RMCob / homebridge-wyze-connected-home-op

Wyze Connected Home plugin for Homebridge with support for the Wyze Outdoor Plug
http://github.com/RMCob/homebridge-wyze-connected-home
MIT License
41 stars 20 forks source link

Show disconnected devices as "No Response" in HomeKit #28

Open willdhorn opened 2 years ago

willdhorn commented 2 years ago

When a device is unable to be reached by Homebridge (or HomeKit), the typical response is to show it as 'No Response'. Currently, however, devices connected with this plugin show no indication, even though the Wyze app shows the device as disconnected. Trying to control a device will show as if the request was sent to the device and worked, and then revert back to the previous state the next time it performs a get_object_list request.

Fortunately, there is enough information in the Wyze response to tell whether a device is connected or not. In the get_object_list response, it appears that the "conn_state" property indicates whether it's connected or not (where "conn_state": 1 means connected and "conn_state": 0 means disconnected)

There also seems to be some kind of indication in the set_property response. Here are two responses to two bulbs where one is connected and the request worked, and the other is disconnected as shown in the Wyze app:

Now without official Wyze documentation of their API, its hard to say exactly what these result codes mean, but it my testing requests made to the disconnected bulb have consistently returned responses with result as 4.

Would it be feasible to have the plugin return some kind of error so that homebridge knows to show the device as 'No Response' when the API indicates a connection issue?

willdhorn commented 2 years ago

The corresponding property id (in the get_property_list response) for availability is P5 according to the python API that the HomeAssistant plugin uses

willdhorn commented 2 years ago

This helped me understand how the 'No Response' state works with HomeKit and bridges: https://github.com/ebaauw/homebridge-hue/wiki/No-Response. Particularly:

Most other Homebridge plugins and the native HomeKit feature of the Hue bridge report unreachable devices by returning an error status on read or write, causing HomeKit to set No Response

jfarmer08 commented 2 years ago

Support added to https://github.com/jfarmer08/homebridge-wyze-smart-home