Eufy Security Integration

Following on from my above post, here are the steps to take to achieve this setup.

  1. Install and configure WebRTC via HACS: https://github.com/AlexxIT/WebRTC

  2. Install and configure Browser Mod via HACS: https://github.com/thomasloven/hass-browser_mod

  3. Create this script:

alias: Eufy Doorbell Start Livestream
sequence:
  - service: eufy_security.start_livestream
    target:
      entity_id:
        - camera.YOUR-CAMERA-NAME
      device_id: YOUR-DOORBELL-DEVICE-ID
  - service: browser_mod.window_reload
mode: single
  1. Create this script:
alias: Eufy camera OFF
sequence:
  - service: eufy_security.stop_livestream
    target:
      entity_id: camera.YOUR-CAMERA-NAME
      device_id:
        - YOUR-DOORBELL-DEVICE-ID
  - service: homeassistant.reload_config_entry
    target:
      entity_id: camera.YOUR-CAMERA-NAME
      device_id:
        - YOUR-DOORBELL-DEVICE-ID
mode: single
icon: mdi:video-off
  1. Create this automation:
alias: Eufy - Stop doorbell stream after 2.50 min
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.doorbell_streaming_sensor
    to: 'True'
    from: 'False'
condition: []
action:
  - delay:
      hours: 0
      minutes: 2
      seconds: 50
      milliseconds: 0
  - service: script.THE_SCRIPT-ID-FOR-Eufy camera OFF script from step 4
mode: restart
  1. Create this card for ‘last event’ image:
type: conditional
conditions:
  - entity: binary_sensor.doorbell_streaming_sensor
    state: 'False'
card:
  type: picture-glance
  entities: []
  camera_image: camera.YOUR-CAMERA-NAME
  tap_action:
    action: call-service
    service: script.eufy_doorbell_start_livestream
    service_data: {}
    target: {}
  1. Create this card for the ‘live stream’ WebRTC card:
type: conditional
conditions:
  - entity: binary_sensor.doorbell_streaming_sensor
    state: 'True'
card:
  type: custom:webrtc-camera
  entity: camera.doorbell
  mse: false


  1. Create this card for the “STOP CAMERA” button (not required but can be useful to have ability to stop the livestream via UI):

type: conditional
conditions:
  - entity: binary_sensor.doorbell_streaming_sensor
    state: 'True'
card:
  type: button
  tap_action:
    action: call-service
    service: script.THE_SCRIPT-ID-FOR-Eufy camera OFF script from step 4
    service_data: {}
    target: {}
  icon: mdi:doorbell
  show_state: false
  show_name: true
  icon_height: 50px
  name: STOP CAMERA

Ps. If there are any issues I usually find restarting the bropat docker container fixes things.

Also, you may not require to call the `stop_livestream’ service as @anon63427907 has pointed out that the integration automatically calls this when no incoming bytes received. However I do find that I need the service ‘homeassistant.reload_config_entry’ to get everything working perfectly.

5 Likes

Hi
I’m experiencing the same things as you do !
I also need to stop it manually

  • i also use browser_mod :slight_smile:
    So we probably have almost 100% the same situation :slight_smile:

Are you willing to share ALL your scripts and dashboard setup (conditional carsds?)

However still have a question concerning step 6 and 7
Why you make separate script for 6, why dont you include it in the script from step 3 ?
After x time (or maybe after 2.5 min so step 8 isnt necessary) , or maybe after you close the popup from browser_mod ?

Thx for the headsup !

Lovely ! thx
Will try it asap.
step 3 & 4 you target the entity_id AND the device_id
No need for that, you can get rid of the device_id i think (less code lines)

entity id is enough, device id is usually some scrambled values, not readable.

@conorlap
I will probably adjust your scripts to be able to be used by rtsp cameras too.
So the scripts will have a choice (if p2p doorbell then do this) or choose rtsp cam then do this
So we dont need 4 scripts and 2 automations but only 2 and 1

Amazing, thanks!
My doorbell has a state in the format of “Idle - 71 %” though. I guess maybe new with an update? Might need to template, or maybe make “state not”.

I will post my code here too, for those who need it with choose action
(so for p2p AND rtsp)
Edit:

Step 3 and 4 (2 scripts to start/stop with choose)

start_stream:
  alias: Eufy start stream
  icon: "mdi:cctv"
  mode: single
  sequence:
    - choose:
        - conditions:
            - condition: state
              entity_id: binary_sensor.deurbel_streaming_sensor
              state: 'False'
          sequence:
            - service: eufy_security.start_livestream
              target:
                entity_id: camera.deurbel
            - service: browser_mod.window_reload
        - conditions:
            - condition: state
              entity_id: binary_sensor.tuin_streaming_sensor
              state: 'False'
          sequence:
            - service: eufy_security.start_rtsp
              target:
                entity_id: camera.tuin
            - service: browser_mod.window_reload  
            
stop_stream:
  alias: Eufy stop stream
  icon: "mdi:cctv-off"
  mode: single
  sequence:            
    - choose:
        - conditions:
            - condition: state
              entity_id: binary_sensor.deurbel_streaming_sensor
              state: 'True'
          sequence:    
            - service: eufy_security.stop_livestream
              target:
                entity_id: camera.deurbel
            - service: homeassistant.reload_config_entry
              entity_id: camera.deurbel
        - conditions:
            - condition: state
              entity_id: binary_sensor.tuin_streaming_sensor
              state: 'True'   
          sequence:    
            - service: eufy_security.stop_rtsp
              target:
                entity_id: camera.tuin
            - service: homeassistant.reload_config_entry
              entity_id: camera.tuin

Do change the name of the cams , here i used “deurbel” and “tuin” , but change it to your names
@conorlap why dont you make use of the binary streaming sensor in your scripts and dashboard? its new and very useful ! Will adjust mine :stuck_out_tongue:

2 Likes

Mine and his too
Use the new binary streaming sensor for that !
Dont use state not

2 Likes

yes, instead of relying state of camera ‘which is a friendly state for user`’ rely on new binary sensor. example was published here: https://github.com/fuatakgun/eufy_security/blob/master/README.md#63-optional---webrtc

2 Likes

I’ve edited my code above to use the new binary streaming sensor :slight_smile:

Regarding using device ID also, I just found it worked in my testing so I added it and the entity.

@skank I didn’t add RTSP as my doorbell doesn’t support this but useful info for others! :wink:

Why you make separate script for 6, why dont you include it in the script from step 3 ?
After x time (or maybe after 2.5 min so step 8 isnt necessary) , or maybe after you close the popup from browser_mod ?

@skank Step 6 calls the script from Step 3. I chose to have the automation seperate for more granular control / to test if I can turn it off if I don’t need it etc. Not sure which popup you’re talking about, I don’t get any pop ups from browser_mod.

1 Like

Ok clear.
The popup is the more info box
Actually in my main dashboard i have a button “security”
When i tap it, a popup comes up with all my cameras and motion detecters.
So there i have the conditional cards

You can do pretty amazing stuff with browser mod !
But thats too offtopic here
Pm me if u want to know more

I’m still tweaking the scripts and conditional cards here

Edit: @conorlap, i’m seeing strange things with the browser mod reload and config entry reload, so i’m withdrawing that from your script, then theres nothing left to start the script, so i can use the config from fuatakgun to start.
To stop i do have a script and button


Still tweaking, coming back here with final results

Whats the purpos of the msr: true and background false addition to the webrtc cam? When i look at github, the background is false always so no need to add, the mse i dont quite understand

2 Likes

MSE is specific technology to enable remote streaming, in case your router fails to stream webrtc remotely and it is used as fallback mechanism when webrtc would fail. more here: https://github.com/AlexxIT/WebRTC#webrtc-external-access

But it automatically uses it, so why add as “yes”
i think doing harme there it will always use it

is it on by default? not sure, but if it is on by default, you can definitely remove it.

Yes
I got rid of it

Anyway, retesting stuff
Still i get sometimes eufy is not doing what i ask

I was trying to STOP the rtsp camera
with the command eufy_security.stop_rtsp

But to be sure, i stopped eufy addon and rtsp addon
restarte both
then trying to stop it, but still it keeps playing
when i look at binary sensor streaming it says TRUE
and i cant stop it using the command
(not always like that)

Yeah it’s actually probably best to set mse to false. For me it caused delay when mse was left enabled because it would initially load the live stream via mse and then tranfer to WebRTC after a second. Causing glitches/delay for the first 1-3 seconds of the livestream starting.
I’ve edited my code above.

I’m experiencing this now too, I thought this issue was gone because everything worked great earlier today but now it’s auto restarting the livestream sometimes and I cannot stop using the command.

Yeah have the same thing too

ITs not stable lol

Yeah unfortunately not, I had great success for approx 1 hour with no issues this morning and thought it was all good!

Yeah thatswhy i didnt add any extra eufy cams and still doubting to throw it all overboard including doorbell and even going to google cams and doorbell or smth

Eufy should pay fuatakgun and bropat for all their effort into this though

But still it remains unstable, and im beginning to think, its not cause of fuatakgun and bropat their programming skills, but it might be that the cause there is eufy itself

1 Like