REST API and Tasker on Andriod

2,102 views
Skip to first unread message

Neil Renaud

unread,
Sep 22, 2014, 12:12:12 PM9/22/14
to ope...@googlegroups.com
Hi,

Has anyone managed to use Tasker on Andriod to send a HTTP POST request to the REST API? If so do you have an example of the details I need to fill in to get it to work? 

I'm essentially trying to trigger a rule when my alarm clock goes off in the morning...

Thanks,
Neil

Christoph Wempe

unread,
Sep 22, 2014, 1:18:05 PM9/22/14
to ope...@googlegroups.com
I am using it.
It's really simple.

Just add an "HTTP Get"-action and fill in the first three fields.

Server:Port -> 192.168.0.2:8080
Path -> CMD
Attributes -> Switchname=ON

This will set the item "Switchname" to "ON".

For troubleshooting you can manually type in the whole URL in your browser.
In this exaple it would look like this:

Joshua Pond

unread,
Sep 22, 2014, 3:04:19 PM9/22/14
to ope...@googlegroups.com
The other option you have if you don't want to go through this is to get HABSweetie. There is a plugin for HABSweetie and Tasker.

Josh

Ben Jones

unread,
Sep 22, 2014, 3:44:40 PM9/22/14
to ope...@googlegroups.com
I am using Tasker to interface with openHAB - it works very well, especially when you add AutoVoice into the mix. 

I am using HTTP Post tasks to send commands (instead of GET - not sure what the difference is to be honest);

Server:Port:  https://user:password@openhabserver:8443
Path: rest/items/Appliance_CoffeeMachine/
Data: ON
Content Type: text/plain

This allows me to access the system remotely, securely, with authentication. 

eric

unread,
Sep 23, 2014, 10:55:56 PM9/23/14
to ope...@googlegroups.com
This sounds really interesting.  How are you guys using it?  What kinds of things are you doing?

Eric

Ben Jones

unread,
Sep 24, 2014, 12:19:56 AM9/24/14
to ope...@googlegroups.com
I don't have a huge number of profiles setup but they include;

coffee machine on/off
coming home - this is great when driving home, can just pull out my phone and say 'coming home' and it will disarm the alarm, turn on the lights and open the garage door
garage door - open/close garage door
tv on/off

Interested to hear how you end up using it...

Neil Renaud

unread,
Sep 24, 2014, 12:48:46 AM9/24/14
to ope...@googlegroups.com

I've not tested it yet but I'm planning to turn the house lights on when my alarm goes off.

--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/38jn0Xb-J7o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Joshua Pond

unread,
Sep 24, 2014, 1:08:46 AM9/24/14
to ope...@googlegroups.com
I use it mostly for the voice and the widgets.

I can have a widget that runs whatever HA stuff I want.
I also use it for when my phone connects to the WiFi my presence changes to being at home. I also have the network health binding that runs every minute but this is a bit more precise. The NTP is a backup.
Also for when I'm asleep. Tasker notifies when the phone is on charge for so long at certain times it lets openHAB know I'm asleep. When I undock in the morning it fires off whatever I want in the morning.

Probably a few other things too that I have planned.

Josh

Ben Jones

unread,
Sep 24, 2014, 4:47:11 AM9/24/14
to ope...@googlegroups.com
Good idea re. WIFI for presence Josh, I too have the network health binding polling every 60s but somethings that is a bit slow for my liking. Thanks for the tip!

I do something similar with my phone at night too. If it is after 9pm and I am connected to my home WIFI network, when I plug my phone into the charger it activates the 'sleep' scene. This turns off all the AV equipment, checks all external doors are closed, and lowers all the lights (so I can find my way to bed). Then after 5 mins everything is shutdown.

Tasker really is a wonderful tool when integrated with openHAB, and to be honest is probably the main reason I will never go back to iOS!

Christoph Wempe

unread,
Sep 24, 2014, 11:21:05 AM9/24/14
to
  • voice
    • "Good night" sends "sleeping ON" to openHAB
      • : Light turns of, radio gets quieter, radio gets shutdown after 60 minutes, "Sleep as Android"-app starts
    • "volume XX" sets the volume of my current playback to XX. (no matter if i play radio in Zone2 of my AVR or I watch a movie.
    • "lights on/off"
    • "how warms is my flat?"; phones answers with the current temperature
  • sends "sleeping OFF" to openhab when alarm goes off
    • starts radio
  • send "I am home" when I am connected to home wifi and dosconnect my headset.
    • starts radio
  • send "i am not home" to openHAB wehen I connect my BT-headset while connected to home wifi.
    • turn off radio
  • sends "calling ON/OFF" when call starts/ends (my favorite)
    • mutes or pauses current playback
      • radio and live tv get muted
      • movie, series (XBMC) get pauses

Christoph Wempe

unread,
Sep 24, 2014, 1:54:12 PM9/24/14
to ope...@googlegroups.com
I just created a wiki entry about controlling openHAB with Android.

It's just quick and dirty. ;)

Feel free to clean it up or add anything you consider usefull.

Joshua Pond

unread,
Sep 24, 2014, 4:40:23 PM9/24/14
to ope...@googlegroups.com
The On/OFF calling is a good idea except in our house if my wife or the kids are watching and I get a call. Could probably add it to the TV and Squeezeboxes too.

One thing you can also try is the Yatse XBMC remote. Great remote with a few plugins that pause the movie when you get calls. It mostly seems to be only whoever started the movie on their phone so works a bit better on multi person households.

Not so openHAB related but I also use the intents so my 'watch a movie' turns on the theatre room and also opens up Yatse to the correct media player.

Josh

Ben Jones

unread,
Sep 24, 2014, 4:48:02 PM9/24/14
to ope...@googlegroups.com
Josh - so you have a 'Watch a Movie' task in tasker that can automatically fire up Yatse for the correct instance of XBMC?

Are you using the XBMC binding with openHAB? I am using that to control all my lighting, for example dim when watching a TV show, or turn off if watching a movie. Also pauses when I get a call on the landline (via Freeswitch), same with my Squeezeboxes, and resume when the call ends. Actually works extremely well that bit.

Don't have it hooked up for my mobile calls however, since as you say, if the wife is watching something and my phone rings not sure she would be all that happy if everything stopped.

Amazing what you can do with this stuff - always good to hear what others are doing to get inspiration tho!

Ben Jones

unread,
Sep 24, 2014, 4:50:15 PM9/24/14
to ope...@googlegroups.com
Christoph - any reason you don't use that ResTask tasker plugin for all interactions with the openHAB REST API? I didn't know about it but it looks great, especially the nice and simple support for authentication. Currently I am using the HTTP POST task for sending commands, and have the authentication details in the URL itself. I am going to have a play with ResTask. Just wondering why you only use it for sending commands and not requesting values?

Christoph Wempe

unread,
Sep 24, 2014, 5:51:17 PM9/24/14
to
Since I haven't enabled athentication (yet) the HTTP Get works just fine and simple for sending commands.
And I prefer build-in solutions if there is no significant reason to use a 3rd party plugin.

But it would be great if you could add your suggestions to the wiki so other users can decide for themself wich way suites them best. :)

btw: Does anybody know how to upload images/screenshots to the wiki?
I just found a way to embed images from (other) urls.

Joshua Pond

unread,
Sep 24, 2014, 6:17:48 PM9/24/14
to
Ben - Yes of sorts.

I have a 'watch movie' task in tasker. It turns on XBMC through openHAB and openHAB controls the lights (through http GET to InControl Software). My zwave isn't on openHAB as it doesn't support locks at the moment. Change in state/play/pause with XBMC is controlled through openhab with openHAB telling inControl what to do with the lights.
I haven't fully tested Yatse and the calling/pause plugin thing but when the kids watch something sometimes me or my wife turns it on. Sometimes with calls it pauses and sometimes it doesn't and I think it has to do with who was controlling XBMC.
One of the actions in the 'watch movie' task is to open the app yatse with the intent to open the correct instance of XBMC.

Josh

Ben Jones

unread,
Sep 25, 2014, 1:52:45 AM9/25/14
to ope...@googlegroups.com
Nice one Josh - I might have to give that a try.
Reply all
Reply to author
Forward
0 new messages