Generic/template switch with assumed state?

Hi there,

is there any way to have a generic switch with turn_on and turn_off scripts, and assumed state? So, kind of a template switch, but without the required value_template ?

Background: I have a few pilight switches with bad reception. So, I want to replace the plain pilight configuration by something of the above kind. In the actions I would repeatedly send pilight commands. But as there is no way to retrieve the actual state by a template, it would need to be assumed state.

I guess this would be possible with some input_boolean and complicated cross-scripting with the switch. But I would prefer something clean, i.e. one single entity of type switch.

Do you have any ideas?

Thanks! Andreas

I coudnā€™t find anything. So, I decided to go for a change in the codebase. Hopefully, this will make it to the release soon:

1 Like

+1
exactly I am looking for

If you know your way through the various automatic checks that failed on my PR, Iā€™m happy if you can help out!

Create a normal Template switch but set:

value_template: "false"

Then, in the customize section, set:

assumed_state: true

for that switch and it works! You can turn the script on or off (regardless of state) and it will run the appropriate on or off script.

Nice idea! Except the switch will always be off, right? Iā€™d like to know the state of the switch to determine whether (e.g.) my living room is on or off. Any idea on that?

Btw, there is the template light , which supports optimistic mode, but it does not accept the customized assumed state. So, I canā€™t switch it on from the UI, if itā€™s on already.

Yes - the switch always reports as off so you certainly canā€™t use switch.toggle - which is a real pain.
The proper solution is for the code to change and just give us a switch that can run separate on and off sequences. Been waiting this for over a year so I canā€™t see it happening.
I never heard of optimistic mode - Iā€™ll check it out, thanks.