cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 38 forks source link

Reachability #9

Closed cflurin closed 7 years ago

cflurin commented 8 years ago

I've added homebridge/to/set/reachability

topic: homebridge/to/set/reachability
payload: {"name": "flex_lamp", "reachable": true}
or
payload: {"name": "flex_lamp", "reachable": false}

Please install from GitHub:

sudo npm install -g cflurin/homebridge-mqtt
cflurin commented 8 years ago

It seems that the Apple home app doesn't support this feature. I've test it with EVE and here works.

ArnieX commented 8 years ago

@cflurin indeed Home.app doesn't support it. Then it is even more strange behaviour while Philips Hue is able to set "No response" status in Home.app the reachability characteristic does not. Any ideas? I have also come by reachability characteristic in Apple's datasheet for HomeKit but even thought I tried it before somehow it didn't work so I thought I'm doing something wrong and gave up. I have no idea what else it could be as Apple's datasheet doesn't quite give a lot info.

cflurin commented 8 years ago

@ArnieX:

Please install the latest version from GitHub. It should now work for Home too (No Response)

Note: at Homebridge start reachable is set true.

ArnieX commented 8 years ago

You are officially my HERO! ;)

Now I will just periodically test if device is connected or not.

cflurin commented 8 years ago

great! thanks for your feedback.

tvillingett commented 8 years ago

@ArnieX maybe you can use a "last Will and Testament" if your mqtt client supports that, which helps to see if it is unreachable, instead of writing extra client code. See example of use: http://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament

ArnieX commented 8 years ago

@tvillingett that is a good idea and less overkill than pinging the device every 60second.

CaptiveCreeper commented 7 years ago

how do I make it so that the reachability is false when the device is not connected (off or not on the network).

cflurin commented 7 years ago

@CaptiveCreeper Have a look at the documentation https://github.com/cflurin/homebridge-mqtt#set-reachability

CaptiveCreeper commented 7 years ago

The documentation only shows how to set the reachability. It doesnt say anything about how to make it so that when the device no longer responds that it will show as not reachable

tvillingett commented 7 years ago

@CaptiveCreeper Is the idea to use "last will" that I wrote about above not working for you?

CaptiveCreeper commented 7 years ago

@tvillingett When I was looking into last will at first I apparently skimmed though it too much and misunderstood how it worked. After you responded saying that it should work I looked into it more and now it does work. Sorry for wasting your time with something that was already solved.

ArnieX commented 7 years ago

@tvillingett I have also used it on your tip, thanks for that.

linjiejim commented 6 years ago

Thanks for your reference @cflurin , and your tips @ArnieX @tvillingett Could you tell me how to set the accessory "NO RESPONSE", by using"homebridge/to/set/reachability" at server side? thank you in advance! However, @tvillingett 's idea can be used on specific Topic, but "HB-mqtt APIs" are general topics, so it seems that the "last will testament" feature doesn't work fine with it? I will be grateful if you correct my mistake.

linjiejim commented 6 years ago

Cool! And thank you guys for your inspirations. Finally I find it out and here is a brief for those who may need: 1.[mqtt client] publish a "LWT" to broker when connect with [topic] "homebridge/to/set/reachability " and [payload] "name": "YOUR_CLIENT_NAME", "reachable": false). 2.homebridge-mqtt will subscribe this topic and set to "unreachable" once client was ungracefully dropped. 3.remember to set reachability to true when CLIENT starts so that you can wake it up again.