Automation not working using two switches

Sorry for asking a lot of questions :-/

I tried to use this code:

- id: '52'
  alias: 'Flurlicht durch Schalter einschalten für 2 Minuten tagsüber'
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: 
        - binary_sensor.wall_switch_158d000183ca15
        - binary_sensor.wall_switch_158d000183ca72
      click_type: single
  condition:
    condition: time
    after: '05:31'
    before: '17:59'
  action:
  - service: yeelight.set_mode
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
      mode: 'normal'
  - service: homeassistant.turn_on
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
  - delay: 00:00:05
  - service: homeassistant.turn_off
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3

Unfortunately nothing happens if I click on one of the two switches.

If I use only one of the switches in the code (=remove the second one), it works for the added one.
What is wrong with the code?

I think you need to separate your triggers, like this:

- id: '52'
  alias: 'Flurlicht durch Schalter einschalten für 2 Minuten tagsüber'
  trigger:
    - platform: event
      event_type: xiaomi_aqara.click
      event_data:
        entity_id: 
          - binary_sensor.wall_switch_158d000183ca15
        click_type: single
    - platform: event
      event_type: xiaomi_aqara.click
      event_data:
        entity_id: 
          - binary_sensor.wall_switch_158d000183ca72
        click_type: single
  condition:
    condition: time
    after: '05:31'
    before: '17:59'
  action:
  - service: yeelight.set_mode
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
      mode: 'normal'
  - service: homeassistant.turn_on
    data:
1 Like

thanks for your help @Burningstone

Unfortunately the result is the same, just nothing happens (also no log entry).
This is really strange!

Just to be clear. If I use this, it works (but of course only with one wall switch):

  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.wall_switch_158d000183ca15
      click_type: single

Strange.

For testing purposes, does it work if you create two automations, one for each button?
Like this:

- id: '52'
  alias: 'Flurlicht durch Schalter einschalten für 2 Minuten tagsüber_1'
  trigger:
    - platform: event
      event_type: xiaomi_aqara.click
      event_data:
        entity_id: binary_sensor.wall_switch_158d000183ca15
        click_type: single
  condition:
    condition: time
    after: '05:31'
    before: '17:59'
  action:
  - service: yeelight.set_mode
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
      mode: 'normal'
  - service: homeassistant.turn_on
    data:
- id: '53'
  alias: 'Flurlicht durch Schalter einschalten für 2 Minuten tagsüber_2'
  trigger:
    - platform: event
      event_type: xiaomi_aqara.click
      event_data:
        entity_id: binary_sensor.wall_switch_158d000183ca72
        click_type: single
  condition:
    condition: time
    after: '05:31'
    before: '17:59'
  action:
  - service: yeelight.set_mode
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
      mode: 'normal'
  - service: homeassistant.turn_on
    data:

Do you have any other services that will be called but you didn’t show them or why do you have this in the end?

 - service: homeassistant.turn_on
    data:

Yes it works if I create two separate automations.

For sure I have other automations but the quoted part is not the end of the code.
If you check the first post you can scroll down, there is some part missing in your quoted code :wink:

Just to make sure, you added the dash in front of ‘platform’ in the trigger section. This code copied 1:1 doesn’t work?

- id: '52'
  alias: 'Flurlicht durch Schalter einschalten für 2 Minuten tagsüber'
  trigger:
    - platform: event
      event_type: xiaomi_aqara.click
      event_data:
        entity_id: binary_sensor.wall_switch_158d000183ca15
        click_type: single
    - platform: event
      event_type: xiaomi_aqara.click
      event_data:
        entity_id: binary_sensor.wall_switch_158d000183ca72
        click_type: single
  condition:
    condition: time
    after: '05:31'
    before: '17:59'
  action:
  - service: yeelight.set_mode
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
      mode: 'normal'
  - service: homeassistant.turn_on
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
  - delay: 00:00:05
  - service: homeassistant.turn_off
    data:
      entity_id: 
        - light.flur_1
        - light.flur_2
        - light.flur_3
1 Like

I’m really sorry - now it works. I haven’t copied your code, only changed it accordingly.
Seems so that I made a mistake.

Thank you very very much for your help! Now it works :slight_smile:

No worries :slight_smile: As long as it is working now!

Your error is probably that you forgot to add the ‘-’ in front of the platform in the trigger section, this way it doesn’t recognize it as a list of triggers.