bropat / eufy-security-ws

Small server wrapper around eufy-security-client library to access it via a WebSocket.
MIT License
169 stars 24 forks source link

[Bug]: No property changed event for camera Eufy Security 4G LTE when alarm is triggered #186

Closed witold-gren closed 1 year ago

witold-gren commented 1 year ago

Version

1.3.0

Node version

v16.19.0

Operating System type

Docker

Operating system version

Home Assistant 2023.1.4, Supervisor 2022.12.1, Operating System 9.4

Describe the bug

Hey, thanks for you effort to create this plugin and add new devices. There is some really great work done here.

I discovered one problem with specific device. For Eufy Security 4G LTE (T8151) if we use trigger alarm on this camera in logs we only see event alarm event but for other devices like Home Base 2 we also have a event property changed. This differences implicate the way how works eufy_security plugin for Home Assistant.

It will be nice if all devices will send the same events to standardise the way ho we communicate with our devices. More details you can find in related open PR eufy_security in https://github.com/fuatakgun/eufy_security/issues/690

To reproduce

Enable DEBUG mode in container and observer incoming event. Trigger alarm on camera Eufy Security 4G LTE and Home Base 2. In Eufy Security 4G LTE we don't have event property changed but in Home Base 2 they exist.

Screenshots & Logfiles

IN EUFY APP SET SECURITY TO "AWAY" STATE

THE ALARM HAS BEEN ARMED VIA MOBILE APP

2023-01-15 19:04:35.932 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8151P3022070514', 'guardMode': 0}}
2023-01-15 19:04:35.933 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8151P3022070514', 'name': 'guardMode', 'value': 0}}
2023-01-15 19:04:35.951 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8151P3022070514', 'currentMode': 0}}
2023-01-15 19:04:35.951 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8151P3022070514', 'name': 'currentMode', 'value': 0}}

THE ALARM HAS BEEN TRIGGERED

2023-01-15 19:05:45.614 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'alarm event', 'serialNumber': 'T8151P3022070514', 'alarmEvent': 7}}

DISABLE ALARM VIA MOBILE APP

2023-01-15 19:05:58.439 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8151P3022070514', 'guardMode': 63}}
2023-01-15 19:05:58.444 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8151P3022070514', 'name': 'guardMode', 'value': 63}}
2023-01-15 19:05:58.459 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8151P3022070514', 'currentMode': 63}}
2023-01-15 19:05:58.459 DEBUG (MainThread) [custom_components.eufy_security.eufy_security_api] _on_message - {'type': 'event', 'event': {'source': 'station', 'event': 'property changed', 'serialNumber': 'T8151P3022070514', 'name': 'currentMode', 'value': 63}}

Additional context

I am testing how the alarm is triggered by newly added devices, and I'm trying to add an automation that will inform me about this event. This works fine for some devices, but in my case it doesn't work for one type of device Eufy Security 4G LTE (T8151) .

BTW. I also noticed that all changes made in the eufy mobile application are well shown through the plugin. However, an attempt to set any other value via this app-on ends with information about not connecting to the device.

2023-01-15 19:22:14.349  WARN Station T8151P3022070514 - Tried all hosts, no connection could be established 
2023-01-15 19:22:14.350  INFO  Timeout connecting to station T8151P3022070514 
2023-01-15 19:32:15.699  WARN Station T8151P3022070143 - Tried all hosts, no connection could be established 
2023-01-15 19:32:15.701  INFO  Timeout connecting to station T8151P3022070143 
2023-01-15 19:32:34.057  WARN Station T8151P3022070514 - Tried all hosts, no connection could be established 
2023-01-15 19:32:34.059  INFO  Timeout connecting to station T8151P3022070514 
2023-01-15 19:42:35.551  WARN Station T8151P3022070143 - Tried all hosts, no connection could be established 
2023-01-15 19:42:35.568  INFO  Timeout connecting to station T8151P3022070143 
2023-01-15 19:42:52.574  WARN Station T8151P3022070514 - Tried all hosts, no connection could be established 
2023-01-15 19:42:52.575  INFO  Timeout connecting to station T8151P3022070514 
fuatakgun commented 1 year ago

Thanks, i will also share my logs here that is showing that both alarm and property changed events are happening at the same time

witold-gren commented 1 year ago

Hey @bropat finally I found small bugs in the code and my PR solve problem which I describe on this issue https://github.com/bropat/eufy-security-client/pull/333 Please check it and merge if you thing that it looks correct.. feel free to make corrections if you think something could be done better 😀

witold-gren commented 1 year ago

I think we can close this issue on this repository and open it in eufy-security-client repository.