Add WebRTC & Home Assistant conditional card tips to README.md
conorlap opened this issue ยท 28 comments
Just some potentially useful set-up info for people using @fuatakgun & @bropat 's integration/docker container.
You can get the doorbell live stream down to about 2-4 second delay using WebRTC to display the RTSP camera feed using this integration: https://github.com/AlexxIT/WebRTC
The lovelace card:
You can add the additional command mse: false because quite often it loads the MSE stream then stutters for another second before loading WebRTC but your results may vary:
type: custom:webrtc-camera
entity: camera.doorbell
mse: false
You can utilize the lovelace conditional card so the WebRTC feed only displays on the dashboard when the camera is actually streaming, example:
type: conditional
conditions:
- entity: camera.doorbell
state: Streaming - p2p
card:
type: custom:webrtc-camera
entity: camera.doorbell
mse: false
For cleanest set-up, you can create another lovelace card which displays the last event detected by the doorbell. This is also a conditional card and this only displays when the camera is NOT streaming video. To activate video, simply click on the picture which triggers script.eufy_doorbell_rtsp_reload that you can create that calls the eufy_security.stop_livestream & eufy_security.start_livestream service. Examples below:
Conditional card with script call:
type: conditional
conditions:
- entity: camera.doorbell
state: Idle
card:
type: picture-glance
entities: []
camera_image: camera.doorbell
tap_action:
action: call-service
service: script.eufy_doorbell_rtsp_reload
service_data: {}
target: {}
Livestream Reload Script:
alias: Eufy Doorbell RTSP Reload
sequence:
- service: eufy_security.stop_livestream
target:
entity_id: camera.doorbell
- service: eufy_security.start_livestream
target:
entity_id:
- camera.doorbell
mode: single
Nice. I remember I've tried that integration before and ran into issues, not streaming anything, even from their example on their repo. Maybe I'll have to come back to it and give it another go.
Maybe you have WebRTC leak protection enabled on your browser? I had WebRTC Control extension on my browser and had to stop it to allow WebRTC to work.
Nice. I remember I've tried that integration before and ran into issues, not streaming anything, even from their example on their repo. Maybe I'll have to come back to it and give it another go.
I had the same experience, I will give it a try on WebRTC Control extension.
This is cool. Had to change the latter card to following due to there being the battery percentage after Idle in the state for me. However, I'm apparently still having some issues with the video working, but I'll comment on the other thread since it's not related to this one. Will try to remember to report here when I get that working if the delay is better for me by using WebRTC.
type: conditional
conditions:
- entity: camera.doorbell
state_not: Streaming - p2p
card:
type: picture-glance
entities: []
camera_image: camera.doorbell
tap_action:
action: call-service
service: script.eufy_reload
service_data: {}
target: {}
I can report that I finally have this working for my wireless doorbell. After giving up I decided to check it out again as I have other cameras that need a good rtsp player. Once I added the HACS integration I needed to also add it to the home assistant integrations. facepalm. So my setup is like this. I needed a button system for my wife to easily turn on and off the camera, and then using the conditional card you wrote ( great idea! ) to display the feed. I also have an automation that kills the feed after 2:50 minutes of runtime so it doesn't destroy the battery life.
type: horizontal-stack
cards:
- type: button
tap_action:
action: call-service
service: eufy_security.start_livestream
service_data: {}
target:
device_id: XXX
name: Stream Doorbell
icon_height: 100px
icon: mdi:video
entity: camera.doorbell
show_state: true
- type: button
tap_action:
action: call-service
service: eufy_security.stop_livestream
service_data: {}
target:
device_id: XXX
name: Stop Doorbell
icon_height: 100px
icon: mdi:video-outline
To add to this, I found a nice gallery frontend for showing videos in a clean format. I don't have it for my eufy doorbell yet but this looks better than the media browser.
Can someone please explain if this webrtc is now the way to go?
I'm using the rtsp addon (which should be faster than p2p) , im still having lots of delay before it starts.
Is this webrtc now another way than this rtsp addon, or are they compliant, i dont really understand.
All i want is as less delay as possible.
@fuatakgun you know more about it?
Okay so since you have RTSP already setup, all you need to do now is install the WebRTC integration to Home Assistant (details here: https://github.com/AlexxIT/WebRTC) then once it's installed you simply create a custom card that calls your existing RTSP camera entity. For example:
type: custom:webrtc-camera
entity: camera.doorbell
mse: false
I failed to run webrtc on my setup, I am sticking with p2p and rtsp.
Okay so since you have RTSP already setup, all you need to do now is install the WebRTC integration to Home Assistant (details here: https://github.com/AlexxIT/WebRTC) then once it's installed you simply create a custom card that calls your existing RTSP camera entity. For example:
type: custom:webrtc-camera entity: camera.doorbell mse: false
i'm getting a custom elements doesnt exist, although i installed it through hacs and rebooted, even cleared my cache
@skank01 - did you add the webrtc-camera.js to your lovelace dashboards resources?
This is under Configuration > Lovelace Dashboards > Resources
Mine is as follows:
URL:
/www/community/webrtc/webrtc-camera.js
Resource Type:
JavaScript Module
Example image: https://imgur.com/a/evA0uog
The gotcha that had me was you had to add it through HACS, and then add it again in the integration page.
The gotcha that had me was you had to add it through HACS, and then add it again in the integration page.
That did the trick indeed, i didnt know i had to add it twice via integrations
once integration in hacs
and then once again integration in HA settings
The camera is working here, i'm gonna see now to add the conditional card and the reload script
Strange @fuatakgun it didnt work with you
EDIT: i know see the facepalm of @dpomnean his post, stupid of me
Ok i'm having troubles
USing the conditional card, i also had troubles cause over here, i have the battery % next to idle too
So i have to use "state_not"
This is how my code looks like for the card & script
Card:
[code]
type: conditional
conditions:
- entity: camera.tuin
state_not: Streaming - rtsp
card:
type: picture-glance
title: Tuin
entities: []
camera_image: camera.tuin
tap_action:
action: call-service
service: script.eufy_tuin_rtsp_reload
service_data: {}
target: {}
[/code]
script:
[code]
alias: Eufy Tuin RTSP Reload
sequence:
- service: eufy_security.stop_rtsp
target:
entity_id: camera.tuin
- service: eufy_security.start_rtsp
target:
entity_id:
- camera.tuin
mode: single
[/code]
Running in 2 troubles:
- Somehow using the conditional card, and in fact also the custom:webrtc-camera card
It auto starts the camera play rtsp automatically.. Theres also an icon showing its autoconnecting !!
So when using the conditional card (if i stopped the service seconds before) i do see the last picture, but it immediately dissappears cause its trying to play already (and so its not idle anymore) - why do i need to stop the rtsp first before trying to play? it should stop AFTER it played
When you see webrtc widget, it tries to enable camera automatically (initiating stream).
Dis you try state with percentage? Any issue with quotes?
When you see webrtc widget, it tries to enable camera automatically (initiating stream).
Dis you try state with percentage? Any issue with quotes?
Yes indeed, it tries to play automatically, i dont want that , cause theres no use in using the conditional to show the last event detected if it immediately goes away
I didnt try state with percentage, cause i dont know how to do that cause the % changes everytime
@conorlap is it possible to help me here? OR maybe can you show a video where you see the conditional card in action, before you tap, and then after you tap, and after playing has stopped, i want to see how it works at ur place
@skank01
I've been experiencing the same issues, I think the autoplay thing started happening after updating to @bropat /eufy-security-ws version 0.4.2.
Prior to 0.4.2 it functioned as desired:
- It would display the 'last event' image
- click on the image to trigger start livestream - the live stream feed would show
- Once livestream was stopped the WebRTC card would disappear and the 'last event' image would return.
so, there should be a better state mechanism rather than writing battery and stream source into state.
It could be as below, without any battery and RTSP/P2P information
- Idle
- Streaming
- Motion Detected
- Person Detected
@skank01
I've been experiencing the same issues, I think the autoplay thing started happening after updating to @bropat /eufy-security-ws version 0.4.2.Prior to 0.4.2 it functioned as desired:
- It would display the 'last event' image
- click on the image to trigger start livestream - the live stream feed would show
- Once livestream was stopped the WebRTC card would disappear and the 'last event' image would return.
Hi,
So, how do you solve it? Cause now, it disturbs the working..
I can confirm as @fuatakgun mentions , it's still on 0.3.3.
Maybe its time to use the latest? We would probably benefit from other stuff as well?
For me , to watch the live view, its still not good enough (takes too long to load, or using webrtc, its useless)
I didn't solve it yet - but I downgraded to bropat/eufy-security-ws:0.3.3 and it seems to work slightly better. It's still autoplaying but doesn't crash my HA instance now.
Unfortunately this setup is not all that great for livestreaming still, hopefully it can be improved!
I'm gonna disable webrtc again, until its fixed it doesnt autoplay, cause its worse than the normal integration from fuatakgun
I cant even check if its loading faster (i dont get that idea yet)
I do hope though that loading the stream will get faster, cause its just not good enough here.
I have hopes for the official integration from bachya, but still, thats doesnt go forward anymore
(all respect though)
Having this integration officially would improve code quality, but there is no way to improve latency because integration is just mirroring incoming data from add-on. I had discussed the possibility of increasing speed of streaming with add on owner, but we could not find one.
What is the latency for you now while using p2p over rtsp add on?
To be honest, right now, nothing is working good
I'm deleting everything from webrtc
Cams still take 30 seconds to load
But stopping streams isnt responding anymore...
I'm honestly getting fed up with eufy stuff.
No google home integration at all yet (not blaming you)
I'm not sure what i will do
back to here, I was able to setup webrtc locally and while latency is very small, initial startup latency is still there.
I will create a new sensor about streaming status and update readme file about installation on WEBRTC and conditinal card.
Thanks @conorlap for this super idea.
Backgound: apparently streaming is slow, because of internal stream
implementation of home assistant, not because of integration or add-on. integration can still speed up initial launch time, which I will focus but not stream itself. Moreover, I have seen many threads about how stream
integration might end up consuming memory etc, my own installation reboots once or twice in a day and I suspect stream
is the root cause.
@fuatakgun doenst it autostart stream with you?
ongoing solution on this;
- setup separate sensors for streaming state of camera as
is_streaming
(true/false) ,streaming_source_type
(p2p/rtsp),streaming_source_address
(URL for RTSP server add on or home base station if supports native RTSP) - if
is_streaming
is TRUE, show webrtc, if false, show camera entity to see the last event photo - set a new configuration option to control auto start functionality, as it might automatically trigger stream start event and we want to avoid it.
readme is updated according to latest changes.