I know there is a topic on this forum here.
Sonoff RF Bridge. Strategies for receiving data
I used this topic a few years ago to get my sonoff rf bridge working. That unit continues to work well. Recently I received a new r2 of this bridge (a white one). I have managed to put esphome on this device and I am wondering if anyone has tips for using a similar method to get status of my sensors using esphome with a python script to publish to mqtt, similarly to what I am doing now with my original unit? I posted to the original topic but that post was unresponsive so I am hoping that a new topic gets me some answeres. I am receiving data but the data is not being properly passed through the python if statement.
I currently have this python script…
# New ESPHome RF Bridge
# White Unit
# http://192.168.0.159/
# Add the sensor below then update the binary sensor yaml file here
# /home/mele/homeassistant/_mqtt/b_sensor
d = {
'E3E20A':['sensor8','ON','true'],
'E3E20E':['sensor8','OFF','true'],
'E3E206':['sensor8b','ON','false'],
'0DCF0A':['sensor9','ON','true'],
'0DCF0E':['sensor9','OFF','true'],
'0DCF06':['sensor9b','ON','false']
}
# Create p variable of entire payload received
# p = str(msg['payload'])
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':'true'}
logger.info('RF-Bridge Publishing: ' + str(service_data))
else:
service_data = {'topic':'home/unknown', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}
rf_command = str(p)[0:2]
if rf_command != "00":
logger.warning('<rfbridge_demux> Received unknown RF command: {}'.format(p))
hass.services.call('mqtt', 'publish', service_data, False)
This Automation…
alias: ESPHome RFBridge
description: ""
trigger:
- platform: event
event_type: esphome.rf_code_received
condition: []
action:
- data_template:
payload: "{{ trigger.event }}"
action: python_script.esphome_rfbridge
enabled: true
mode: single
And these MQTT Sensors…
#########################
# ESPHome RF Bridge White
#########################
- name: "Bedroom Window"
state_topic: 'home/sensor8'
device_class: door
unique_id: E3E20A
qos: 1
- name: "Bedroom Window Low Battery"
state_topic: 'home/sensor8b'
device_class: battery
unique_id: E3E206
qos: 1
- name: "Bathroom Window"
state_topic: 'home/sensor9'
device_class: door
unique_id: 0DCF0A
qos: 1
- name: "Bathroom Window Low Battery"
state_topic: 'home/sensor9b'
device_class: battery
unique_id: 0DCF06
qos: 1