Advertisement
JLindvig

rfbridge_demux.py

Oct 25th, 2020 (edited)
2,257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement