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.
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 :