fuatakgun / eufy_security

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

Home Assistant - Switch cam on off #61

Closed SmartM-ui closed 3 years ago

SmartM-ui commented 3 years ago

Hi @fuatakgun would it be possible to integrate the switch to turn the cam on and off? In the original app, the switch, is called "Camera on" useful for privacy when you are at home. I would like to use the switch to activate the automations in the home assistant. Thanks

fuatakgun commented 3 years ago

Hey, enable and disable services should be enough for you.

SmartM-ui commented 3 years ago

Hey, enable and disable services should be enough for you.

Hi @fuatakgun Thanks for the advice, i tried and the service works. It manages to turn the cam on and off. I created a switch, place the code if it can be of help to anyone:

switch:
  - platform: template
    switches:
      eufy_on_off:
        turn_on:
          service: eufy_security.enable
          data: {}
          target:
            entity_id: camera.xxx
        turn_off:
          service: eufy_security.disable
          data: {}
          target:
            entity_id: camera.xxx

I have another request regarding the on / off status of the cam.

Is a sensor or attribute already available to understand if the cam is actually on or off?

Thanks

fuatakgun commented 3 years ago

There is a sensor called enabled which should give you the state

SmartM-ui commented 3 years ago

There is a sensor called enabled which should give you the state

I had seen that sensor, but it doesn't seem to be associated with the actual state of the camera. When I turn the cam on or off from the original app, the status doesn't change. It only changes when I launch the service eufy_security.disable or enable from home assistant

SmartM-ui commented 3 years ago

There is a sensor called enabled which should give you the state

Hi @fuatakgun I noticed that the on off status updates in real time only if I change security from the original app (e.g. from home to away from home) or via the alarm control panel service in home assistant

fuatakgun commented 3 years ago

That is an overall drawback of the integration. There is a state in eufy cloud and there is an internal cache in eufy add on(almost behaving as mobile app). Eufy cloud is not informing through push notifications to eufy add on but there is a polling interval of 10 minutes to get latesf information.

i believe, you should have the similar behavior other way around, disable the camera from home assistant while your mobile app is open and see if it will ot updated immediately.

i can create a new service to fetch latest updates from cloud but you need to call it yourself, i do not want to make angry Eufy while calling their endpoints :-)

SmartM-ui commented 3 years ago

That is an overall drawback of the integration. There is a state in eufy cloud and there is an internal cache in eufy add on(almost behaving as mobile app). Eufy cloud is not informing through push notifications to eufy add on but there is a polling interval of 10 minutes to get latesf information.

i believe, you should have the similar behavior other way around, disable the camera from home assistant while your mobile app is open and see if it will ot updated immediately.

i can create a new service to fetch latest updates from cloud but you need to call it yourself, i do not want to make angry Eufy while calling their endpoints :-)

Hi, I was doing some tests, because I had seen that after a certain amount of time the status on the home assistant changed. So there is 10 minutes to wait to see the update on Home Assistant. I had also tried to see how it works by sending the service from Home Assistant and in fact to immediately show the change on the official app, I had to close and reopen the app on the smartphone. Could you create or show me how to get the new service? If anything, it could be automatically recalled only when the home assistant page containing information on the status of the cam is displayed ... it could be an idea to not make Eufy angry :-)

fuatakgun commented 3 years ago

I would only be able to come up with a service but it is up to you how to use it :)

can you move your latest discussion into a new issue for the sake of completeness and resolve this?

SmartM-ui commented 3 years ago

OK, I'll proceed to open the new request.