rudders / homebridge-http

HTTP Plugin for Homebridge
Apache License 2.0
178 stars 109 forks source link

Brightness and State #18

Closed tannebil closed 8 years ago

tannebil commented 8 years ago

In homebridge-http, I've noticed that if I turn on a light using the brightness control, the state for the light in Eve/Home doesn't update until I leave and return to the control screen for the light. The same also happens if I just use the power control to turn on or off the light and the brightness doesn't update until I leave and return. Is this something baked into HomeKit, an iOS bug, or something controlled in the homebridge or homebridge-http? There's nothing obvious to my barely trained eye in the homebridge-http code.

That said, as another data point, I also run homebridge-smartthings and the Z-Wave outlet never updates the related characteristic, i.e. if I turn the light on, the brightness will stay at 0% and never updates.

I don't have a "real" HomeKit light to test against.

NovaGL commented 8 years ago

Hi,

This is by design, if you would like it to update automatically you have to wait till @rudders has time to look at my pull release, I am sure it is all fine but I would be happier that way.

Basically you have to change lighthandling to realtime instead of yes. That way it will constantly poll the device.

Try my repo if you want to test realtime polling - https://github.com/NovaGL/homebridge-http-simple

I don't have any smart things devices so you will have to ask in that repo, look in the logs to see if there is anything there mentioning those devices.

rudders commented 8 years ago

when you talk about brightness and power control is this from a HomeKit app or from another app? Same question for zway- are you controlling the devices from outside of HomeKit? In which case @NovaGL is right - some kind of polling of the device is needed unless the device has a callback we can subscribe to (as we do for wemo devices) to let us know something has changed outside of the control/scope of homekit. What device are you controlling with homebridge-http? Does it have an http call to determine it's on/off and brightness states?

tannebil commented 8 years ago

This testing was all done from HomeKit apps (Eve and Home). I have access to the lights from other apps (Smartthings for the Z-Wave light and Space for my UPB lights but my focus was on just testing Homekit.

I have brightness and on/off url's for the lights and the status/brightness ends up correct once I navigate away from the light screen and back in both Eve or Home.

You guys are way ahead of me all this stuff so I need a few breadcrumbs on the trail to be able to either install http-advanced or answer your question about callbacks. This is my first excursion into the world of GitHub and callbacks.

rudders commented 8 years ago

If you use a HomeKit app to turn on the lights or change the brightness is should update the app immediately. From my experience all apps handle this fine. If this is not the case the we should investigate.

If you change the state of a light via a d Non-HomeKit app then Homebridge-http won't know about it and won't be able to update HomeKit.

If the are zwave and smart things accessories why not use their respective plugins rather than http?

tannebil commented 8 years ago

Most of my lights are UPB controlled by an HAI Omni. No plug-in exists for it.

I'm using the homebridge SmartThings plug-in to control the single Z-Wave light I own.

I understand the problem with trying to keep status consistent. UPB has ways to trigger lights at a hardware level and getting the status changes into the app I was using was a bit of a challenge.

NovaGL commented 8 years ago

I have good news and bad news for you. I use HAI Omni as well and I can control it through Homebridge, the bad news is you need a piece of software in the middle to translate it to a form Homebridge understands, I use Openremote but you can also use HomeSeer or OpenHab.

I warn you its not for the faint of heart.

rudders commented 8 years ago

Do you have a URL that you can use to get the status (on, off, brightness)?

And if you do, what return values doesn't provide? is it just a number or is it some sort of XML or JSON structure

rudders commented 8 years ago

Oh!! @novagl.

That's sounds promising

NovaGL commented 8 years ago

@rudders I compiled my OpenRemote setup from source, took me a very long time to figure it out. Now no matter what the appliance is I can get Openremote to convert it to HTTP and use my other homebridge plugin called homebridge-openremote to do status polling and on off \ brightness.

It's really quite cool as I can link Harmony Hub, Yamaha any device I want and it converts the SSH or SOAP command, XML command or JSON GET\POST\PUSH to a simple HTTP GET command.

rudders commented 8 years ago

That does sound sweet. I might just take a look.

tannebil commented 8 years ago

rudders, I have a a URL that returns brightness as a 0-100 integer value and one that returns the power state (0/1). The URL to set any of these values does not return anything.

NovalGL, I'm using HaikuHelper to control my Omni. If I knew what I was doing, I suspect it wouldn't be too difficult to write a plug-in for it as the documentation is full of all those cool buzzwords like JSON, REST, and service endpoints . I'm a bit concerned about its future as the developer has gone quiet for a few months. It's a nice product but it was never clear to me that the economics exist to support a commercial product.

HaikuHelper is available in the Mac App Store for $50 but hasn't been updated in a couple of years. I assume the developer is busy making a living doing something else. The good news is that it's been largely trouble-free.

NovaGL commented 8 years ago

I use Haiku (iOS) too, it's superseded with "Space".

If this is something you want to do, you should really look into how HaikuHelper can give you the right output as that is the best way moving forward, btw HaikuHelper does voice control but I guess you want it all on the one app.

Talking about REST, get a chrome plugin called DHC, that way you can see the results of your HTTP GET and POST commands to better understand how to integrate it into Homebridge

tannebil commented 8 years ago

Space is my primary HA app at the moment but since Space Server hasn't shipped, Haiku also has to be installed and configured on my devices to receive notifications.

So why didn't you write a homebridge-haiku plug-in? Did you just want a more extensible plug-in?

NovaGL commented 8 years ago

I use Haiku not HaikuHelper, what is the reason you ask. I have a household of iOS, Android and Windows Phone users, using HaikuHelper is extremely limiting as well as the fact it is very expensive, I build mine own OpenRemote setup for $0 (exc hardware)