Not sure why but this isnt working for me.
This is in my config yaml.
binary_sensor:
- platform: mqtt
name: 'Living Room Door'
state_topic: 'home/PatioDoor'
device_class: door
My automation is
alias: rfbridge_demultiplexer
description: ""
trigger:
- platform: mqtt
topic: tele/RF_Bridge/RESULT
condition: []
action:
- service: python_script.rfbridge_demux
data_template:
payload: "{{trigger.payload_json.RfReceived.Data}}"
mode: single
And this is the python script.
d = { '5A830A':['PatioDoor','ON','true'],
'5A830E':['PatioDoor','OFF','true'],
'2DEC73':['Living Room Window','ON','true'],
'2DEC79':['Living Room Window','OFF','true']
'0568D3':['Bedroom Window','ON','true'],
'0568D9':['Bedroom Window','OFF','true']
'06D933':['Downstairs Toilet Door','ON','true'],
'06D939':['Downstairs Toilet Door','OFF','true']
'05CDC3':['Fridge','ON','true'],
'05CDC9':['Fridge','OFF','true']
'55D60A':['Front Door','ON','true'],
'55D60E':['Front Door','OFF','true']
'5E600A':['Back Door','ON','true'],
'5E600E':['Back Door','OFF','true']
}
p = str(data.get('payload'))
if p is not None:
if p in d.keys():
service_data = {'topic':'home/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
else:
service_data = {'topic':'home/unknown', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}
logger.warning('<rfbridge_demux> Received unknown RF command: {}'.format(p))
hass.services.call('mqtt', 'publish', service_data, False)
Ive also tried the sensor in my config yaml file like this
mqtt:
binary_sensor:
- name: "Patio Door"
state_topic: "home/PatioDoor"
device_class: door