Getting iPhone apps that support Hue to work with Hue emulator

As the topic says. I’m wondering if it is possible to get the Hue Emulator component to work with iPhone apps (for sneaky integration), I have tried but gotten it to work (even with port 80). In my case I would like HASS to know if house is sleeping or awake by following the state of my Sleep Cycle app, which can send on/off signals to Hue. Since I prefer to have all intelligence directly inside of HASS.

Any one know if the HA-bridge might be a better alternative?

/R

1 Like

I managed to get my Logitech Harmony remote to control my HA using the HUE bridge I set up in HA originally for Amazon echo if that’s the kind of thing your looking for? I don’t see why it wouldn’t work for you.

Thats exactly what I’m after! The app in this case waits for the button to be pressed on the bridge. Maybe it is my physical bridge that takes precedence for some reason. If it works for you I will try some more.

Did you change your port to 80 or keep default settings?

/R

I ran into the same problem i found by accident that at least for my installation, it would find things better and the button press notice would auto elapse if i started processes after a HA restart.

My process for Alexa was…
Stop Home Assistant > Start Again > As soon as HA UI displays Tell Alexa to Search. Devices were added

My process for Harmony via IPhone App…
Stop Home Assistant > Start Again > As soon as HA UI displays start search for hue via app > App asked me to press button on my bridge > Left it hanging > App acted as if button was Pressed > Requested HUE sign in > i created an account (i didnt have one) > The app then failed to find devices in my account BUT all device show and synced to other Harmony equipment.

I’m pretty sure this isn’t the way its supposed to operate but it worked for me… I left the default port settings but i don’t have a physical bridge on the network like yourself.

Hope this helps.

Thanks jamieb!

Will try out your suggestions.

It would be awesome if this worked! Seamless integration :smiley:

/R

Hey Robban – please let me know how this goes! I’m guessing you’re using Sleep Cycle Alarm Clock, and I’d very much like that same integration :smiley:

Indeed I am!

I have verified with other apps that the emulated hue bridge is actually getting picked up correctly. Sadly though the Sleep Cycle Alarm Clock app does not recognise it. I have written a request for the developer to add support, hopefully it is only a smaller improvement in order to get the support working.

I will update this thread when I get a response from the developer

/R

Aww, too bad, I was really hoping for the magic of a swipe! If you find an alternative solution, please post it here as well :wink:

I’m crossing my fingers for the dev to step up!

I saw that there was an update to Sleep Cycle today, have you tested whether there’s been a fix?

Also, would you mind linking me to your support ticket? :smiley:

I’m also trying to get this setup working. Using ha-local-echo, I can see in the log that the Sleep Cycle app discovers the emulated Hue:

192.168.7.31 - - [14/Nov/2016 00:39:09] “GET /description.xml HTTP/1.1” 200 -

However, nothing happens in the app, I just get a blank page. I suspect the emulation is not good enough for Sleep Cycle.

Ideally, the built-in hue emulator component should be used, but I’m even more at a loss how to debug this.

If someone with access to a physical Hue bridge and the Sleep Cycle app could assist, this would be much easier to debug.

I will try to do this again some time during this week. I will get back to you.

I didn’t get a reply from them regarding this ticket. Will try to find it also some time during this week.

/R

For the record, ha-local-echo sent a description.xml as from a 2015 gen2 Hue. I tried to modify it to show up as a gen1 2012 unit, but it did not help, or I could create a proper description.xml.

I have a physical hue bridge but not much time on my hands. If you can give me step-by-step instructions, I can give it a go :slight_smile:

First, verify that your setup works.

  1. Download Sleep Cycle from the App Store.
  2. Go to Settings, Philips Hue. Turn on the switch.
  3. Verify that you get something else than a black screen.

If this seems to work, I’d like to get a copy of your description.xml file. It is available at
http://YOUR-HUBS-IP:80/description.xml, or possibly at another port, depending on your setup.

It works, here’s my XML :blush:

Thank you! I have now gotten a bit further. :slight_smile: It seems that Sleep Cycle is ignoring the port given by the URLBase tag in description.xml, and instead uses 80 as the hard-coded port. This is a bummer, since port 80 is more likely to be unavailable on a machine running a Hue emulator. :frowning:

Anyway, I tested running ha-local-echo on port 80, and this made Sleep Cycle try another request, this time for “/api/(null)”. To which ha-local-echo responded with a 404. So, if you’re willing to continue trying, the next step is to download the response from http://YOUR-HUBS-IP:80//api/(null) and send it to me. Note that the parenthesis should be there. (It looks like a bug, I suspect they should really have sent “api/”)

Edit: Just for the record, they did a GET while ha-local-echo only supports POST for “/api”. Ho hum.

Actually, you don’t need to do that. :slight_smile: I managed to get further along on my own, and now I’ve hacked ha-local-echo to give a reply that Sleep Cycle accepts.

However, it’s hard-coded, and I need to figure out a good way to integrate this properly.

For the record, here is the conversation that Sleep Cycle assumes:
192.168.7.30 - - [18/Nov/2016 10:07:11] “GET /description.xml HTTP/1.1” 200 - # this will be done on the port given in the discovery record, however future request will ignore this port.
192.168.7.30 - - [18/Nov/2016 10:07:11] “GET /api/(null) HTTP/1.1” 200 # assumes a response “[{“success”: {“username”: “12345678901234567890”}}]”
192.168.7.30 - - [18/Nov/2016 10:07:12] “POST /api HTTP/1.1” 200 # the post contains the content: {‘devicetype’: ‘QuickHue’}
192.168.7.30 - - [18/Nov/2016 10:07:14] “GET /api/12345678901234567890 HTTP/1.1” 200 # assums a resonse with a full dump json with lights, groups, config and schedule.

I’ve figured out all details, and I made a tidied-up patch of ha-local-echo. It is available at https://github.com/magicus/ha-local-echo.

This version actually works with Sleep Cycle. I have verified that it turns of a light when selecting “instant” turn off at sleep time. (I have not bothered checking for turning on, I assume it works).

However, it does require the user to select port 80, as I said previously. At least for me, this makes this solution more or less unusable. :frowning:

Thanks a lot for your work! I guess OP can now post a pretty detailed bug report for sleep cycle :blush:

Great work guys! I will post a new request giving these details which hopefully generates a reaction which the previous request obviously didn’t…

/R