Hello. I’ve got an RF switch that I use to control a light. When I restart HA or reboot the Pi that switch turns off when HA starts up. How can I set the initial state for this switch? Can I just set that state in the config or do I need to create a Automation that triggers on start up?
Follow that link and look at state restoration. Not directly available for switches yet, however you could setup an input boolean and some automations to make it work with your RF switch.
Thanks for the reply. I found something really bonehead in my config. I think I had tried to fix this previously by added an Automation when HA starts. I found a action that was turning off that switch on startup. I changed that action to turn the switch on and now I think I’m in business.
Vageesh, are you trying to read the initial state of the switch? I don’t think you can do that. My issue was basically that when I rebooted my HA it would turn off the switch. I think they’ve fixed that in the latest builds so it just keeps the same state. I had also found a command that ran every time on startup in my config which was turning that switch off. I removed that and was good. If you want the switch to be in a certain state after reboots you can just add a entry to turn on or off that switch on startup.
Since you cannot read the initial state of the RF switch, but you always want them set to ‘on’ after a reboot, I’d just add an automation to run during every hass startup that turns on those switches. If they are already on they will stay on, If they were off they will be turned on, and best of all that makes sure the physical state of the switches and the set state in hass to be correct.