2 sensors were triggered concurrently but the automation action only did for the first one sensor

Hello,

I have an issue with the title, does anyone have an experiment for this kind of situation. Here is my automations.yaml.

- alias: 'Door sensor with Sonos Say TTS'
  trigger:
    - platform: state
      entity_id: sensor.lab_door
      from: 'closed'
      to: 'open'
  action:
    - service: script.sonos_say
      data:
        sonos_entity: media_player.office
        volume: 0.3
        message: 'Lab Door is opening!'
        delay: '00:00:03'

- alias: 'Window sensor with Sonos Say TTS'
  trigger:
    - platform: state
      entity_id: sensor.front_window
      from: 'closed'
      to: 'open'
  action:
    - service: script.sonos_say
      data:
        sonos_entity: media_player.office
        volume: 0.3
        message: 'Front window is opening!'
        delay: '00:00:03'

Thanks.

Can you format your code correctly please? (look at the blue bar on top of the page). It’s very difficult otherwise to check your code…
Also please confirm which automation is working and which is not

Sorry, I just formatted the code.

It denpens on which sensor changes state quicker when I trigger them at the same time, so sometimes is window sensor and sometimes is door sensor.

Thanks.

do the actual states get reflected in HA?
My first thought would be the issue is not with HA but with the hub / device that you use to receive these signals.
For example I use an RFXTRX to catch 433MHz signals. While the RFX is busy receiving the information from 1 device, it can’t receive info from another one at the same time…
I’m wondering why you have a delay at the end of your automation when there is no action to follow?
If states are accurately reflected, that could be the other explanation: the delay holds the “handle” on your sonos, stopping it from receiving more commands. (that’s me potentially making things up here, not sure of my theory) Have you tried without the delay?

The RasPi would get both sensors’ signals because these sensors (Honeywell 5800MINI) would send data a couple times.
I have tried to comment out the delay, then the Sonos would TTS the first sensor then be cut off by another the second sensor sometimes. I am thinking is it possible to queue triggers?

OK I understand now.
A better way would be to have a condition that ensures the automation only runs if hasn’t ran in the last 3 sec:

- alias: 'Door sensor with Sonos Say TTS'
  trigger:
    - platform: state
      entity_id: sensor.lab_door
      from: 'closed'
      to: 'open'
  condition:
    - condition: template
      value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.door_sensor_with_sonos_say_tts.attributes.last_triggered | default(0)) | int > 3)}}'
  action:
    - service: script.sonos_say
      data:
        sonos_entity: media_player.office
        volume: 0.3
        message: 'Lab Door is opening!'

- alias: 'Window sensor with Sonos Say TTS'
  trigger:
    - platform: state
      entity_id: sensor.front_window
      from: 'closed'
      to: 'open'
  condition:
    - condition: template
      value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.window_sensor_with_sonos_say_tts.attributes.last_triggered | default(0)) | int > 3)}}'

action:
    - service: script.sonos_say
      data:
        sonos_entity: media_player.office
        volume: 0.3
        message: 'Front window is opening!'

Please check the indentation though as I just copied from your code and added the condition from my config

The problem is more likely that the second notification can’t play whilst the first one is already playing, so you need a wait_template that waits for the media player to be idle before making the announcement.

Thanks you all.