Sonoff RF Bridge / Tasmota retain MQTT messages for door sensors

I’ve got a Sonoff RF bridge flashed with Tasmota and I’m trying to figure out how to get the device to publish the “retain” flag when it sends the MQTT message to the server after detecting an RF signal.

I have a door sensor connected to a vent inside the room that opens/closes via an automation based on whether the door is open/closed and whether someone is in the room or not. The sensor on the door is RF 433 mhz and it works fine while Home Assistant is running, but if I have to restart the instance all the sensors lose their state because the RF Bridge isn’t sending the “retain” flag when it publishes the RfReceived messages to MQTT.

This is what is printed in the Tasmota console when the sensor is triggered:

22:10:42 MQT: tele/rf_bridge/RESULT = {“RfReceived”:{“Sync”:9640,“Low”:350,“High”:950,“Data”:“8D9EE7”,“RfKey”:“None”}}

I have tried setting all the “retain” flag commands (PowerRetain, SensorRetain, SwitchRetain). All are showing on/enabled, even after rebooting the RF bridge. Seems that my sensors are forwarding to MQTT with the topic as “RESULT” and not “POWER” or “SENSOR”…but there is no ResultRetain command for me to control it.

I saw the SetOption4 commmand to change topic from tele/rf_bridge/RESULT to tele/rf_bridge/RFRECEIVED, but that really didn’t help much because it still wasn’t publishing with the retain flag even with all the enable options.

I know my server is accepting the retain flag because I have several ESP8266 sensors that are publishing the flag and it retains them and publishes them as expected when you re-subscribe to # (all topics) in MQTT.fx, just none of my door sensors.

Not sure what else to try…I originally purchased the RF Bridge and door sensors after seeing a few popular tutorials of how to set it up however if I can’t get the sensors to persist their state through an HA restart, that might be a deal breaker for an automation that relies on the door state to be correct on startup.

Example: I want to open bathroom vent register if the door is open longer than 1 minute, and then shut the vent if door has been closed longer than 1 minute with no occupancy/motion. Without retain, the vent just shuts a minute after startup since the door state defaults back to closed in HA, even if the door is actually open in reality.

Has anyone successfully managed to get sensors configured with Sonoff RF Bridge to persist their state through HA restart? It seems that HA “retain” flag in binary_sensor config are not supported and never worked anyway since retain through MQTT must be sent in the publish…how can I make these work?

1 Like

One possibility is using a rule.

For example in the console you could input:

rule1 on RFRecieved#data=8D9EE7 do backlog publish2 rf_bridge/sensor ON

then rule1 1 to turn it on.

publish2 sends a retained message.

1 Like

Did you ever figure this out without using rules, I have like 15 sensors and I dont think the 3 rule buffers will work in my case

Same problem here.

Use a demux script, as explained here :

1 Like