This is a fantastic idea and have successfully implemented it in my system.
I as well tried a different method with my Tasmota-tized devices from Digiblur.
https://www.youtube.com/watch?v=w_CchtI-oK0&t=438s
That worked well but would only do about 12 or 13 devices due to running out of room in the Tasmota rule buffers. I needed to find something that would hold much more than that.
Here is my implementation of your script. Notice that I have HA sending codes out to some devices as well, and in order to capture those changes I needed to capture another json code and then cause the script to ignore blank packets. Also I saw no reason to send failed packets to mqtt as they cannot help anything there. I elected to instead send those only to the HA log because I can safely ignore distorted/garbled/unmonitored codes, but having them show in the HA log allows me to troubleshoot new and troubled devices with ease. This is the changes I made to the python.
I do believe I could eliminate the ‘blank’ codes sent within the de-mux automation and a clever json if/then statement, but that befuddled me, so I did it this way…
d = { '00550C':['SideDoorBell','ON','false'],
'E9B03E':['BackDoorPIR','ON','false'],
'E9A63E':['BasementWayUPIR','ON','false'],
'EA284E':['BasementWayDPIR','ON','false'],
'1145C0':['DustCollectorButton1','ON','false'],
'11450C':['DustCollectorButton2','ON','false'],
'8D63A4':['MomsButton1','ON','false'],
'8D63A1':['MomsButton2','ON','false'],
'2B200A':['Mailbox','ON','true'],
'2B200E':['Mailbox','OFF','true'],
'2B2006':['BatteryLowMailbox','ON','false'],
'CB8887':['KitchenDownLights','ON','true'],
'CB8886':['KitchenDownLights','OFF','true'],
'#CB8887':['KitchenDownLights','ON','true'],
'#CB8886':['KitchenDownLights','OFF','true'],
'472083':['Chromecast','ON','true'],
'472082':['Chromecast','OFF','true'],
'#472083':['Chromecast','ON','true'],
'#472082':['Chromecast','OFF','true'],
'E8B087':['E3','ON','true'],
'E8B086':['E3','OFF','true'],
'#E8B087':['E3','ON','true'],
'#E8B086':['E3','OFF','true']
}
p = data.get('payload')
if p is not None:
if p in d.keys():
service_data = {'topic':'rf433/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
# logger.warning('<rfbridge2_demux> Received RF command: {}'.format(p))
hass.services.call('mqtt', 'publish', service_data, False)
elif p == "":
service_data = {'topic':'rf433/blank', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}
# hass.services.call('mqtt', 'publish', service_data, False)
# logger.warning('<rfbridge2_demux> Received blank RF command: {}'.format(p))
else:
service_data = {'topic':'rf433/unknown', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}
# hass.services.call('mqtt', 'publish', service_data, False)
logger.warning('<rfbridge2_demux> Received unknown RF command: {}'.format(p))
####################################################
# Sonoff Bridge Demultiplexer Automations.yaml #
####################################################
- id: bridge_2a_breaker
initial_state: 'on'
alias: rfbridge2a_demultiplexer
trigger:
platform: mqtt
topic: RF_Bridge2/tele/RESULT
action:
service: python_script.rfbridge2_demux
data_template:
payload: '{{trigger.payload_json.RfReceived.Data}}'
- id: bridge_2b_breaker
initial_state: 'on'
alias: rfbridge2b_demultiplexer
trigger:
platform: mqtt
topic: RF_Bridge2/stat/RESULT
action:
service: python_script.rfbridge2_demux
data_template:
payload: '{{trigger.payload_json.RfCode}}'
#####################################################
# Door Switches (433mhz) Binary_Sensors.yaml #
#####################################################
- platform: mqtt
name: "Mailbox"
device_class: opening
state_topic: rf433/Mailbox
payload_on: 'ON'
payload_off: 'OFF'
force_update: false
availability_topic: RF_Bridge2/tele/LWT
payload_available: Online
payload_not_available: Offline
#########################################################
## 3 ## Switch.yaml Control Dumb RF wall plugs. #
#########################################################
- platform: mqtt
name: "Kitchen Down Lights"
command_topic: "RF_Bridge2/cmnd/Backlog"
payload_on: "RfSync 9540; RfLow 310; RfHigh 920; RfCode #CB8887"
payload_off: "RfSync 9540; RfLow 310; RfHigh 920; RfCode #CB8886"
state_topic: rf433/KitchenDownLights
state_on: 'ON'
state_off: 'OFF'
availability_topic: "RF_Bridge2/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"
- platform: mqtt
name: "Chromecast"
command_topic: "RF_Bridge2/cmnd/Backlog"
payload_on: "RfSync 9540; RfLow 310; RfHigh 920; RfCode #472083"
payload_off: "RfSync 9540; RfLow 310; RfHigh 920; RfCode #472082"
state_topic: rf433/Chromecast
state_on: 'ON'
state_off: 'OFF'
availability_topic: "RF_Bridge2/tele/LWT"
payload_available: "Online"
payload_not_available: "Offline"