0.6.9: il bridge corretto (boost con la durata) e i comandi con argomento in PROTOCOL
La copia del bridge dentro l'app va tenuta allineata: contiene la correzione del boost, dell'assenza, di ACS off e del riscaldamento forzato, che la libreria accetta solo con un argomento. Il pacchetto Sailfish non cambia (il bridge non entra nell'RPM), quindi non serve ricostruire l'RPM.
This commit is contained in:
@@ -143,6 +143,62 @@ check("termostato: batteria non scarica", d.get("thermostat_battery_low") is Fal
|
||||
check("senza termostato: nessun errore",
|
||||
b.summarize({k: v for k, v in finto.items() if k != "thermostats"}).get("thermostat_zone") is None)
|
||||
|
||||
# --- 5) comandi che la libreria accetta solo con i loro argomenti ---------- #
|
||||
# Qui sta la ragione del blocco: il boost senza durata solleva TypeError e il
|
||||
# bridge risponde "richiesta non valida" all'app.
|
||||
from pyairahome.commands import CommandBase # noqa: E402
|
||||
|
||||
boost = b.build_command("hot_water_boost_on")
|
||||
check("boost: un'ora di default",
|
||||
boost._message.hot_water_boost_duration.seconds == 3600,
|
||||
f"{boost._message.hot_water_boost_duration.seconds}s")
|
||||
check("boost: durata scelta in minuti (90 -> 5400s)",
|
||||
b.build_command("hot_water_boost_on", 90)
|
||||
._message.hot_water_boost_duration.seconds == 5400)
|
||||
rifiuta("boost: durata fuori intervallo", "hot_water_boost_on", 5)
|
||||
rifiuta("boost: durata non numerica", "hot_water_boost_on", "presto")
|
||||
|
||||
acs = b.build_command("hot_water_heating_off")
|
||||
check("ACS spento: un'ora di default", acs._message.time.seconds == 3600,
|
||||
f"{acs._message.time.seconds}s")
|
||||
|
||||
forzato = b.build_command("force_heating_on")
|
||||
check("forzato: un'ora di default", forzato._message.duration.seconds == 3600,
|
||||
f"{forzato._message.duration.seconds}s")
|
||||
|
||||
assenza = b.build_command("away_mode_on")
|
||||
m = assenza._message
|
||||
check("assenza: da adesso a +7 giorni",
|
||||
abs((m.end_time.seconds - m.current_time.seconds) - 7 * 86400) <= 1,
|
||||
f"{m.end_time.seconds - m.current_time.seconds}s")
|
||||
check("assenza: fine dopo l'inizio", m.end_time.seconds > m.current_time.seconds)
|
||||
check("assenza: casa tenuta a 15 °C", abs(m.target_room_temperature - 15.0) < 1e-6,
|
||||
f"{m.target_room_temperature}")
|
||||
rifiuta("assenza: zero giorni", "away_mode_on", 0)
|
||||
|
||||
# Nessun comando della whitelist deve restare senza un argomento obbligatorio:
|
||||
# e' il difetto che ha fermato il boost, e la whitelist e' esattamente la lista
|
||||
# che l'app puo' chiamare, quindi va provata tutta.
|
||||
campione = {"set_hot_water_target": 55, "set_heating_setpoint": 20,
|
||||
"set_cooling_setpoint": 20, "hot_water_boost_on": 60,
|
||||
"hot_water_heating_off": 60, "away_mode_on": 7,
|
||||
"force_heating_on": 60}
|
||||
for cid in b.COMMANDS:
|
||||
try:
|
||||
cmd = b.build_command(cid, campione.get(cid), 1, ctx)
|
||||
# La busta e' quello che la libreria manda davvero: se il comando non
|
||||
# avesse un nome di campo valido, si romperebbe qui. (I comandi senza
|
||||
# parametri, come ping, hanno il messaggio interno vuoto: controllare
|
||||
# quello sarebbe sbagliato.)
|
||||
busta = CommandBase.build_command(cmd)
|
||||
byte = len(busta.SerializeToString())
|
||||
check(f"whitelist: {cid} si costruisce e si incarta",
|
||||
bool(cmd.get_field()) and byte > 0,
|
||||
f"campo {cmd.get_field()}, {byte} byte")
|
||||
except Exception as exc:
|
||||
check(f"whitelist: {cid} si costruisce e si incarta", False,
|
||||
f"{type(exc).__name__}: {exc}")
|
||||
|
||||
# --- esito ---------------------------------------------------------------- #
|
||||
falliti = [n for n, ok, _ in esiti if not ok]
|
||||
print(f"\n{len(esiti) - len(falliti)}/{len(esiti)} controlli superati")
|
||||
|
||||
Reference in New Issue
Block a user