webdeck / homebridge-indigo

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

ListenPort #23

Closed hassancy closed 7 years ago

hassancy commented 7 years ago

This plugin is great and I am expanding its usage. But I wanted to inquire whether there are any updates to expand the plugin to include working of the ListenPort. I have not seen any updates on Homebridge Buddy since it was pulled so was wondering if this plugin's functionality could be expanded in that regard.

KardelSniper commented 7 years ago

Hi @hassancy , I also experienced this problem and reported this to the author. My understanding is that this is really HBB and Indigo's thing to solve, as this plugin is only providing an interface to listen, but Indigo needs to actually send the status update. For now I used Indigo's python and Applescript to create triggers so as to use this ListenPort, and now HomeKits gets correctly updated of device status. For each trigger, you just need to make it work whenever a device status changes, and send an HTTP request to (if homebridge and indigo are on the same server and ListenPort is set to 8177) http://127.0.0.1:8177/devices/YOUR_DEVICE_ID and this will do the work. Hope this helps :)

hassancy commented 7 years ago

I understand creating triggers when a device status changes to execute a script. I just need a little help on the script if you don't mind. What you are suggesting is an AppleScript that uses the curl command? Could you share your language syntax with me?

KardelSniper commented 7 years ago

@hassancy Sure. So if you don't need to batch-create such triggers, then it's very easy and you don't need to use Applescript - Python will better do the job. Say you have a dimmer switch, and you create a trigger for it, type being Device State Changed, and you select that device (take down its Indigo ID), making this trigger react to Brightness Level -> Has Any Change, then in Actions you choose Execute Script, and create this Embedded Python script:

import httplib
httpServ = httplib.HTTPConnection('127.0.0.1', 8177)
httpServ.connect()
httpServ.request('GET', '/devices/YOUR_DEVICE_ID')

This is a very simple script that just sends this request to Homebridge-Indigo, which upon receiving it will tell HomeKit to update this device's status. It doesn't check for errors etc, just very basic function, but works like a charm on my end (you need to close and relaunch the Home app before this will take effect, and sometimes the update will be delayed a bit before you see it in Home, from my experience). Hope this helps!

webdeck commented 7 years ago

Thanks for providing the workaround @KardelSniper!

KardelSniper commented 7 years ago

@webdeck My pleasure :)

hassancy commented 7 years ago

Thanks a bunch @KardelSniper

KardelSniper commented 7 years ago

@hassancy No problem :)