homebridge-wyze-connected-home-op icon indicating copy to clipboard operation
homebridge-wyze-connected-home-op copied to clipboard

Show disconnected devices as "No Response" in HomeKit

Open willdhorn opened this issue 2 years ago • 3 comments

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:

  • Connected Bulb {"ts":1651193896923,"code":"1","msg":"","data":{"session_id":"<just_some_hex_junk>","result":2}}
  • Disconnected Bulb {"ts":1651193893152,"code":"1","msg":"","data":{"session_id":"<different_hex_junk>","result":4}}

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 avatar Apr 29 '22 01:04 willdhorn

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 avatar Apr 29 '22 01:04 willdhorn

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

willdhorn avatar May 04 '22 13:05 willdhorn

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

jfarmer08 avatar Jun 13 '22 18:06 jfarmer08