Wake a screen or put it to sleep from Home Assistant (0.2.53)
Every screen gets two template buttons, Wake and Sleep, for automations (button.press on button.<screen>_wake / _sleep). Wake does what a tap does: a dimmed screen runs wake_display, a screen that is on only restarts the standby count. Sleep dims right away through dim_display, also with Auto standby off, and closes an alert that is up (reported as remote); it is ignored during a touch calibration. A new non-restored flag, sleep_requested, keeps that standby in place: dim_display dims with standby off, and apply_screen_settings, which runs every minute, no longer wakes such a screen. wake_display clears it (a tap, Wake, an alert), and so does the Auto standby switch when it really turns standby off. Nothing is saved, so the buttons cost no flash writes and may run on every motion. The Claude skill, README, add-on docs and RELEASING describe both buttons. Checked on host builds of both boards over the native API, 24 checks each (timer, Sleep with Auto standby off across a minute tick, alert, calibration), and with ESP32 builds of both Easy profiles (+336 B RAM). Firmware 0.2.45. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+53
-3
@@ -3,7 +3,7 @@
|
||||
# Source profile for packages/guition.yaml (tools/generate_packages.py); see docs/GUITION.md.
|
||||
# A screen gets its tiles from the ESP Screen Manager add-on while it runs. The CYD is its own profile.
|
||||
substitutions:
|
||||
SCREEN_FIRMWARE_VERSION: "0.2.44"
|
||||
SCREEN_FIRMWARE_VERSION: "0.2.45"
|
||||
# 0: no drift limit; LVGL decides, releasing inside the tile is a tap, leaving it is not
|
||||
# (like iOS). The CYD keeps a limit because its resistive panel jumps.
|
||||
TOUCH_MOVE_LIMIT_PX: "0"
|
||||
@@ -560,6 +560,13 @@ globals:
|
||||
restore_value: no
|
||||
initial_value: 'false'
|
||||
|
||||
# Sleep from Home Assistant (0.2.45+): standby that also holds with Auto standby off,
|
||||
# until a tap, Wake or an alert wakes the screen.
|
||||
- id: sleep_requested
|
||||
type: bool
|
||||
restore_value: no
|
||||
initial_value: 'false'
|
||||
|
||||
- id: active_label_off
|
||||
type: std::string
|
||||
restore_value: no
|
||||
@@ -1047,6 +1054,8 @@ switch:
|
||||
auto &s = screen_settings::current;
|
||||
if (!s.standby_enabled) return;
|
||||
s.standby_enabled = false;
|
||||
// Switching it off wakes the screen, also out of Sleep; a switch that was already off leaves Sleep alone.
|
||||
id(sleep_requested) = false;
|
||||
if (runtime_tiles::enabled) runtime_tiles::settings_preference.save(&s);
|
||||
runtime_tiles::setting_event("standby_enabled", 0);
|
||||
id(apply_screen_settings).execute();
|
||||
@@ -3530,7 +3539,8 @@ script:
|
||||
if(lv_indev_get_act())lv_indev_wait_release(lv_indev_get_act());
|
||||
id(screen_lvgl).set_rotation(static_cast<esphome::display::DisplayRotation>(runtime_tiles::rotation));
|
||||
}
|
||||
if (id(display_dimmed) && !settings.standby_enabled) {
|
||||
// Auto standby off wakes the screen, but not out of a Sleep pressed in Home Assistant.
|
||||
if (id(display_dimmed) && !settings.standby_enabled && !id(sleep_requested)) {
|
||||
id(display_dimmed) = false;
|
||||
}
|
||||
auto now = id(homeassistant_time).now();
|
||||
@@ -3679,6 +3689,7 @@ script:
|
||||
- lambda: |-
|
||||
id(last_touch_ms) = millis();
|
||||
id(display_dimmed) = false;
|
||||
id(sleep_requested) = false;
|
||||
// Almost instant brightness-up. ESPHome's default is 1s, and that feels sluggish
|
||||
// when you touch the screen and are waiting on light.
|
||||
id(set_backlight).execute(screen_settings::current.brightness, 80);
|
||||
@@ -3705,7 +3716,8 @@ script:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return screen_settings::current.standby_enabled;'
|
||||
# Sleep from Home Assistant dims with Auto standby off too.
|
||||
lambda: 'return screen_settings::current.standby_enabled || id(sleep_requested);'
|
||||
then:
|
||||
- lambda: |-
|
||||
id(display_dimmed) = true;
|
||||
@@ -4483,6 +4495,44 @@ text:
|
||||
name: "Tile settings"
|
||||
internal: ${DASHBOARD_INBOX_INTERNAL}
|
||||
|
||||
button:
|
||||
# Wake and Sleep for Home Assistant automations (0.2.45+). Wake is a tap: it lights a dimmed
|
||||
# screen and counts the standby time from now. Sleep is the standby time running out, right away
|
||||
# and also with Auto standby off; it holds until a tap, Wake or an alert, and closes an alert that
|
||||
# is up. Neither saves anything, so an automation may press them on every motion. No
|
||||
# entity_category: they are controls, not settings.
|
||||
- platform: template
|
||||
id: wake_button
|
||||
name: "Wake"
|
||||
icon: "mdi:gesture-tap"
|
||||
on_press:
|
||||
- lambda: 'ESP_LOGI("standby", "Wake from Home Assistant, screen %s", id(display_dimmed) ? "in standby" : "on");'
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(display_dimmed);'
|
||||
then:
|
||||
- script.execute: wake_display
|
||||
else:
|
||||
- lambda: 'id(last_touch_ms) = millis();'
|
||||
- platform: template
|
||||
id: sleep_button
|
||||
name: "Sleep"
|
||||
icon: "mdi:power-sleep"
|
||||
on_press:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(calibration_active);'
|
||||
then:
|
||||
- lambda: 'ESP_LOGI("standby", "Sleep from Home Assistant ignored: touch calibration is running");'
|
||||
else:
|
||||
- lambda: |-
|
||||
ESP_LOGI("standby", "Sleep from Home Assistant");
|
||||
id(sleep_requested) = true;
|
||||
- script.execute:
|
||||
id: alert_dismiss
|
||||
reason: "remote"
|
||||
- script.execute: dim_display
|
||||
|
||||
number:
|
||||
- platform: template
|
||||
id: setting_brightness
|
||||
|
||||
Reference in New Issue
Block a user