fuatakgun / eufy_security

Home Assistant integration to manage Eufy Security devices as cameras, home base stations, doorbells, motion and contact sensors.
877 stars 73 forks source link

Disarmed/off state on Homebase vs. home assistant. #45

Closed r2xud closed 2 years ago

r2xud commented 3 years ago

This way when using the keypad to disarm the alarm, home assistant does not replicate it's state and will still read as armed.

The home assistant alarmpanel should also switch the Eufy homebase to the "OFF" state instead of the "DISARMED" state to make sure the alarm state on the Eufy homebase, the Eufy keypad and in home assistant read the same.

fuatakgun commented 3 years ago

Can you share a screenshot from eufy app? I do not have Off state, i have only 5 predefined guard modes ( i don't have a keypad);

Screenshot_2021-08-14-17-05-10-121_com.oceanwing.battery.cam.jpg

r2xud commented 3 years ago

It's probably the keypad that adds the "OFF" state and switches to it when using the keypad to disarm.

The screenshot is in Dutch.

Uitgeschakeld = Disarmed Uit = Off

Screenshot_20210814-170838_EufySecurity

fuatakgun commented 3 years ago

Please click on settings icon on Off mode to show details. Is there any delete button at the end of page? If yes, this is just a custom mode you can create but you need to call it over integration services.

fuatakgun commented 3 years ago

Screenshot_2021-08-14-17-34-41-254_com.oceanwing.battery.cam.jpgScreenshot_2021-08-14-17-34-34-833_com.oceanwing.battery.cam.jpg

r2xud commented 3 years ago

It's not a custom mode. Adding the keypad creates this mode.

Screenshot_20210814-175159_EufySecurity

r2xud commented 3 years ago

From the user manual:

162895690285685104030074810797

fuatakgun commented 3 years ago

I see, i remember this was recently added to add on here, just 3 days ago; https://github.com/bropat/eufy-security-client/issues/27

New release will be published and i need to test it for integration.

On the other hand, i don't think enabling off mode everyone would make sense, we need to find a common solution for all here. In alarm panel, there are only 3 states.

https://github.com/bropat/eufy-security-client/issues/27

r2xud commented 3 years ago

Did not see Issue #27. Sorry for that. Yes, finding a common solution for all would be best.

I'll wait for the new release. Thanks for the great work you do! :)

fuatakgun commented 3 years ago

Welcome, let's keep this open, I am still not clear what should be the solution for all Integration users. If you check here (https://www.home-assistant.io/integrations/manual), there are 4 states in home assistant alarm control panel;

I have implemented first three of them in integration. The other states as schedule and geocode are actually not state but rules sets to change the state, so I am not worried about them.

But, I am not sure where and how we should place off in this mapping.

fuatakgun commented 3 years ago

One possible solution; whenever keypad is used to deactivate alarm, we can assume off is equal to disarmed, is this a correct assumption? So, if you use integration, it will switch to disarmed but if you use keypad, it will switch to off. Both cases will be visible to you as disarmed in the integration. What do you think?

r2xud commented 3 years ago

I agree. That seems like a possible solution. The Off state can be seen as equal to the disarmed state in my opinion.

domemshur commented 3 years ago

When I do this intergration, nothing gets created or populates in home assistant for my eufy alarm station. My Motion sensors show up, but not my keypad.

Thanks

fuatakgun commented 2 years ago

@domemshur , what is alarm station? is it home base or something different? If this is a different device, please create a separate issue to support it.

On keypad, it is an interface to eufy, not an actual device to be represented in home assistant. At least, that is my perception, happy to discuss more on this. I will focus on mapping OFF state to DISARMED in home assistant.

fuatakgun commented 2 years ago

@r2xud , please help me following these steps;

r2xud commented 2 years ago

The problem is that the intergration will not load when i restart home assistant while the state is switched to "Off".

I get the following error msg:

Logger: custom_components.eufy_security
Source: custom_components/eufy_security/websocket.py:69
Integration: Eufy Security (documentation, issues)
First occurred: 21:31:16 (2 occurrences)
Last logged: 21:31:16

eufy_security - Exception - process_messages: 6 - traceback: Traceback (most recent call last): File "/config/custom_components/eufy_security/websocket.py", line 67, in process_messages await self.on_message(msg) File "/config/custom_components/eufy_security/websocket.py", line 83, in on_message await self.message_callback(message) File "/config/custom_components/eufy_security/coordinator.py", line 184, in on_message self.async_set_updated_data(self.data) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 287, in async_set_updated_data update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state state = self.state File "/config/custom_components/eufy_security/alarm_control_panel.py", line 128, in state return CODES_TO_STATES[current_mode] KeyError: 6 - message: WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"source":"station","event":"property changed","serialNumber":"XXXXXXXXXXXXXXXX","name":"currentMode","value":6,"timestamp":1631993476404}}', extra='')
eufy_security - Exception - process_messages: 6 - traceback: Traceback (most recent call last): File "/config/custom_components/eufy_security/websocket.py", line 67, in process_messages await self.on_message(msg) File "/config/custom_components/eufy_security/websocket.py", line 83, in on_message await self.message_callback(message) File "/config/custom_components/eufy_security/coordinator.py", line 184, in on_message self.async_set_updated_data(self.data) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 287, in async_set_updated_data update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state state = self.state File "/config/custom_components/eufy_security/alarm_control_panel.py", line 128, in state return CODES_TO_STATES[current_mode] KeyError: 6 - message: WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"source":"station","event":"property changed","serialNumber":"XXXXXXXXXXXXXXXX","name":"guardMode","value":6,"timestamp":1631993476635}}', extra='')
fuatakgun commented 2 years ago

this is good enough for me to investigate :)

On Sat, 18 Sept 2021 at 21:36, r2xud @.***> wrote:

The problem is that the intergration will not load when i restart home assistant while the state is switched to "Off".

I get the following error msg:

`Logger: custom_components.eufy_security Source: custom_components/eufy_security/websocket.py:69 Integration: Eufy Security (documentation, issues) First occurred: 21:31:16 (2 occurrences) Last logged: 21:31:16

eufy_security - Exception - process_messages: 6 - traceback: Traceback (most recent call last): File "/config/custom_components/eufy_security/websocket.py", line 67, in process_messages await self.on_message(msg) File "/config/custom_components/eufy_security/websocket.py", line 83, in on_message await self.message_callback(message) File "/config/custom_components/eufy_security/coordinator.py", line 184, in on_message self.async_set_updated_data(self.data) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 287, in async_set_updated_data update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state state = self.state File "/config/custom_components/eufy_security/alarm_control_panel.py", line 128, in state return CODES_TO_STATES[current_mode] KeyError: 6 - message: WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"source":"station","event":"property changed","serialNumber":"XXXXXXXXXXXXXXXX","name":"currentMode","value":6,"timestamp":1631993476404}}', extra='') eufy_security - Exception - process_messages: 6 - traceback: Traceback (most recent call last): File "/config/custom_components/eufy_security/websocket.py", line 67, in process_messages await self.on_message(msg) File "/config/custom_components/eufy_security/websocket.py", line 83, in on_message await self.message_callback(message) File "/config/custom_components/eufy_security/coordinator.py", line 184, in on_message self.async_set_updated_data(self.data) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 287, in async_set_updated_data update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state state = self.state File "/config/custom_components/eufy_security/alarm_control_panel.py", line 128, in state return CODES_TO_STATES[current_mode] KeyError: 6 - message: WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"source":"station","event":"property changed","serialNumber":"XXXXXXXXXXXXXXXX","name":"guardMode","value":6,"timestamp":1631993476635}}', extra='')`

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/fuatakgun/eufy_security/issues/45#issuecomment-922362145, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUSN7XUZNCKBRQ2WZGQHB3UCTS2VANCNFSM5CFFN35A .

fuatakgun commented 2 years ago

please get latest version and test, feel free to resolve later on.

r2xud commented 2 years ago

I installed version 0.4.2. now i can see the door sensors and the keypad in the intergration panel but when rebooting i get the following error msg:

Logger: homeassistant.components.alarm_control_panel
Source: custom_components/eufy_security/alarm_control_panel.py:128
Integration: Alarm bedieningspaneel (documentation, issues)
First occurred: 11:45:37 (2 occurrences)
Last logged: 11:45:37

Error adding entities for domain alarm_control_panel with platform eufy_security
Error while setting up eufy_security platform for alarm_control_panel
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 587, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 698, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state
    state = self._stringify_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state
    state = self.state
  File "/config/custom_components/eufy_security/alarm_control_panel.py", line 128, in state
    return CODES_TO_STATES[current_mode]
KeyError: 6
fuatakgun commented 2 years ago

Please do not install 0.4.2, just update the integration.

Add on is not ready to upgrade, there are some issues. If you upgrade and find some issues (given that you are on the latest version of the integration), you can add new issues here: https://github.com/fuatakgun/eufy_security/issues/59

On Mon, 20 Sept 2021 at 11:52, r2xud @.***> wrote:

I installed version 0.4.2. now i can see the door sensors and the keypad in the intergration panel but when rebooting i get the following error msg:

Logger: homeassistant.components.alarm_control_panel Source: custom_components/eufy_security/alarm_control_panel.py:128 Integration: Alarm bedieningspaneel (documentation, issues) First occurred: 11:45:37 (2 occurrences) Last logged: 11:45:37

Error adding entities for domain alarm_control_panel with platform eufy_security Error while setting up eufy_security platform for alarm_control_panel Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 587, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 698, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state state = self.state File "/config/custom_components/eufy_security/alarm_control_panel.py", line 128, in state return CODES_TO_STATES[current_mode] KeyError: 6

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/fuatakgun/eufy_security/issues/45#issuecomment-922778530, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUSN7RQOXLBHPFZ4IOL7U3UC3743ANCNFSM5CFFN35A .

r2xud commented 2 years ago

Alright. I do not see the latest version of the integration. How do i install it?

fuatakgun commented 2 years ago

you should see an update notification in HACS like this image

r2xud commented 2 years ago

Yes that is what i was looking for. There is no update available.

fuatakgun commented 2 years ago

did you update recently? I had changed the library 16 hours ago.

r2xud commented 2 years ago

No i did not as far as i know. Is there a way to check what version i am running?

In the repo i see that the last edited file is the README.md 3 days ago. I do not see the change from 16 hours ago.

download

fuatakgun commented 2 years ago

I am getting old, updated the repo just now, please try and share the results.

r2xud commented 2 years ago

Thanks for the great work you do.

I just installed the update. I will test tonight and let you know the results.

r2xud commented 2 years ago

I'm now able to arm_home, arm_away and disarm the alarm using the home assistant alarm panel. When disarming the state one the homebase switches to Disarmed so it does not show on the keypad. But that was to be expected since not everyone has a keypad.

Thanks for the great work! I think it's resolved.