Invert the functionality of a switch

I have an integration-defined switch whose behavior I want to invert (i.e. “on” should be “off” for the default switch implementation, and vice-versa). I know I can create individual scripts that manually perform “On” and “Off” behaviors as desired, but I’m working with another integration that expects a proper switch. Is this possible?

It’s probably overkill but, the HACS integration Spook provides a Helper that provides this inverse function.

1 Like

How can you use this function in a binary sensor?
I downloaded spook but I’m too new to understand how to use it :frowning:


afbeelding

I implemented this using the template helper wizard per below screenshot but am having trouble. If the real switch is on and I turn the inverted template switch on then the real switch turns off and a moment later the template switch also turns off. Attempts to turn on the template switch fail and it turns itself off. If I directly turn off the real switch, the template switch does not turn on. When I evaluate the template in the developer tools it is correctly inverted to the real switch logic so I am quite confused what I am doing wrong. I did check the logs and dont see any errors. Appreciate any tips.