webdeck / homebridge-indigo

Homebridge Plugin for Indigo
Apache License 2.0
13 stars 6 forks source link

Homekit status not updated #21

Closed KardelSniper closed 7 years ago

KardelSniper commented 7 years ago

Hi there, I've been using the plugin for a while and it was really great! But just noticed this problem: when I operate my Insteon devices through Indigo or through physical switches, the device status won't be updated in Homekit. My other devices (eg, MyQ garage door openers) that do not use Indigo, but directly use Homebridge to connect to Homekit, do not show this problem. I wonder if this is a bug or did I do something wrong? Or do I need to specify the listenPort to make this work (tried sending it a http request with "id=deviceID" as parameter, but got "Cannot get /"). Please help, thanks a lot!

webdeck commented 7 years ago

This requires using both listenPort and an Indigo Plugin that communicates with that listenPort to update the status of devices whenever Indigo observes a change. The Indigo Buddy plugin was building support for this figure, but the developer has stopped working on it for now.

KardelSniper commented 7 years ago

Thanks for the quick reply! Appreciate it. So could you provide some specifications on the request that the homebridge-indigo plugin is expecting on the listen port? I might be able to help develop something.

Also, there's another problem I discovered while using the plugin (probably should start another issue). It only started to happen recently: almost all the devices controlled by indigo (and thus this plugin) reverted back to "default room" in homekit. I wasn't able to figure out what triggered this: I tried restarting homebridge, indigo, both, re-register homebridge etc, and thought it might be homebridge started before indigo devices were discovered, but wasn't able to reproduce the problem. It seems to happen randomly when there're lots of devices used. And this only affected the room designation, not other things like "show in favorite". Just wondering if you happen to have any idea why this happened?

Thank you very much!

webdeck commented 7 years ago

The plugin would need to send an HTTP GET request to /devices/deviceID on the listenPort, where deviceID is the Indigo device ID of the device that needs to be updated. homebridge-indigo will then query Indigo to update the state of that device. Returns 200 on success, 404 if the deviceID is not known to homebridge-indigo, or 500 if there was an unexpected error talking to Indigo.

I was hoping to get enough free time to write a plugin, but then life intervened. :)

KardelSniper commented 7 years ago

Hi, Thanks for the explanation! I was able to get the listenPort to work by writing some triggers using Indigo, now HomeKit updates devices states properly. It's not an easy solution, I wasn't able to easily get the triggers device id using its python api, so had to use some applescript. I wasn't able to find the correct documentation, so this process is really an ugly workaround. But finally got it to work! In fact if there're just a few devices, then it's very easy, just create a brightness or on/off state trigger for each that sends the http request to your plugin, with device id hard-coded. But I have 80+ devices, so I had to write an action group that iterates through all devices, and use python to execute applescript to create all those triggers - plus, since I didn't know the correct way to specify action type, had to copy manually created triggers. Really a user-unfriendly solution :(

Anyway thanks for the help! Let me know if you'd like to have the details of my solution.

webdeck commented 7 years ago

Clever hack!

KardelSniper commented 7 years ago

Thanks! I read the method from another Indigo forum user's post and thought about using it here.

webdeck commented 7 years ago

PS - On losing room assignments and favorite status, it's an ongoing issue with homebridge itself. There is hope that the next major revision of the homebridge server will add support for syncing room assignment, using a future update of the Hesperus iOS app to assign the rooms specified by homebridge (since room assignment is only possible via an iOS app.) This is the thread discussing those future enhancements to homebridge: https://github.com/nfarina/homebridge/issues/1039

KardelSniper commented 7 years ago

Thanks for letting me know about that! Very much appreciated. I thought it was Indigo-only, since only my Indigo-controlled Insteon devices had this problem. But well, this entire thing is so complicated so who knows. It's really a pain having to re-assign 80+ devices to rooms every day or two though XD

KardelSniper commented 7 years ago

Hi again, just want to report that the room issue happened to me again early this morning - this time it went further, that all indigo accessories disappeared (while other stuff managed by homebridge remained). I checked homebridge lot, it seems that somehow homebridge restarted, and when trying to connect to indigo, an error was returned: ERRCONNREFUSED, and then it says discovered 0 accessories. I guess this might be the same issue that's causing room assignments to be cleared? If this is indeed it, do you think it's a good idea to add some error handling in your function that sends the request "/devices.json"? Like, if error occurred, instead of just log it, but try again or stop the process?

I'll look more into it and see if this is indeed the cause. Thanks!

webdeck commented 7 years ago

Thanks - can you open a new issue for that?

KardelSniper commented 7 years ago

Sure. Will do right now. Thanks!