Allow all sensors to be persistent and not just input_boolean

I am using RF Door / Window sensors over the SonoffBridge.
Each sensor state is sent the same way with just the “Data” part changing.

MQT: tele/sonoffBridge/RESULT = {“RfReceived”:{“Sync”:10990,“Low”:350,“High”:1060,“Data”:“123412”,“RfKey”:“None”}}

MQT: tele/sonoffBridge/RESULT = {“RfReceived”:{“Sync”:10990,“Low”:350,“High”:1060,“Data”:“123D12”,“RfKey”:“None”}}

When you use a binary _sensor to display this state of the Door / Window being Open / Closed the value does not survive a restart. So I have to use an input_boolean in the background to store this information and then use a binary_sensor in the fore ground to allow me to use the device_class: door / window as input_boolean’s do not support the device_class function.

I suggest that other sensors such as binary_sensor should be able to use the record: function to remain persistent during a restart of Home Assistant.

The thread where I discus the issue in greater detail.

Set the MQTT retain flag = true for your binary senor state messages. This will set the state correctly on restart.

I have already tried retain: true as well as the following in the console on the RF Bridge:
PowerRetain 1, SwitchRetain 1 and SensorRetain 1

Non of them allow the sensor state to survive a restart.

Did you figure this out?

These settings apply to the sonoff bridge itself, not to messages recieved from the bridge. If you want to retain the status across HA restarts, use the demux script. see this topic :