Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to not have WebRTC in the home assistant web dashboard permanently block the machine sleeping / screen turning off? #613

Open
AdrianGarside opened this issue Nov 26, 2023 · 8 comments
Labels
question Further information is requested

Comments

@AdrianGarside
Copy link

AdrianGarside commented Nov 26, 2023

However, that permanently blocks my machine sleeping or the screen turning off when I view the dashboard, even if I then navigate away. I have to ctrl-F5 to release the lock:

'powercfg /requests' shows:

EXECUTION:
[PROCESS] \Device\HarddiskVolume3\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
WebRTC has active PeerConnections

I have background: true set to get the much more responsive display and to mitigate reliability issues with the Bambu Lab X1 RTSP feed but removing that doesn't appear to change the behavior.

Repro:

  1. View WebRTC in HA dashboard in Edge
  2. Run (elevated) 'powercfg /requests' to see the lock taken.
  3. Navigate way
  4. Run (elevated) 'powercfg /requests' to see the lock is still taken.
  5. F5 to refresh the web page.
  6. Now the lock is gone.
@AdrianGarside AdrianGarside changed the title Is there a way to not have WebRTC background display in home assistant web permanently block the machine sleeping / screen turning off? Is there a way to not have WebRTC in the home assistant web dashboard permanently block the machine sleeping / screen turning off? Nov 26, 2023
@AlexxIT AlexxIT added the question Further information is requested label Nov 26, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Nov 26, 2023

Background video preventing PC from sleeping. You already have answered on your question.

@AdrianGarside
Copy link
Author

AdrianGarside commented Nov 26, 2023

Turning it off didn't change the behavior. Edit - retested that and it did actually fix it - just not always immediately.

But given I like to sit with my web dashboard showing I'm still interested if there's a way to have WebRTC never block the machine sleeping. Otherwise I'll have to remember to navigate away every time I leave my PC.

@AdrianGarside
Copy link
Author

Rendering via WebRTC also adds audio even though the source rstp feed doesn't have that:

[DRIVER] Realtek High Definition Audio (HDAUDIO\FUNC_01&VEN_10EC&DEV_0B00&SUBSYS_1458A0CF&REV_1000\5&307ed9b2&0&0001)
An audio stream is currently in use.

Looks like 'media: video' might have helped with that.

@AdrianGarside
Copy link
Author

AdrianGarside commented Nov 26, 2023

If I'm reading the docs right, 'EXECUTION' just means the process won't be suspend - not clear if it blocks sleep.

But audio playback definitely does. With audio disabled the listed blocker changed to:
DISPLAY:
[PROCESS] \Device\HarddiskVolume3\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
Video Wake Lock

'powercfg /requestsoverride PROCESS msedge.exe DISPLAY'

permanently blocks edge from preventing the display turning off/machine sleeping. Which is overkill but given I've had embedded web page ads cause the same problem I'm actually ok with this...

So fingers crossed 'EXECUTION' which seemingly can't be specified successfully as a requestoverride doesn't block display/sleep.

Edit: Spoke too soon - the DISPLAY block on Edge doesn't seem to work. It's still listed as a request and I think that means it's still blocking. Will have to wait until my machine should have turned off it's display to see.

@AdrianGarside
Copy link
Author

AdrianGarside commented Nov 28, 2023

'powercfg /requestsoverride PROCESS msedge.exe DISPLAY EXECUTION' was needed and worked. DISPLAY to allow the screen to turn off. EXECUTION to allow the machine to go to sleep. Possibly this will break some pages that expect to be able to do work while in the background to refresh content though :(

I don't know if the video playback tech in the browser used here lets you turn off the blocks for screen turn off / machine sleep? If not, this is probably the best I can get.

@Suxsem
Copy link

Suxsem commented Dec 18, 2023

I know it's not the best solution, but MSE mode allows sleep, so I suggest you this configuration:

background: false
muted: true
mode: mse,hls,mjpeg
media: video,audio

@AdrianGarside
Copy link
Author

I definitely need the background: true. It's the main thing mitigating the fact that Bambu Printer's stream is buggy. Only the first connection is (mostly) reliable. If that drops later the reconnect will almost certainly fail. So by keeping that initial connection permanently live regardless of being viewed it makes the stream mostly reliable. For the most part it now only stops working when I restart my production home assistant instance (which restarts webrtc/go2rtc) - I have to restart the printer after to get a working video stream again.

@AdrianGarside
Copy link
Author

I just reconfigured to have go2rtc running in it's own docker so that I can restart my home assistant without breaking the video stream. But I haven't been able to work out from the documentation:

  • How do I stop webrtc spinning up its embedded go2rtc instance in the unlikely case that the home assistant docker starts up before/faster than the go2rtc one? I just started the go2rtc docker first and that's now running and has taken over the ports. Is it sufficient that I specified a server in the webrtc custom card?
  • Is there a way to configure go2rtc itself to keep the connection to the Bambu stream alive even with no clients? Or do I need to ensure at least one of my production/test home assistant instances has viewed the feed (via go2rtc) in order for the background:true setting to keep the go2rtc connection and proxy feed live?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants