Traducido del English por IA ·
Tarjeta de reglas. Así gestiono los horarios de ventilación del laboratorio.Primero asigna al perfil de la Pi un comando, p. ej. heaters.set con un parámetro Sí/No on, nivel Basic. En la Pi:
from rpi_rf import RFDevice
tx = RFDevice(17); tx.enable_tx()
CODES = {True: [5592405, 5592407, 5592411, 5592413],
False: [5592404, 5592406, 5592410, 5592412]}
def on_rpc(req_id, body):
if body.get("method") == "heaters.set":
for code in CODES[bool(body["params"]["on"])]:
tx.tx_code(code, 1, 350) # protocol 1, pulse length from the sniff
client.publish(f"v1/rpc/res/{req_id}", '{"ok": true}', qos=1)
(Tus códigos y la duración del pulso provienen del sniff, los míos son marcadores de posición.)Luego, en la tarjeta de Reglas del asset de la terraza:
- Regla «Heaters on»: When Sunrise or sunset, Sunset, offset -15. Then Send a command
heaters.seton = yes to the Pi. - Regla «Heaters off»: When A time of day 23:00, every day. Then the same with on = no.
El atardecer necesita la ubicación del lugar, así que pon la latitud/longitud en el asset de la terraza y coloca la Pi debajo de él; de lo contrario, la regla no se guardará. Además, 433 MHz no tiene retroalimentación, así que envía el comando dos veces con un minuto de diferencia si quieres asegurarte. Documentación: Time, sunrise/sunset, dates and holidays.
Rules card. I run lab ventilation schedules this way.
First give the Pi’s profile a command, e.g. heaters.set with a Yes/no param on, Basic tier. On the Pi:
from rpi_rf import RFDevice
tx = RFDevice(17); tx.enable_tx()
CODES = {True: [5592405, 5592407, 5592411, 5592413],
False: [5592404, 5592406, 5592410, 5592412]}
def on_rpc(req_id, body):
if body.get("method") == "heaters.set":
for code in CODES[bool(body["params"]["on"])]:
tx.tx_code(code, 1, 350) # protocol 1, pulse length from the sniff
client.publish(f"v1/rpc/res/{req_id}", '{"ok": true}', qos=1)
(Your codes and pulse length come from the sniff, mine are placeholders.)
Then on the terrace asset’s Rules card:
- Rule «Heaters on»: When Sunrise or sunset, Sunset, offset -15. Then Send a command
heaters.seton = yes to the Pi. - Rule «Heaters off»: When A time of day 23:00, every day. Then the same with on = no.
Sunset needs the place’s location, so put latitude/longitude on the terrace asset and place the Pi under it, otherwise the rule won’t save. Also, 433 MHz has no feedback, so send the command twice a minute apart if you want to be sure. Doc: Time, sunrise/sunset, dates and holidays.

