Stuck on my input_boolean switch, help?

Too much inside my head these days supplying medical equipment domestically, but trying to relax working on the coolest hobby there is :slight_smile:

I’ve done this in the past (but deleted it in later on), but can’t get it to work now.

Created an input_boolean

q70r_on_off:
  name: Q70R Av På
  initial: off
  icon: mdi:television-classic

Then created the switch template

  - platform: template
    switches:
      q70r_on_off:
        friendly_name: Samsung Q70R Status
        value_template: "{{ is_state('input_boolean.q70r_on_off') }}"
        turn_on:
          - service: script.q70r_skru_paa
          - service: input_boolean.turn_on
            entity_id: input_boolean.q70r_on_off
        turn_off:
          - service: script.q70r_skru_av
          - service: input_boolean.turn_off
            entity_id: input_boolean.q70r_on_off

Then adding adding it to a button-card

Though, it kind of works ONE time, then it stops. To debug, I went backwards using dev-tools and tested by executing the script - works perfect every time.
Then I tried to test the switch.q70r_on_off but it kind of turn on for a few seconds and turns off again and script is not activated.

And noticed I get these repeatedly in the log now

The is_state function takes two arguments and you have only supplied it with one.

"{{ is_state('input_boolean.q70r_on_off') }}"

Change it to:

"{{ is_state('input_boolean.q70r_on_off', 'on') }}"
1 Like

@123 See hew easy it is to overlook something… Thx mate - working as expected :upside_down_face:

But never testet, can I use a data_template within a switch template?

What I want is at HA startup, check if media_player.samsung_q70r.state = on, then set input_boolean.state to on (it is set at initial: off in config)

Should I perhaps run this in an automation at startup?

That sounds like an automation to me.