bachya / eufy-security-ws-python

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

Home Assistant Integration #2

Closed bachya closed 2 years ago

bachya commented 3 years ago

Keeping track of what I need to do for a Home Assistant integration:

v1

v2 and Beyond

TBD

bachya commented 3 years ago

Guard mode sensor is coming along:

CleanShot 2021-07-12 at 12 22 11

The value updates almost instantly after changing it in the Eufy Security app, which is awesome. One thing that needs fixing is the state labels; I've followed the HA docs, but no matter what, my states show the raw label and not the human-friendly one (e.g., GEO instead of Geofencing).

FuzzyMistborn commented 3 years ago

Would using the new select entity work better here? https://www.home-assistant.io/blog/2021/07/07/release-20217/#new-entity-select

bachya commented 3 years ago

@FuzzyMistborn Interesting! Will look into it.

FuzzyMistborn commented 3 years ago

No problem. I currently use input_selects to control the state of the cameras so the select entity might just do the job (and get around your issue with human-friendly sensor states).

piitaya commented 3 years ago

Nice 😊
I planned to create this integration too but you did it before me! 100% agree with the select. But I think it can be better to use the alarm entity : https://developers.home-assistant.io/docs/core/entity/alarm-control-panel but only home, away, off can be mapped to the alarm control panel.

I have two eufy 2C (with home base 2) and one eufy indoor 2K if you need beta tester for the integration.

bachya commented 3 years ago

Preliminary work on using a select entity is very promising. Thanks for the heads up, @FuzzyMistborn!

But I think it can be better to use the alarm entity : https://developers.home-assistant.io/docs/core/entity/alarm-control-panel but only home, away, off can be mapped to the alarm control panel.

@piitaya I don't think an alarm_control_panel is appropriate for the Guard Mode (since, as you point out, there are several states that don't map to an alarm_control_panel). Furthermore, although the Guard Mode can trigger an alarm of sorts, it isn't, itself, technically an alarm.

I have two eufy 2C (with home base 2) and one eufy indoor 2K if you need beta tester for the integration.

Great! I will most definitely need testers.

piitaya commented 3 years ago

I agree, the guard mode is not an alarm mode so it can be mapped to the alarm panel mode.

Eufy Security Home Assistant
Away Away
Home Home
Disarmed Disarmed *
Off Disarmed *
Custom 1 Vacation **
Custom 2 Night **
Custom 3 ? **
Geo N/A
Schedule N/A

* I don't known the difference between off and disarmed mode. ** I can be integration parameters to map the custom mode to Home Assistant mode (In my case custom 1 is Night and custom 2 is Vacation).

The Geo and Schedule mode are special because it's just automations (with time and location) to switch between all the other modes.

Maybe we can find a mix using 2 entities :

But a select for all modes is the best solution for the V1. It's just a proposition for future developments 😊

bachya commented 3 years ago

@piitaya Got it. Thanks for the suggestion!

skank01 commented 3 years ago

Count me in for testing too. I have doorbell and cameras. Especially looking forward in casting the image of the doorbell cam after doorbell press :)

bachya commented 3 years ago

Alright, the select is fully working:

CleanShot 2021-07-13 at 16 32 19

I know we're excited to get to cameras/doorbells/etc., but I think this is a well-contained bit of functionality for the first PR. Going to start working on the Home Assistant OS add-on.

skank01 commented 3 years ago

Great work :) so quick thx in advance!

ronaldt80 commented 3 years ago

Happy to test this as well! Have 2 cams and a doorbell.

jonisnet commented 3 years ago

Besides i'm going away from home next week for 6 months, happy to test aswell. 1x Homebase 2x 2C cam 1x Doorbell (wired) 1x 2k Indoor

piitaya commented 3 years ago

Some feedback after days of real condition testing :

  1. When updating the guard mode in eufy app, the select is not always updated in home assistant :
    • Sometimes I have no update in home assistant (I have to restart home assistant to have the updated select option)
    • Sometimes the selected option home assistant is the previous guard mode in home assistant
  2. When updating the select in home assistant, the eufy app is not always updated (but in most cases it's updated). It's not updated when I have issues mentioned in 1.

I'm not sure it's an issue with eufy_security_ws_python or with the eufy_security component in home assistant.

You can see in this video, the sync issue (eufy app => home assistant) Note: I renamed the custom1 custom2 custom3 mode in the translation file to have to same names in home assistant and eufy app 😅

https://user-images.githubusercontent.com/5878303/126630737-d4cb81c5-b95c-4d28-a65f-ac77a646f672.mp4

Does anyone else has issues like that ?

skank01 commented 3 years ago

We are all waiting for the addon, there is not one yet

FuzzyMistborn commented 3 years ago

I'm assuming @piitaya is running the docker image of eufy-security and added the integration manually so he doesn't need the addon.

@piitaya I'd suggest opening up a separate issue.

bachya commented 3 years ago

@piitaya I'll need debug-level logs for home assistant.components.eufy_security and eufy_security_ws_Python to determine where the issue lies.

piitaya commented 3 years ago

The eufy_security_ws_python seems to receive the right events. I think it's an issue in home-assistant component (the way that home-assistant received the event and store it in the state). But I have no debug logs in the home assistant component 😞

EDIT : After some investigations, my eufy-security-ws containers was in latest version (0.3.2). I revert to 0.2.0 version et it works. There is 2 new schemas https://github.com/bropat/eufy-security-ws/blob/master/API_SCHEMA.md and eufy-security-ws-python only use version 1. Note : the version 3 add awesome event and command like : alarm trigger 🚀

A video with logs :

https://user-images.githubusercontent.com/5878303/126761936-4cae0bf5-6d1a-48e3-a1c4-ef3416c263b3.mp4

You can see that the 2 first changes works. in the video.

Raw logs :

home-assistant    | 2021-07-23 11:13:38 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63}}
home-assistant    | 2021-07-23 11:13:38 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63})
home-assistant    | 2021-07-23 11:13:38 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': 1627031618882}}
home-assistant    | 2021-07-23 11:13:38 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63}}
home-assistant    | 2021-07-23 11:13:38 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': 1627031618978}}
home-assistant    | 2021-07-23 11:13:42 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 3}}
home-assistant    | 2021-07-23 11:13:42 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 3})
home-assistant    | 2021-07-23 11:13:42 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': 1627031622806}}
home-assistant    | 2021-07-23 11:13:42 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 3}}
home-assistant    | 2021-07-23 11:13:42 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': 1627031622905}}
home-assistant    | 2021-07-23 11:13:47 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 1}}
home-assistant    | 2021-07-23 11:13:47 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 1})
home-assistant    | 2021-07-23 11:13:47 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': 1627031627382}}
home-assistant    | 2021-07-23 11:13:47 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1}}
home-assistant    | 2021-07-23 11:13:47 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': 1627031627481}}
home-assistant    | 2021-07-23 11:14:04 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63}}
home-assistant    | 2021-07-23 11:14:04 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63})
home-assistant    | 2021-07-23 11:14:04 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': 1627031644380}}
home-assistant    | 2021-07-23 11:14:04 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63}}
home-assistant    | 2021-07-23 11:14:04 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': 1627031644474}}
home-assistant    | 2021-07-23 11:14:30 INFO (MainThread) [homeassistant.components.upnp] Device not discovered
home-assistant    | 2021-07-23 11:14:30 INFO (MainThread) [homeassistant.components.upnp] Unable to create UPnP/IGD, aborting
home-assistant    | 2021-07-23 11:14:44 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 1}}
home-assistant    | 2021-07-23 11:14:44 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 1})
home-assistant    | 2021-07-23 11:14:44 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': 1627031684785}}
home-assistant    | 2021-07-23 11:14:44 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1}}
home-assistant    | 2021-07-23 11:14:44 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': 1627031684917}}
home-assistant    | 2021-07-23 11:14:49 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63}}
home-assistant    | 2021-07-23 11:14:49 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63})
home-assistant    | 2021-07-23 11:14:49 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': 1627031689606}}
home-assistant    | 2021-07-23 11:14:49 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63}}
home-assistant    | 2021-07-23 11:14:49 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': 1627031689698}}
home-assistant    | 2021-07-23 11:14:53 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 1}}
home-assistant    | 2021-07-23 11:14:53 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 1})
home-assistant    | 2021-07-23 11:14:53 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': 1627031693366}}
home-assistant    | 2021-07-23 11:14:53 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 1}}
home-assistant    | 2021-07-23 11:14:53 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': 1627031693460}}
home-assistant    | 2021-07-23 11:14:57 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 3}}
home-assistant    | 2021-07-23 11:14:57 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 3})
home-assistant    | 2021-07-23 11:14:57 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': 1627031697026}}
home-assistant    | 2021-07-23 11:14:57 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 3}}
home-assistant    | 2021-07-23 11:14:57 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': 1627031697125}}
home-assistant    | 2021-07-23 11:15:00 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63}}
home-assistant    | 2021-07-23 11:15:00 DEBUG (MainThread) [eufy_security_ws_python] Received unknown event: Event(type='current mode changed', data={'source': 'station', 'event': 'current mode changed', 'serialNumber': 'T8010N232053264F', 'currentMode': 63})
home-assistant    | 2021-07-23 11:15:00 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': 1627031700246}}
home-assistant    | 2021-07-23 11:15:00 DEBUG (MainThread) [eufy_security_ws_python] Received data from websocket server: {'type': 'event', 'event': {'source': 'station', 'event': 'guard mode changed', 'serialNumber': 'T8010N232053264F', 'guardMode': 63}}
home-assistant    | 2021-07-23 11:15:00 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': 1627031700357}}
bachya commented 3 years ago

I can't really tell from a video what's occurring. Does eufy_security_ws receive every event? It looked like there was at least one time were you change the mode and it wasn't all of the normal corresponding log messages. Additionally, what happens if you slow down a little bit – say, leave two or three seconds in between changing modes?

piitaya commented 3 years ago

Even if i slow down I have the issue. I didn't have it with the 0.2.0 version of eufy-security-ws. There is a lot a changes with the last version 0.3.2 (https://github.com/bropat/eufy-security-ws/compare/0.2.0...0.3.2)

bropat commented 3 years ago

@piitaya Try eufy-security-ws version 0.3.3 released a few seconds ago and let me know. ;)

piitaya commented 3 years ago

Thank for the update @bropat 🙂 I updated but I always have the same issue. I created an issue to avoid spam in this home assistant roadmap issue : https://github.com/bachya/eufy-security-ws-python/issues/4 I try to add some logs and debug my self but nothing convincing yet.

ds-sebastian commented 3 years ago

Excited for this! Great work so far 🙂

skank01 commented 3 years ago

@bachya how are things going here?

cvaz79 commented 3 years ago

He must be on his well deserved holly-days. I'm also anxious for this Home Assistant Integration.

bachya commented 2 years ago

Hi all! Thanks for your patience. I've been going through a series of heavy items (both work and personal) that have required my attention. All that said, I have not forgotten this and hope to have some time to continue on this soon.

skank01 commented 2 years ago

Welcome back Bachya ! All understanding and respect here ! Still looking forward !

Daneish commented 2 years ago

Thanks for the update Bachya, and thank you for all of your work on the project! I hope things lighten for you soon. Take the time that you need to look after yourself mate.

cvaz79 commented 2 years ago

Thanks a lot Bachya, looking forward to this integration.

skank01 commented 2 years ago

Hi all! Thanks for your patience. I've been going through a series of heavy items (both work and personal) that have required my attention. All that said, I have not forgotten this and hope to have some time to continue on this soon.

@bachya let us hope too :)

cvaz79 commented 2 years ago

Hi everyone, is there any news on this topic?

skank01 commented 2 years ago

@bachya, this project is dead?

eikowagenknecht commented 2 years ago

Wouldn't it make sense to combine efforts with @fuatakgun? His integration has come a long way since this post https://community.home-assistant.io/t/eufy-security-integration/318353 and is working quite well generally.

bachya commented 2 years ago

Hi all. Unfortunately, I'm going to need to put this project aside – too many other things, both personal and professional, have come up and I'm not able to give it the attention it deserves. Per @eikowagenknecht's comment above, it sounds like there's another project that is being actively worked on, so I recommend everybody take a look at that.

Thanks for understanding.