184 files

This commit is contained in:
Home Assistant Version Control
2026-09-02 11:49:09 +00:00
parent 7b47edbf8d
commit 0c64e47969
184 changed files with 9608 additions and 11572 deletions
@@ -242,7 +242,14 @@ def evaluate_runtime(
from datetime import UTC
on_dt = on_dt.replace(tzinfo=UTC)
total += max(0.0, (dt_util.utcnow() - on_dt).total_seconds()) # pragma: no mutate (a 1s floor shift vanishes in the 2-decimal rounding)
ongoing = max(0.0, (dt_util.utcnow() - on_dt).total_seconds()) # pragma: no mutate (a 1s floor shift vanishes in the 2-decimal rounding)
# #149: per-session cap — the open window contributes at most
# what the session may still book (mirrors the live tracker).
cap = trigger_config.get("trigger_runtime_max_session_seconds")
if isinstance(cap, (int, float)) and not isinstance(cap, bool) and cap > 0:
booked = es.get("session_booked_seconds") or 0.0
ongoing = min(ongoing, max(0.0, float(cap) - float(booked)))
total += ongoing
hours = total / 3600.0
best_hours = hours if best_hours is None else max(best_hours, hours)
if target_hours: