Action template

i have this automation but not work
the switch of input.boolean stay always on

- id: luci_spente_cucina
  alias: 'luci spente cucina'
  trigger:
  - platform: state
    entity_id: switch.plug_158d000163fbb8 #Luci Mensola
    from: 'on'
    to: 'off'
  - platform: state
    entity_id: switch.plug_158d00010ac8ad #Luci Centrali
    from: 'on'
    to: 'off'
  - platform: state
    entity_id: switch.netatmo_led_cucina #Luci led cucina
    from: 'on'
    to: 'off'
  - platform: state
    entity_id: switch.plug_158d0002366d21 #Coppa vapore
    from: 'on'
    to: 'off'
  action:
  - service_template: >
           {%- if is_state('input_boolean.luci_mensola', 'off') and is_state('input_boolean.luci_centrali', 'off') and is_state('input_boolean.coppa_vapore', 'off' ) and is_state('input_boolean.luci_led_cucina', 'off' )-%}
             input_boolean.turn_on
           {%- else -%}
             input_boolean.turn_off
           {%- endif %}
    entity_id: input_boolean.luci_spente_cucina

someone that could help me?

Do you just want a toggle that is on or off based on the other states? If so you can make a binary_sensor that does the same thing without an automation

binary_sensor:
  - platform: template
    luci_mensola:
      value_template: >
        {{ is_state('input_boolean.luci_mensola', 'off') and is_state('input_boolean.luci_centrali', 'off') and is_state('input_boolean.coppa_vapore', 'off' ) and is_state('input_boolean.luci_led_cucina', 'off' ) }}

give error on binary sensor

you need to put it in configuration.yaml as it’s own section. You’re doing something wrong in regards to that.

this binary sensor is always off. not change

@petro ,
Looking at both the original and your response, there seems to be nothing wrong with either. They should work.
In effect what you did was create a ‘group’ - of items and the binary sensor is the group switch, except you can’t use the binary_sensor to switch them off.
My question is why doesn’t the original work ?

work
thank you

1 Like