MikeGawi / ePiframe

ePiframe is an e-Paper (or HDMI, Composite display) Raspberry Pi Photo Frame with Google Photos and more
GNU General Public License v3.0
63 stars 10 forks source link

Display Sleep #64

Closed jakemauer closed 2 years ago

jakemauer commented 2 years ago

Hi Mike!

I'm using ePiframe with a repurposed HDMI monitor and I'd love to be able to have the monitor go to sleep in the evening and wake up in the morning. While I'm making wishes it would be cool if there was a webhook I could hit to turn it on/off so I could integrate it with my smart home system in Home Assistant.

Do you know how I would even go about sleeping the display and turning it back on again on a Pi4? I found this discussion: https://www.reddit.com/r/raspberry_pi/comments/5e860b/how_do_you_get_raspbian_to_turn_off_its_monitor/

which references using tvservice -o to turn off the display. tvservice is only available if you're using the fkms driver, not the default kms driver. If I switch to using fkms, the flag -o does sleep the display! -p wakes it up but the photo picture framebuffer doesn't appear.

MikeGawi commented 2 years ago

This is fantastic! I love the idea! OK, I will do the research, tests and will give you a feedback what is possible. The best would be to control the on/off with the API and/or the service command but I'll find the best way. Also the on/off times will be controlled by the configured frame on/off times.

Thanks!

MikeGawi commented 2 years ago

My findings so far:

I still needs some more testing but I will implement that feature soon.

@jakemauer - the tvservice -o was not working for you on default driver or I didn't get that right?

jakemauer commented 2 years ago

That’s correct. When using the KMS driver it errors out saying tvservice is not available with that driver.

On Apr 26, 2022, at 3:30 PM, Mike Gawi @.***> wrote:

 My findings so far:

tvservice (-p and -o) works for me on legacy and Fake KMS drivers. Full KMS will not work and is not recommended on Pi0 - maybe I was not searching too deeply but I'm happy it works on the default driver and I'll stick to that (no documentation needed, no specific changes, etc.). the -p powers up the display but loses "hook" and displays black screen. the -p powers up the display and fbset -depth 8 (dummy fbset to force a refresh) updates it (the console appears) so it can display something again. I still needs some more testing but I will implement that feature soon.

@jakemauer - the tvservice -o was not working for you on default driver or I didn't get that right?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

MikeGawi commented 2 years ago

Ok, now I know where my confusion came from: Checked on RPi4 and there the KMS driver (vc4-kms-v3d) is set as default, where on RPi0 a legacy driver is a default. Legacy and FKMS works with tvservice and KMS not.

MikeGawi commented 2 years ago

I think I've found the best solution that works for every default driver and on every Raspberry Pi (0,3,4): vcgencmd display_power 0 and vcgencmd display_power 1 For some displays the power off works for few seconds only as hotplug is triggered but that's all about tweaking RPi configuration.

Please check that solution and let me know. The more tests performed the better this will work.

MikeGawi commented 2 years ago

Implemented and merged to master.

If you want to have the display power off during ePiframe off hours (start_times and stop_times settings) just use the setting control_display_power in config.cfg file or in WebUI: Settings->Display->Control Display Power. Obviously that will only work when HDMI display is selected.

As for

While I'm making wishes it would be cool if there was a webhook I could hit to turn it on/off so I could integrate it with my smart home system in Home Assistant.

you can use ePiframe API to get status and control the display power. This API command works regardless to the setting mentioned above.

jakemauer commented 2 years ago

This is amazing, thank you Mike! I'm waiting to get my display back up and running this weekend but I'll keep you posted.