Problems with creating a switch

I want to create a switch which sets a variable to a certain state (Alarm mode to on).
The Probem is that the switch i am trying to use wont stay on.
Here is my config:

- platform: template
  switches:
    arm_alarm:
      value_template: '{{ states.switch.arm_alarm.state }}'
      turn_on:
        service: switch.turn_on
        entity_id: switch.arm_alarm
      turn_off:
        service: switch.turn_off
        entity_id: switch.arm_alarm

How can i accompish this?

Maybe try this:

value_template: ‘{{ is_state(“switch.arm_alarm”, “on”) }}’

To me, the switch above doesn’t make sense:

  • the value template of the switch is based on the switch itself
  • the turn on and turn off actions of the switch manipulate the switch itself

Maybe what you’re looking for is an input boolean?

thx that was exactly what i was looking for

1 Like