yaml tidyups and warning removals

This commit is contained in:
root
2026-01-24 14:06:52 +13:00
parent 9bbde16d8d
commit c104187d62
44 changed files with 391 additions and 124 deletions
+27 -1
View File
@@ -11,6 +11,33 @@ substitutions:
sntp_server_2: !secret ntp_server_2
sntp_server_3: !secret ntp_server_3
###########################################################################################
# Internal clock fallback support
# If SNTP is invalid, we fall back to a simple internal minute counter
# We assume user powers on the device at 12:00 noon
# => 12 * 60 = 720 minutes from midnight.
# Not restored, so it resets each boot.
# Therefore, if no network and you still need timing functions, switch on ay noon.
###########################################################################################
globals:
- id: current_mins
type: int
restore_value: no
initial_value: "720" # 720 is 12:00 Noon
interval:
- interval: 60s
then:
- lambda: |-
// If SNTP valid, store minutes since midnight.
auto now = id(sntp_time).now();
if (now.is_valid()) {
id(current_mins) = (now.hour * 60) + now.minute;
} else {
// Fallback: minutes since boot.
id(current_mins) = (int)(millis() / 60000UL);
}
###########################################################################################
# Real time clock time source for ESPHome
# If it's invalid, we fall back to an internal clock
@@ -72,7 +99,6 @@ text_sensor:
}
// Fallback: show internal clock based on current_mins (minutes from midnight).
// NOTE: current_mins is expected to be a global defined in the main device YAML.
int mins = id(current_mins);
if (mins < 0) mins = 0;
if (mins >= 1440) mins = mins % 1440;