Openhab-android: Feature: Built-in Tasker integration

Created on 25 Dec 2016  路  25Comments  路  Source: openhab/openhab-android

Currently openHAB Android client is a standalone app, with no connections with smartphone's sensors or environment.
I think that combining the power of the app with Tasker plugin would revolutionize a way we interact with our home automation system. Or, at least, make it easier to integrate multiple Android apps with HABdroid (is it still accurate name?:))

Here's one tutorial on how to create your own Tasker plugin and a thread on that matter as well.

Best regards,
Kuba

Bountysource

enhancement

Most helpful comment

Feel free to test: https://github.com/openhab/openhab-android/pull/1338#issuecomment-489307359

Actually, I think it would be better to create a seperated Tasker plugin which is not too tightly integrated with the Android App.
That way, the plugin could be used for:

I disagree with creating a new app for this. The code used for the Tasker plugin is basically just the list to pick the items from and this list can be re-used in the future for other features.

All 25 comments

Agree! Along similar lines, I would like to be able to choose item names in the app which will be updated by the app based on location, motion, battery level, signal level, etc.

I created two mockups of basic plugin configuration steps.

In Tasker, after you choose the plugin and go to Configuration, you'd see a list of possible actions.
(e.g. Items Actions, Binding Actions, Things Actions... whatever our REST API allows us to use :))
I think we should focus on Items Actions at first. Baby steps.
1

And in the next screen you'd assign a command to the item you selected:
2

openHAB Tasker integration

  • [ ] Display an openHAB icon in Tasker Actions / Plugin
  • [ ] Show a OpenHABTaskerActionActivity window (title: "Action configuration")

    • A list view of two elements: openHAB Item and command



      • Clicking Item element should open a dialog


        with radio list of all items (you can select only one item)


        with one button: Cancel


      • Clicking Command element should open a dialog


        with Text field and two buttons: Cancel, Save



    • Two buttons: Cancel, Done

  • [ ] Command element can receive Tasker variables (like %BATT)

I'm not a Java dev, but I started studying the docs and HABdroid's source code to get things going.
I encourage others (more experienced) to jump in! :)

Actually, I think it would be better to create a seperated Tasker plugin which is not too tightly integrated with the Android App.

That way, the plugin could be used for:

  • Tasker ( https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm )
  • Locale ( https://play.google.com/store/apps/details?id=com.twofortyfouram.locale )
  • any other apps that use the same API

There are examples that show how a plugin for both services at once can be written.

Thanks @hakan42 for the input! What would be the benefit of having them maintained separately?

So is there anything to be done on HABdroid's side in order to communicate with the separate plugin?
At a glance, it seems that we would need a BroadcastReceiver to handle item's state change.

I found some examples already and I'm looking at the toast example from the Tasker docs, but to be fair, it's my first date with Android (I'm a JS dev) and it can take a while before I even start coding anything 馃檪
Cheers

The main reason is, I don't believe in one application that does everything. And extending the Android App into Tasker area sounds like one thing that tries to do everything.

My personal philosophy is to create small tools that do one thing really well and leave it to the user to combine them into unexpected little gems. Therefore the plugin idea. You might also notice that OH2 and Tasker itself are basically a large number of plugins / addons that speak the same API.

I get your point, but in this case we would just extend HABdroid with additional feature (like NFC or Beacon integration, the only difference being wired to third party app and not the hardware).
See apps like Pushbullet, Unified Remote etc. These are also big apps but extended with Tasker Action.
I think it would alsp be easier to keep maintaining one app.

I don't see a problem adding Tasker integration, as long as it does not create any new mandatory dependencies or new/higher minimum requirements that non-Tasker users would have to contend with, and does not have any impact on licensing issues. For users who are uninterested in Tasker, they see no new UIs or other changes and the app continues to work as if nothing changed for them.

As a heavy Tasker user I'll +1 for the idea. I do not think adding support for Tasker into Habdroid itself would necessarily be apparent to users who do not use Tasker. Looking at the examples @kubawolanin mention, there is no evidence of Tasker in the main application. It is only when you go into Tasker that you find it in Plugins (I'm not sure what the distinction between Plugins and 3rd Party is within Tasker but suspect Plugin is where this would fall).

At a minimum, exposing an intent that Tasker can call with the Item name update type (command or update) and state would be awesome for most commanding and sensor updates from the phone use cases. Personally that is all I would need for my use cases. This is how I control Waze and PocketCasts from Tasker and it works great.

However, with a proper plugin I can see the future possibility of commanding Tasker from OH which now can be achieved somewhat awkwardly through something like Pushbullet or SMS messages.

There was no progress on this feature for a long time, but I found an interesting repository yesterday.
@dereulenspiegel made a great Android app called HABSweetie some time ago :)
I couldn't make it work with my OH2, but the source code of Tasker integration is already there.
Maybe it would be worth to combine forces on this one and reuse @dereulenspiegel's work in HABDroid?

https://github.com/dereulenspiegel/HABSweetie/tree/master/App/HABSweetie/src/main/java/de/akuz/android/openhab/tasker

Besides the finding above, I started tinkering with the HABDroid code some time ago on this branch.

Cheers,
K

Is someone working on this? I think it would be a great idea.

@nbmaltais I think no one is working on this yet.

Can tasker send and receive android broadcasts?

@mueller-ma sorry for late response. On the Tasker docs page there are some references to BroadcastReceiver. It doesn't tell me much though 馃槈

Here's some introduction on Tasker plugin development.

Would you give it a try? Would be awesome!

Cheers

Tasker supports three different types of plugins: action, condition and event:
when event then if (condition) { action }

Event and condition plugins requires us to receive FCM messages when items update, which isn't possible right now and the same reason why #6 is blocked.

Action seems doable as well, since we have #1137 merged now.

  1. Create an activity ("EditActivity") that is started by tasker if someone selects openHAB as an action.
  2. Display all items as a list there
  3. On click, show a dialog and ask for the value.
  4. Return a bundle containing these two information (item + state)
  5. Enhance BackgroundTasksManager to start a worker if it receives the bundle from tasker

IMO we should start with action first. I'm not sure about the UI: Should the EditActivity just display a list of all items or should we display the sitemaps and let a user pick an item from there?
Sitemaps are user generated, so he knows best where to find an item.

Also following actions might be useful:
Change theme (Change between day and night theme)
Open sitemap
Start voice recognition

Should the EditActivity just display a list of all items or should we display the sitemaps and let a user pick an item from there?
Sitemaps are user generated, so he knows best where to find an item.

From a user's perspective, I might not have any sitemap at all if I'm a HABPanel user. Also, I might not have the Item I want to interact with from Tasker on my sitemap.

As for displaying the list of items, I would hope the list is searchable? Some users have 1000+ Items.

I would also go for a list and not for a sitemap based Activty.
Besides richs points, one maybe wants to add some automation on top for items that are not in the sitemap.

The "PickItemActivity" can be used for multiple features (#538 and #6). My idea was to create multiple alias-activities with each an intent filter for tasker or widgets and assign the onClickListener based on the called alias activity.

Feel free to test: https://github.com/openhab/openhab-android/pull/1338#issuecomment-489307359

Actually, I think it would be better to create a seperated Tasker plugin which is not too tightly integrated with the Android App.
That way, the plugin could be used for:

I disagree with creating a new app for this. The code used for the Tasker plugin is basically just the list to pick the items from and this list can be re-used in the future for other features.

@mueller-ma i read that it could be easily maintained within the current app source.
And i read that this would be the lowest effort related to maintainability.

If my readings are correct i would fully agree with you to keep it in one source. :)

Does it make sense to send state updates to groups?

Does it make sense to send state updates to groups?

Yes ... think e.g. roller shutters.

@mueller-ma As #1338 is merged, can this one be closed now?

@mueller-ma big thanks for implementing this! :-) OH just became more powerful.

The app now supports Tasker variables.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cribskip picture cribskip  路  8Comments

mueller-ma picture mueller-ma  路  3Comments

FredericMa picture FredericMa  路  10Comments

magd1978 picture magd1978  路  10Comments

kubawolanin picture kubawolanin  路  13Comments