Tidy the standby code around Wake and Sleep (0.2.54)
One rule ends a Sleep: a tap, Wake or an alert. The Auto standby switch cleared sleep_requested when Home Assistant turned standby off, while ESP Screens and the settings page on the screen did not; now only wake_display clears the flag, and apply_screen_settings still wakes a screen the standby time dimmed. dim_display no longer checks anything itself (the interval checks Auto standby, the Sleep button sets the flag). It dims, then runs go_home with "also on standby" on, otherwise closes the settings page and every card through close_cards. Before, it copied half of go_home and hid the four YAML overlays itself, so a runtime detail card stayed open under a dimmed screen. close_cards is now the one runtime_tiles::dismiss() call: the fallback and the widget.hide actions after its return ran for nothing. The backlight light becomes internal. Home Assistant could change it, but the minute tick put the level back, and switching it off darkened the screen without standby. The brightness numbers and Wake/Sleep replace it. A dead clock-label branch from the manual profile leaves apply_screen_settings. Checked with 209 Python and 14 C++ tests, host builds of both boards over the native API, and ESP32 builds of both Easy profiles. Firmware 0.2.46. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+20
-42
@@ -2,7 +2,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.45"
|
||||
SCREEN_FIRMWARE_VERSION: "0.2.46"
|
||||
# 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"
|
||||
@@ -1042,8 +1042,9 @@ switch:
|
||||
- platform: restart
|
||||
name: "Restart"
|
||||
# Auto standby, the same setting as the checkbox in ESP Screens (firmware 0.2.41+), so Home Assistant
|
||||
# automations can keep a screen on. Off wakes the screen and keeps it on; on counts the standby time
|
||||
# from that moment. Nothing runs at boot: the switch follows the saved setting.
|
||||
# automations can keep a screen on. Off wakes a screen the standby time dimmed and keeps it on (a Sleep
|
||||
# holds until a tap, Wake or an alert); on counts the standby time from that moment. Nothing runs at
|
||||
# boot: the switch follows the saved setting.
|
||||
- platform: template
|
||||
id: setting_auto_standby
|
||||
name: "Auto standby"
|
||||
@@ -1065,8 +1066,6 @@ 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();
|
||||
@@ -1095,10 +1094,13 @@ output:
|
||||
frequency: 20000Hz
|
||||
|
||||
light:
|
||||
# The firmware owns the backlight: brightness, standby, night and alerts set it, and the minute tick
|
||||
# restores it. Home Assistant uses the brightness numbers and the Wake and Sleep buttons (0.2.46+).
|
||||
- platform: monochromatic
|
||||
output: gpio_backlight_pwm
|
||||
name: "Display Backlight"
|
||||
id: back_light
|
||||
internal: true
|
||||
restore_mode: ALWAYS_ON
|
||||
default_transition_length: 150ms
|
||||
|
||||
@@ -3561,11 +3563,6 @@ script:
|
||||
id(set_backlight).execute(level, id(display_dimmed) ? 1500 : 300);
|
||||
if (id(display_dimmed)) { lv_obj_clear_flag(id(dim_wake_overlay), LV_OBJ_FLAG_HIDDEN); lv_obj_move_foreground(id(dim_wake_overlay)); }
|
||||
else lv_obj_add_flag(id(dim_wake_overlay), LV_OBJ_FLAG_HIDDEN);
|
||||
// Runtime mode draws the clock in the top bar; the manual profile keeps its own label.
|
||||
if (!runtime_tiles::enabled) {
|
||||
if (settings.show_clock) lv_obj_clear_flag(id(lbl_time), LV_OBJ_FLAG_HIDDEN);
|
||||
else lv_obj_add_flag(id(lbl_time), LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
// The four setting entities only publish a changed value (HA keeps identical states anyway).
|
||||
if (id(setting_brightness).state != settings.brightness) id(setting_brightness).publish_state(settings.brightness);
|
||||
if (id(setting_standby_brightness).state != settings.standby_brightness) id(setting_standby_brightness).publish_state(settings.standby_brightness);
|
||||
@@ -3573,17 +3570,11 @@ script:
|
||||
if (id(setting_standby_seconds).state != settings.standby_seconds) id(setting_standby_seconds).publish_state(settings.standby_seconds);
|
||||
if (!id(ui_refresh).is_running()) id(ui_refresh).execute();
|
||||
|
||||
# Every card closes through runtime_tiles::dismiss (set in on_boot): the runtime detail card, the light,
|
||||
# colour and climate overlays, and active_entity, which the swipe guard reads.
|
||||
- id: close_cards
|
||||
then:
|
||||
- lambda: |-
|
||||
// Runtime cards and the legacy overlays close through one path; the swipe guard
|
||||
// reads active_entity, so a hidden card must never leave it behind.
|
||||
if (runtime_tiles::dismiss) { runtime_tiles::dismiss(); return; }
|
||||
id(active_entity).clear();
|
||||
- lvgl.widget.hide: brightness_overlay
|
||||
- lvgl.widget.hide: color_detail_overlay
|
||||
- lvgl.widget.hide: climate_detail_overlay
|
||||
- lvgl.widget.hide: climate_mode_overlay
|
||||
- lambda: 'if (runtime_tiles::dismiss) runtime_tiles::dismiss();'
|
||||
|
||||
# Everything back to the overview: the settings page, every card and the first page of tiles.
|
||||
# Used by standby, by the "Back to page 1" timeout and by the Home Assistant action.
|
||||
@@ -3722,35 +3713,22 @@ script:
|
||||
- delay: !lambda "return ms + 40;"
|
||||
- lambda: backlight_fade::sync(*id(gpio_backlight_pwm), *id(back_light), level / 100.0f);
|
||||
|
||||
# Standby: the standby time ran out (the 1 s interval checks Auto standby) or Sleep was pressed.
|
||||
# The settings page and every card close; with "also on standby" the screen goes back to page 1 too.
|
||||
- id: dim_display
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: |-
|
||||
id(display_dimmed) = true;
|
||||
id(apply_screen_settings).execute();
|
||||
- if:
|
||||
condition:
|
||||
# Sleep from Home Assistant dims with Auto standby off too.
|
||||
lambda: 'return screen_settings::current.standby_enabled || id(sleep_requested);'
|
||||
lambda: 'return screen_settings::current.home_on_standby;'
|
||||
then:
|
||||
- lambda: |-
|
||||
id(display_dimmed) = true;
|
||||
id(apply_screen_settings).execute();
|
||||
// A settings page behind a dark screen helps nobody; it always closes.
|
||||
settings_screen::close();
|
||||
if (screen_settings::current.home_on_standby) {
|
||||
// Runtime detail cards live above the tile grid, so paging alone cannot close them.
|
||||
runtime_tiles::hide_detail();
|
||||
id(active_entity).clear();
|
||||
id(tile_page) = 0;
|
||||
id(show_tile_page).execute();
|
||||
}
|
||||
|
||||
# Back to the home screen on standby. Deliberately via ESPHome's
|
||||
# actions and NOT with lv_obj_add_flag in a lambda: this script
|
||||
# runs from an interval, so outside LVGL's own handling.
|
||||
- lvgl.widget.hide: brightness_overlay
|
||||
- lvgl.widget.hide: color_detail_overlay
|
||||
- lvgl.widget.hide: climate_detail_overlay
|
||||
- lvgl.widget.hide: climate_mode_overlay
|
||||
|
||||
- script.execute: go_home
|
||||
else:
|
||||
- lambda: 'settings_screen::close();'
|
||||
- script.execute: close_cards
|
||||
|
||||
# A -/+ tap on the climate card: the number follows at once, the call waits for the last tap.
|
||||
# Holding a key steps three times a second.
|
||||
|
||||
Reference in New Issue
Block a user