HI
Is it possible to have multiple conditions with separate actions for these conditions ?
What I am trying to achieve is after the trigger ensure binary_sensor.workday_sensor is off, If it is on exit the automation.
If it is off then set input_boolean.hotwater_timer to off then check input_boolean.hotwater_override is off if it is turn off switch.hot_water_cylinder_switch.
Hope the above makes sense
Yes, I believe you just need to call out your second condition and it should work fine.
- alias: 'Hotwater off with Timer PM Weekends'
hide_entity: False
trigger:
platform: template
value_template: '{{ states.sensor.time.state == states.sensor.hotwater_weekends_pm_stop_time_long.state }}'
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'off'
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.hotwater_timer
#Add the following line
condition:
- condition: state
entity_id: input_boolean.hotwater_override
state: 'off'
action:
- service: switch.turn_off
data:
entity_id: switch.hot_water_cylinder_switch
Basically, the only requirements for an automation are a trigger and action. But you can have as many condition/action sequences as you want. The only catch is that as soon as a condition evaluates to false the automation ends. In your example that’s what you want so it’s fine, but as soon as you want to do anything more complicated such as if/else logic, you’d want to look at Node-Red or AppDaemon.
Does priority matters? Currently, I have 2 automation with the same trigger. One announces x person is home. The second turns on the hallway light. While the first automation do not have a condition, second one does. That is, turn on the light if the light is in the ‘off’ state.
If I combine these 2 automation into one, will this work? For the end result, I want the announcement to happen regardless if the condition is false.
Update: The below code do not perform both actions. It performs only the last one.
- alias: welcome home alexa greeting
trigger:
- platform: state
entity_id:
- input_boolean.duc_home
- input_boolean.eri_home
to: 'on'
action:
- service: notify.alexa_media
data_template:
data:
type: tts
target:
- media_player.ai_1
message: '{{ trigger.to_state.attributes.friendly_name }}, will be home in about 10 minutes.'
condition:
- condition: state
entity_id: light.h_1
state: 'off'
action:
- service: light.turn_on
entity_id: light.h_1
data:
brightness: 180
You can’t use multiple keys like that. Just have one action, under which you have the service you always want to run, then the condition, then the service you only want to run if the condition was true.