JLindvig

rfbridge_demux.py

Oct 25th, 2020 (edited)
871
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sensors = {
  2.   "45400A": ["Dobbelt terrassedør", "ON", "true"],
  3.   "45400E": ["Dobbelt terrassedør", "OFF", "true"],
  4.   "3C003A": ["Havelåge", "ON", "false"]
  5. }
  6. payload = data.get("payload")
  7.  
  8. if payload is not None:
  9.   if payload in sensors.keys():
  10.     service_data = {"topic": "home/{}".format(sensors[payload][0]), "payload":"{}".format(sensors[payload][1]), "qos":0, "retain":"{}".format(sensors[payload][2])}
  11.   else:
  12.     service_data = {"topic":"home/unknown", "payload":"{}".format(payload), "qos":0, "retain":"false"}
  13.     logger.warning("<rfbridge_demux> Received unknown RF command: {}".format(payload))
  14.   hass.services.call("mqtt", "publish", service_data, False)
RAW Paste Data