Control openHAB via Workflow App and Notification Center in iOS

Hi Community,

I hope this is the right board. I would like to show you, how I use the Workflow app for iOS and URL manipulation to control openHAB directly from the notification center in iOS. Maybe it is of interest for someone.

Within the Workflow app you can create workflows (what else haha), just like “Get Contents of URL”, where you can specify an URL like “http://192.168.1.10:PORT/CMD?Lights=ON”. When starting the workflow it just “opens” the URL in the background, which triggers the switch. (Safari won’t be opened for that.)

It only works from inside my home wifi, because of the security settings of openHAB and the use of internal URLs. Of course there are ways to build workarounds, but this is ok for me so far.

The workflow can then be added to the notification center of iOS, which looks like this.

One problem is, that you don’t see the states of the switches. The only feedback the notification center gives you is that the workflow was executed successfully (or not). But you can’t see, if your lights are off or if the garage door is open.

But I can also start and stop openHAB from the notification center, even when I’m not at home. The workflow doing this creates a specified file and puts it into a folder on my Dropbox. The file syncs to my openHAB-server where the dropbox-folder is monitored. Once the file appears, an automated task shuts down openHAB. (Or the other way around, when I want to start it.) Works pretty good and is very solid.

If you have any questions regarding this setup, feel free to ask. :slight_smile:

Cheers
Norman

1 Like

I’m mostly interested in these workarounds.

I spent all of five minutes experimenting on my wife’s iPhone and I could not find a single way to store a URL that includes the username and password as part of the URL. Since the things that she needs to interact with she needs to do so on the boundary of our home network (sometime in, sometimes not) this ended up being a deal killer. My current workaround is to have IFTTT Do button recipies for her and I’m working towards using an Amazon Dash button to trigger the event (opening the garage). But there is a bit of a lag with IFTTT (and the Dash buttons as well) so being able to use Workflow might be better.

On my Android I happily use Tasker and it works great.

I wrote a very little php-script that can be accessed via an URL that does the trick. It’s pretty simple: You put that script on a webserver and open it over it’s URL with three GET-arguments: a predefines secret, the item and the command itself. The script just passes the information to your openHAB instance with curl over .htaccess.

It could look like this http(s)://yourserver.com/?secret=yoursecret&switch=Lamp&setting=ON

I put that script on GitHub.

Another way could be the one I described in my first posting: Let workflow add a file into dropbox, sync that one to your openHAB-server and monitor the folder. As soon a file arrives, a script kicks in that does the thing you want.

But I think the php script is the better way to achieve that, although I haven’t put any thoughts into security issues here. The predefined secret is the only thing that’s keeping it a little secure.

If this Dash button project doesn’t pan out I might try something like this.

Early on I tried putting an Apache reverse-proxy server that would only accept connections with devices presenting a known trusted certificate but I could never get my phone to import the certificate. Worked like a charm on iOS though. I just got a new phone so perhaps that approach is worth checking out again.

Story of my home automation life right now. Works great on Android, doesn’t on iOS. Or the opposite.

Thanks!

Have you considered using my.openhab for use in your workflows?

I have and I do use my.openhab.

But what I want is for my wife is to have something as simple as pressing the physical remote control to trigger the garage door opener. I don’t want her to have to bring out her phone, open an app, and then press a button to trigger the opener. The best I’ve been able to do for her on the iPhone is to create IFTTT Do recipes so it is only a couple of really easy button presses (the sitemap is pretty small when trying to hit the right button with one hand while pulling into the drive way). But the lag between triggering an IFTTT recipe and OH acting upon it is too long most of the time.

I am able to put a Tasker widget on my Android home screen and, even better, have a menu that pops up when I approach the house to trigger it. I mount my phone to a dock as I drive (its’ my GPS) so for me it really is as simple as pressing one button. I can’t do that on the iPhone, though at least with Workflow I can reproduce something as simple as the Do buttons but have instant reaction time.

But if I just put a Dash button in the car then it is back to being a simple as the old remote was.I can’t just use the old opener remotes because they don’t work any more (its a really old opener and I can’t get replacements any more and it is too old to work with universal remotes) and this is what got me started on the whole home automation path in the first place.

I now realize I should have posted this reply here…

See below for accessing my.openhab via the Workflow app (with authentication),

1 Like

Hi there. Sounds great. I wonder - does it work without unlocking iPhone/entering password after tapping? I can not try it, because there is no “Free” mode

Another question - I would like to have same solution for Android phones. E.g with similar design and programming. I know, Tasker could do the job, but wanted easier solution.

I just keep it here as Idea:
In my mind the best way to realize quick and easy HA control from notification center is to have a generic MQTT client with widget capability. E.g. user should be able to create his own button widgets in Notification Center which just publish appropriate messages to broker, when pushed. This would work not with just Openhab, but with any home automation software. Also all authentication and other stuff would be solved by MQTT protocol.
Also such client can easy get status updates and it should not be always connected to broker for this. When you open the center, client should connect, subscribe and broker will automatically send retained messages of necessary items. This is so lightweight, that should be executed in just a moment.
The only problem - I can not find such App in App store at the moment.

@rlkoshak - Hi Rich - Could you share your Tasker setup for this please. I was thinking about trying to do this, but im very much a novice with Tasker.

Some updates include you can manually create and populate a variable from the Variable tab instead of going through the steps I describe.