So I’ve been controlling these cheap RF plugs with my RPi3 via @bruhautomation’s video which has worked well, but I’m getting my big girl pants on and graduating to running HA in Docker/Linux. I was kind of stumped how to integrate RF devices into HA until @DrZzs suggested the Sonoff RF Bridge. I now have the Bridge flashed with Tasmota and all is well. Well, sort of. I’m trying to integrate the Bridge into Home Assistant. I basically want the plugs to run as they do now (basically on and off by the use of slider switches). I keep digging around trying to find the answer to this, but I’m just getting frustrated because I don’t really speak MQTT (though I’m trying to learn). Basically, I’ve read this and THINK I sort of understand how this is working. I’m going to use the example given on the post mentioned:
binary_sensor:
- platform: mqtt
state_topic: "tele/RF_Bridge/RESULT"
value_template: '{{value_json.RfReceived.Data}}'
payload_on: '323234'
payload_off: '323234off'
name: "Button_A"
alias: "Button_A"
off_delay: 1
The state topic of the binary sensor is what is published from the bridge module when I press a button on my RF remote. The value template extracts the “Data” from this response that shows on the Tasmota console on the Bridge:
09:18:03 MQT: tele/sonoff/RESULT = {"RfReceived":{"Sync":13570,"Low":460,"High":1320,"Data":"515557","RfKey":"None"}}
When I turn on the remote, I can see the binary sensor turn on, then back off. So far so good. This is how home assistant can see what the RF remote is sending.
The second bit is the MQTT switch:
switch:
platform: mqtt
name: "Sonoff_Switch_01"
command_topic: "cmnd/sonoff_basic_1/power"
state_topic: "stat/sonoff_basic_1/POWER"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
retain: true
and lastly the automation that ties them together (if I’m understanding this right:
- id: change_switch_01_state
alias: "Change switch 01 state"
trigger:
platform: state
entity_id: binary_sensor.Button_A
to: 'on'
action:
- service: switch.toggle
data:
entity_id: switch.Sonoff_Switch_01
With my information switched out of these examples, I’m running into a few problems. There are 4 buttons on my RF remote that seem to be giving the same codes off. This wasn’t an issue with the rpi_rf platform, as it gave me longer codes for both on and off. I’m wondering if the “Sync”,“Low”,“High” categories the Sonoff Bridge puts out can be included in the value template?
I’m also getting a strange thing in the logs:
2019-03-22 00:03:37 WARNING (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: bed lamp with state_topic: tele/sonoff/RESULT
I’m not sure why I’m getting this warning, but I’m wondering if it’s just from the “off” bit.