Condition template

I have this automation to turn off the radio when i am not home, and i want to add another media_player other that the one already present to make the automation run when one of the two media players is in ‘playing’ state. How to do this?

- alias: Nessuno a Casa Spengo Radio
  initial_state: on
  trigger:
    - platform: template
      value_template: "{{ not is_state('device_tracker.life360_maurizio_fabiani', 'home') }}"
  condition:
      - condition: state
        entity_id: media_player.salotto_audio
        state: 'playing'
  action:
    - service: script.turn_on
      entity_id: script.radio_stop
    - service: notify.telegram
      data:
        message: Spengo la Radio.
- alias: Nessuno a Casa Spengo Radio
  initial_state: on
  trigger:
    - platform: template
      value_template: "{{ not is_state('device_tracker.life360_maurizio_fabiani', 'home') }}"
  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: media_player.salotto_audio
        state: 'playing'
      - condition: state
        entity_id: media_player.other_one ### <- your other media player entity id here
        state: 'playing'
  action:
    - service: script.turn_on
      entity_id: script.radio_stop
    - service: notify.telegram
      data:
        message: Spengo la Radio.
1 Like

Ok so in this way if only one of the media_players, is playing the script run…
very useful, thanks

Actually if one or both media players are playing the condition will be true. Is that a problem?

No, it’s what i was looking for…

1 Like