0.7.1: allineo la copia del bridge (orari dell'impianto letti come UTC)

This commit is contained in:
Carlo
2026-10-11 12:38:27 +02:00
parent 2b397b6c3a
commit f7447900f9
4 changed files with 21 additions and 17 deletions
+5 -1
View File
@@ -698,7 +698,11 @@ def boost_restanti(st: dict) -> int:
# sottrazione con "adesso" (che il fuso ce l'ha) solleva TypeError e
# /summary risponde 502 -- l'app resta senza dati ("Nessun dato").
if quando.tzinfo is None:
quando = quando.replace(tzinfo=PLANT_TZ)
# "Senza fuso" NON vuol dire ora locale: pyairahome converte i Timestamp
# con ts.ToDatetime() (utils/utils.py) che, senza argomenti, restituisce
# un datetime *naive ma in UTC*. Leggerlo come ora dell'impianto
# sbaglierebbe il conto di una o due ore.
quando = quando.replace(tzinfo=timezone.utc)
return max(0, int((quando - datetime.now(timezone.utc)).total_seconds()))
+2 -2
View File
@@ -236,8 +236,8 @@ check("boost mai avviato: zero secondi", b.boost_restanti({}) == 0)
# che ha fatto rispondere 502 a /summary: la sottrazione con "adesso" (che il
# fuso ce l'ha) solleva TypeError, e l'app resta senza dati ("Nessun dato").
# Il conto alla rovescia deve reggere entrambe le forme.
_fine_naive = (datetime.now(b.PLANT_TZ) + timedelta(seconds=1200)).strftime("%Y-%m-%dT%H:%M:%S")
check("boost con fine senza fuso (ora dell'impianto)",
_fine_naive = (datetime.now(timezone.utc) + timedelta(seconds=1200)).replace(tzinfo=None).isoformat()
check("boost con fine senza fuso (forma dell'impianto: naive UTC)",
abs(b.boost_restanti({"hot_water_boost": {"end_time": _fine_naive}}) - 1200) <= 3)
check("riassunto con fine senza fuso (la forma che dava 502)",
(b.summarize({"hot_water_boost": {"end_time": _fine_naive}}) or {}).get("boost_active") is True)