So i wanted to add an actual switch here to show how it’s done. I have some cheap Menards 433mhz switches that run by a 6 button remote. 3 switches, and each has a different on and off code.
What you do is click the button about 5 times as the capture is not perfect. Then you use that info to make a switch like below…
This is from the bridge control panel. I pushed the on, then the off 5 times. You can average these number or just pick something in the middle. Throw out the outlayers. You may have to tweak the numbers in HA if it isn’t responding correctly most of the time.
04:00:12 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9540,"Low":300,"High":880,"Data":"472083","RfKey":"None"}}
04:00:15 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9590,"Low":300,"High":880,"Data":"472083","RfKey":"None"}}
04:00:17 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9560,"Low":300,"High":890,"Data":"472083","RfKey":"None"}}
04:00:20 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":8140,"Low":310,"High":890,"Data":"239041","RfKey":"None"}}
04:00:22 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9520,"Low":300,"High":880,"Data":"472083","RfKey":"None"}}
04:00:25 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9560,"Low":300,"High":880,"Data":"472082","RfKey":"None"}}
04:00:27 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9560,"Low":300,"High":880,"Data":"472082","RfKey":"None"}}
04:00:32 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9580,"Low":290,"High":890,"Data":"472082","RfKey":"None"}}
04:00:34 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9590,"Low":300,"High":890,"Data":"472082","RfKey":"None"}}
04:00:37 MQT: RF_Bridge/tele/RESULT = {"RfReceived":{"Sync":9550,"Low":310,"High":880,"Data":"472082","RfKey":"None"}}
Your topic may be switched in order and your names will change, but this is a working switch, Optimistic seems to work the best, and state could probably be removed, but it’s working for me.
switch:
#####################################################
# MQTT Plug Set D Lights #
#####################################################
#######
## 1 ##
#######
- platform: mqtt
id: "D1"
name: "D1"
command_topic: "RF_Bridge/cmnd/Backlog"
payload_on: "RfSync 9600; RfLow 290; RfHigh 890; RfCode #472083"
payload_off: "RfSync 9600; RfLow 290; RfHigh 890; RfCode #472082"
state_topic: "RF_Bridge/tele/RESULT"
value_template: '{{value_json.RfCode}}'
state_on: "#472083"
state_off: "#472082"
optimistic: true
qos: 2
retain: false
availability_topic: "RF_Bridge/tele/LWT"
payload_available: Online
payload_not_available: Offline
When you push the button in HA, the console looks like this and the switch reacts.
04:02:59 MQT: RF_Bridge/stat/RESULT = {"RfSync":9600}
04:02:59 MQT: RF_Bridge/stat/RESULT = {"RfLow":290}
04:03:00 MQT: RF_Bridge/stat/RESULT = {"RfHigh":890}
04:03:00 MQT: RF_Bridge/stat/RESULT = {"RfCode":"#472083"}
......
04:03:01 MQT: RF_Bridge/stat/RESULT = {"RfSync":9600}
04:03:01 MQT: RF_Bridge/stat/RESULT = {"RfLow":290}
04:03:01 MQT: RF_Bridge/stat/RESULT = {"RfHigh":890}
04:03:02 MQT: RF_Bridge/stat/RESULT = {"RfCode":"#472082"}