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
+26 -17
View File
@@ -323,7 +323,12 @@ globals:
- id: ev_energy_yesterday_kwh
type: float
restore_value: true
initial_value: "0.0"
initial_value: "0.0"
# Track last day-of-year we snapped so it only happens once per day
- id: ev_last_snapshot_doy
type: int
restore_value: no
initial_value: '-1'
# Teleperiod = 60s: publish JSON and advance the window
interval:
@@ -351,21 +356,25 @@ interval:
snprintf(buf, sizeof(buf), "{\"EVChargerWhCount\":%.3f}", delta_wh);
return std::string(buf);
##########################################################################################
# YESTERDAY ENERGY (device-side snapshot of today's total at 23:59:59)
##########################################################################################
time:
- platform: sntp
id: ev_time_for_ev_snap
on_time:
- seconds: 59
minutes: 59
hours: 23
then:
- lambda: |-
// Snapshot today's kWh just before midnight reset
if (isfinite(id(ev_energy_today_kwh).state)) {
id(ev_energy_yesterday_kwh) = id(ev_energy_today_kwh).state;
}
# YESTERDAY ENERGY (device-side snapshot of today's total at end-of-day)
# Uses existing time id(sntp_time) from sntp_common.yaml
- interval: 60s
then:
- lambda: |-
auto now = id(sntp_time).now();
if (!now.is_valid()) return;
// Snapshot once per day at 23:59 (minute precision)
if (now.hour != 23 || now.minute != 59) return;
// Prevent repeats if this runs multiple times during 23:59
if (id(ev_last_snapshot_doy) == now.day_of_year) return;
if (isfinite(id(ev_energy_today_kwh).state)) {
id(ev_energy_yesterday_kwh) = id(ev_energy_today_kwh).state;
}
id(ev_last_snapshot_doy) = now.day_of_year;