Sonoff DW2 door sensor going to state "unavailable"

If you want to retain a state from the rf bridge when restarting HA , read this topic :

Use strategy 2 to set the retain flag.