I have several broadlink switches that are setup to turn on and off but home assistant has no way of knowing their state.
so for example, I have a reptile heat lamp that is automated by sunrise/sunset which works fine, however when home assistant boots, its default state is set to off although the lamp is on.
Is there a way to write into the configuration the default state on boot? This way I can write an automation to set the ‘assumed state’ based on the same rules that turns it on and off?
You seem to be asking 2 different questions.
I don’t think there is a way to write default state to the configuration.
I’m not sure how that would be helpful anyway, because you still wouldn’t know if it is off or on.
You can however run an automation on startup. Then you could use your rules to “turn on” or “turn off” a switch that is already on or off.
Depending upon how your switch handles a turn-on message when it’s already on, this may or may not be a problem.
Thank you for your response. The solution of turning it on at boot (or off) would do the trick. Can’t believe I didn’t think of that! I was obviously overthinking things.
In regards to writing the default state not being possible. This would surprise me if its not possible at all as you can change states from the states page in developer tools without changing the physical state of a switch.
Hmmmmm. I have to admit to being a little confused as to what it is you’re hoping to do. I also have some broadlink switches I use that do not have separate on/off commands so I can’t technically know the state, only assume it. For example, my TV has only one command for on and off, so when I ask alexa to turn on the TV, HA assumes it’s already off so it sends the on/off command, as well as the on command for my receiver. But when I leave the house I only have the receiver turn off (the TV will turn itself off 5 minutes later if it is on), but I don’t send the on/off command for the TV.
Basically is there any state you can tie the lamp state to? To safely assume it’s own state? If you automate the lamp and never manually affect it’s state aside from automations you should be able to come up with a way to turn it on/off and assume you know when it’s on/off.
You could also maybe create an input_boolean and tie that to a custom switch? like so:
The boolean should I believe keep it’s state across restarts so this should in theory work? As long as you don’t manually send the broadlink command that is, as that would break the link between the actual state and the input_boolean state.