bachya / eufy-security-ws-python

A Python wrapper around eufy-security-ws
MIT License
16 stars 3 forks source link

Previous guard mode in home assistant #4

Open piitaya opened 3 years ago

piitaya commented 3 years ago

Describe the bug The last value of guard mode is not always updated. The previous value is displayed.

To Reproduce Change the mode in eufy app

Most of the time, the N - 1 value is in home assistant state (not the last value).

Logs I added some debug logs and changing between some modes in eufy app :

select.py (line 136) LOGGER.debug("_async_update_from_latest_data : station: %s, guard mode: %s", self._station.serial_number, state) __init__.py (line 136) LOGGER.debug("Received event: %s", event)

home-assistant    | 2021-07-25 14:42:54 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1, 'currentMode': 3}}
home-assistant    | 2021-07-25 14:42:54 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:42:54 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: home
home-assistant    | 2021-07-25 14:42:54 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:42:54 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'currentMode', 'value': 3, 'timestamp': 1627216974980}}
home-assistant    | 2021-07-25 14:42:55 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 3, 'currentMode': 3}}
home-assistant    | 2021-07-25 14:42:55 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:42:55 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: home
home-assistant    | 2021-07-25 14:42:55 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:42:55 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'guardMode', 'value': 3, 'timestamp': 1627216975089}}
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 3, 'currentMode': 63}}
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: custom_1
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'currentMode', 'value': 63, 'timestamp': 1627216979197}}
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63, 'currentMode': 63}}
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: custom_1
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:42:59 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'guardMode', 'value': 63, 'timestamp': 1627216979305}}
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63, 'currentMode': 1}}
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: disarmed
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'currentMode', 'value': 1, 'timestamp': 1627216981599}}
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1, 'currentMode': 1}}
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: disarmed
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:01 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'guardMode', 'value': 1, 'timestamp': 1627216981691}}
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1, 'currentMode': 63}}
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: home
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'currentMode', 'value': 63, 'timestamp': 1627216989081}}
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63, 'currentMode': 63}}
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: home
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:09 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'guardMode', 'value': 63, 'timestamp': 1627216989174}}
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63, 'currentMode': 1}}
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: disarmed
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'currentMode', 'value': 1, 'timestamp': 1627217003666}}
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1, 'currentMode': 1}}
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: disarmed
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:23 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'guardMode', 'value': 1, 'timestamp': 1627217003761}}
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1, 'currentMode': 3}}
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: home
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'currentMode', 'value': 3, 'timestamp': 1627217010882}}
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 3, 'currentMode': 3}}
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [custom_components.eufy_security] Received event: guard mode changed
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8010N232053264F, guard mode: home
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [custom_components.eufy_security] _async_update_from_latest_data : station: T8410P2021040D57, guard mode: home
home-assistant    | 2021-07-25 14:43:30 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8010N232053264F', 'name': 'guardMode', 'value': 3, 'timestamp': 1627217010990}}

Additional context Works with 0.2.0 version of eufy-security-ws but not with 0.3.2 and 0.3.3 version. I have 2 stations, may be it can be linked ?

bachya commented 3 years ago

Thanks for the info, @piitaya! I need to incorporate the latest websocket schema and see if something changed. Will aim to do that soon.

piitaya commented 3 years ago

Thank's 🙂 Don't hesitate to ask me if you want advanced tests. 🙂

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.