Condition statement not working

Hello could someone please check my config Ive simplified it as my original automation has many other conditions, the sequence I want is:
Pres test button music starts
Press stop button it stops, Ive put it as a condition because I will have other “or” conditions in my original automation. No matter what state I choose as my condition the music never stops.

Thanks in advance.

alias: New automation
description: ""
triggers:
  - type: turned_on
    device_id: c1ce141440118b28cddd8ca725d23620
    entity_id: c6517642b3da2ea37dbd94ba75f5d354
    domain: switch
    trigger: device
    enabled: true
conditions: []
actions:
  - action: media_player.volume_set
    target:
      entity_id:
        - media_player.kitchen
        - media_player.outside
        - media_player.patio
    data:
      volume_level: 0.13
  - action: media_player.select_source
    data:
      source: Cruise Control
    target:
      entity_id:
        - media_player.kitchen
        - media_player.outside
        - media_player.patio
  - action: media_player.media_play
    target:
      entity_id:
        - media_player.kitchen
        - media_player.outside
        - media_player.patio
    data: {}
  - condition: state
    entity_id: input_boolean.stop
    state: "on"
  - action: media_player.media_stop
    target:
      entity_id:
        - media_player.kitchen_speaker
        - media_player.outside
        - media_player.patio
    data: {}
mode: single

You need to have this:

entity_id: input_boolean.stop
    state: "on"

As a trigger not a condition.

If you want to cause something to happen use a trigger.

If you want to prevent/allow something from happening use a condition.

1 Like

You still need the code without the indent, correct?

conditions:
  - condition: state
    entity_id: input_boolean.stop
    state: "on"
actions:
  - action: media_player.volume_up
    metadata: {}
    data: {}
    target:
      device_id: xxxx
  - condition: state
    entity_id: input_boolean.stop
    state: "on"

and Happy Anniversary!

Your logic will work, but I suggest you eliminate these two actions and see if you get results

- action: media_player.select_source
- action: media_player.media_stop

and do something simple like toggle a light.

Start simple then expand by adding the other actions

alias: New automation
description: ""
triggers:
  - type: turned_on
    device_id: xxxxxx
    entity_id: xxxxxx
    domain: switch
    trigger: device
conditions: []
actions:
  - action: media_player.volume_set
    metadata: {}
    data:
      volume_level: 0.13
    target:
      entity_id:
        - media_player.xxxx
        - media_player.xxxx
        - media_player.xxxx
  - condition: state
    entity_id: input_boolean.stop
    state: "on"
  - action: light.toggle
    metadata: {}
    data: {}
    target:
      entity_id: light.xxxx
mode: single

Verify in Developer Tools that all these devices have a source called Cruise Control

- action: media_player.select_source
    data:
      source: Cruise Control
    target:
      entity_id:
        - media_player.kitchen
        - media_player.outside
        - media_player.patio

You can always look at Traces to see what occured when the Automation ran.

1 Like

Thanks for all your responses it all helped. I think triggers are the way to go in my circumstances, the difficulty I’m having is I’m wanting to have a manual override.
I thought correct me if I’m wrong once a entity is triggered and it gets to the condition I was hoping that it would just sit there until the condition becomes true or false depending on the logic and then move onto the action. Or once triggered if the condition is not true then bad-luck the trigger needs to be retriggered and hope the condition is true this time round? I wasn’t aware about traces…really helpful.

Conditions are only evaluated at the time the trigger is fired, or if part of the actions when reaching that step. If you want to “wait” until all conditions are true, the typical solution is to duplicate all triggers/conditions as both triggers and conditions. The multiple triggers make sure that conditions are evaluated regardless of which trigger/condition is the “last” to fire/become true. The multiple conditions make sure that the triggers/conditions are all still true.

1 Like

Thanks Mayhem, that helps