No Automations triggered with Input Boolean or Switch Button

Hi everybody,

I have buttons in my Lovelace frontend. Each one turns on and off a scene (to look a film, a movie etc).
I have automations to manage the lights (time conditions, strenghth…), triggered by the scenes.
If I send a command turn_on for a scene, everything works perfectly. With the toggle action of the button, the scene turn on, but no automation lights works.

For exemple here, when I push the button to switch between the scenes “je_regarde_une_serie” and “la_serie_est_finie”, the automation to turn on the scenes “ambiance_cosy_de_la_bibliotheque” and “allume_les_lumieres_du_cinema” doesn’t work. But it’s woking when I send the turn_on command.
I’ve tried two possibilities:

        cards:
          - type: custom:decluttering-card
            template: button_série
            variables:
              - name: Série
              - entity: input_boolean.serie_power_switch

  button_série:
    card: 
      type: 'custom:button-card'  
      color: auto
      size: 50%
      show_icon: false
      entity: '[[entity]]'
      show_last_changed: true
      aspect_ratio: 1/1
      show_state: true
      name: '[[name]]'
      show_label: true
      tap_action:
        action: toggle
        haptic: light

automation:
  - alias: "[Boolean] Serie on"
    initial_state: on
    trigger:
      - platform: state
        entity_id: input_boolean.serie_power_switch
        to: "on"
    action:
      - service: scene.turn_on
        entity_id: scene.je_regarde_une_serie
  - alias: "[Boolean] Serie off"
    initial_state: on
    trigger:
      - platform: state
        entity_id: input_boolean.serie_power_switch
        to: "off"
    action:
      - service: scene.turn_on
        entity_id: scene.la_serie_est_finie

automation.yaml :

- id: '1612296465924'
  alias: Ambiance couché après une série
  trigger:
  - event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.la_serie_est_finie
    event_type: call_service
    platform: event
  condition:
  - condition: time
    after: '21:00:00'
    before: 05:00:00
  action:
  - service: scene.turn_on
    entity_id: scene.ambiance_cosy_de_la_bibliotheque
  - service: scene.turn_on
    entity_id: scene.allume_les_lumieres_du_cinema
  mode: parallel
  max: 10

And then I thought, that an input_boolean is an automation and maybe it can’t triggered another automation, so I’ve tried with a switch:

        cards:
          - type: custom:decluttering-card
            template: button_série
            variables:
              - name: Série
              - entity: switch.serie_power_switch

  button_série:
    card: 
      type: 'custom:button-card'  
      color: auto
      size: 50%
      show_icon: false
      entity: '[[entity]]'
      show_last_changed: true
      aspect_ratio: 1/1
      show_state: true
      name: '[[name]]'
      show_label: true
      tap_action:
        action: toggle
        haptic: light

switch:
  - platform: template
    switches:
      serie_power_switch:
        value_template: "{{ is_state('input_boolean.serie_power_switch', 'on') }}"
        turn_on:
          - service: scene.turn_on
            entity_id: scene.je_regarde_une_serie
          - service: input_boolean.turn_on
            entity_id: input_boolean.serie_power_switch
        turn_off:
          - service: scene.turn_on
            entity_id: scene.la_serie_est_finie
          - service: input_boolean.turn_off
            entity_id: input_boolean.serie_power_switch

automation.yaml :

- id: '1612296465924'
  alias: Ambiance couché après une série
  trigger:
  - event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.la_serie_est_finie
    event_type: call_service
    platform: event
  condition:
  - condition: time
    after: '21:00:00'
    before: 05:00:00
  action:
  - service: scene.turn_on
    entity_id: scene.ambiance_cosy_de_la_bibliotheque
  - service: scene.turn_on
    entity_id: scene.allume_les_lumieres_du_cinema
  mode: parallel
  max: 10

Can you help me please? What I’m doing wrong?

Thank you

I’m not aware of any way to toggle a scene. When you take a look at Developer Tools - > Services, there is no service scene.toggle

As a workaround, you could create a second scene for ‘off’ and play with the several actions, e.g.


type: custom:button-card
tap_action:
  action: call-service
  service: scene.turn_on
  service_data:
    entity_id: scene.essen_an     ## scene entities on
double_tap_action:
  action: call-service
  service: scene.turn_on
  service_data:
    entity_id: scene.essen_aus      ## scene entities off

Alternatively for the ‘off’-action:

double_tap_action:
  action: call-service
  service: light.turn_off  ## or: `homeassistant.turn_off`
  service_data:
    entity_id:
      - light.1
      - light.2


EDIT: Murphy’s Law… Haven’t seen the automation following your first code… The first automation is working: If the input_boolean’s state changes to ‘on’, the scene turns on.
But I don’t understand the event stuff in your second automation.

hi pedolsky, thanks for answering :slight_smile:

I’ve thought about working with tap_action to turn on and double_tap_action to turn off to avoid the problem. Because the other tap buttons are working with the automations.
But I do prefer a “on/off” button if it’s possible.

To explain the second automation :
I have lot’s of light scenes, automatically activated with tv/movie/serie/etc scenes.
This case is one exemple. Here, the second automation is attached to two lights scenes. When I switch off the serie, it’s automatically calling a scene to open the light on slowly in the main room (during 10) and some other in another room (to avoid to shoot something when I go to bed :smile:). With a time condition, because it’s not necessary during the daylight.
I have a few automation like that, automatically activated when some scene.tun_on are called. It avoid me te rewrite the conditional lights settings in every tv/movie/serie/etc scenes, and it works very well.

But if I call the exact same tv/movie/serie/etc scene in the “on/off switch” or “on/off input bootlean” button card in lovelace, it’s seems that the call service are missing the automation, or something like that. And it doesn’t activate the light scenes.

You could try another condition scheme:


trigger:
  - platform: state
    entity_id: input_boolean.serie_power_switch
    to: 'off'
action:
  - scene: scene.la_serie_est_finie
  - condition: time
    after: '21:00:00'
    before: '05:00:00'
  - scene: scene.x
  - scene: scene.y

I’ll try that, but without the scene.la_serie_est_finie, which I could turn_on during all the day (it switch off the serie)
If it doesn’t work, then I’ll try this also :

trigger:
  - platform: state
    entity_id: scene.la_serie_est_finie
    to: 'on'

Just tried, it seems that your solution is working like that :

trigger:
  - platform: state
    entity_id: input_boolean.serie_power_switch
    to: 'off'
action:
  - condition: time
    after: '21:00:00'
    before: '05:00:00'
  - scene: scene.x
  - scene: scene.y

and not my solution with the scene.

I try a little more tonight.
Thank you for your help :+1:

It worked very well during the night. I’ve tried the solution with other scenes and light automations.

Thanks for you help ! :+1: