New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Reply To: Patio heaters on 433 MHz sockets: switching them at sunset from a rule through a Pi

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.set on = 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.

Accepted solution♥ 3