From c747ea17d5e00b11d02c2849027c232e3ed9ac63 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:34:19 +0200 Subject: [PATCH] Add customization for display sleeping/awake Probably solves #1035 --- docs/en/customization.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/en/customization.md b/docs/en/customization.md index 1b46bfb..7331fbc 100644 --- a/docs/en/customization.md +++ b/docs/en/customization.md @@ -7,7 +7,9 @@ You can take advantage of [ESPHome Configuration Types](https://esphome.io/guide Please feel free to add your own customation to this document by creating a PR in the `dev` branch. -***IMPORTANT:** Use customization at your own risk. Custom/advanced systems won't be supported by this project's team.* +***IMPORTANT:*** +- *Use customization at your own risk. Custom/advanced systems won't be supported by this project's team.* +- *Please monitor the memory consumption when using customizations. Getting closer to the full memory can drive to errors in the system or prevent your system to support the future updates.*   ## Instructions @@ -165,3 +167,26 @@ time: - 0.pool.ntp.org ``` +  +### Sensor for display awake vs sleeping +Creates a binary sensor to indicate either when the display is showing some page (`on`) or sleeping (`off`). +```yaml +# Is display awake? +binary_sensor: + - name: ${device_name} Display state + id: display_state + platform: template + lambda: |- + return (id(current_page).state != "screensaver"); +``` + +You can easily invert the meaning to have a sensor for display sleeping: +```yaml +# Is display sleeping? +binary_sensor: + - name: ${device_name} Display sleeping + id: display_sleeping + platform: template + lambda: |- + return (id(current_page).state == "screensaver"); +``` \ No newline at end of file