Whenever the “test boolean” is toggled, the “test switch” is also toggled.
Whenever the “test switch” is toggled, the “test boolean” is also toggled - and messages are sent via Telegram!
Why the messages are NOT sent in Scenario 1 ?
Does it mean that “turn_on” and “turn_off” actions from config.yaml are not supposed to be run in case of “switch is toggled because of some template, not because a user toggled it”?
If you do something to change the value of the switch’s value_template (other than toggling the switch) - in this case changing the input_boolean state - then the new state will be reflected by the switch but the turn on or turn off services are not executed.
Consider what would happen if it did execute the services but there was a short delay before the template updated. The switch would oscillate. This would be bad.
Thank you, but now I cannot understand a “physical meaning” of a switch.
I believe that a switch has 2 states - ON & OFF.
And every toggle causes changing ON->OF->ON … and so on.
But is there any sense to specify a switch WITHOUT that “service: input_boolean.turn_off / on” ?
Let’s create another switch - similar to the 1st switch but without toggling the “input_boolean”:
And here only the 1st switch can be toggled to ON, the 2nd switch seems to always switch back to OFF automatically (since it depends on “input_boolean” value which is not changed).
What is a purpose of this behaviour?
It is required that the service you define in the turn on/off actions will change the state of the switch. If this is not the case the switch will not operate correctly.