I currently have 3 automations based on 3 different triggers, but all the automations work exactly the same, only the trigger is different and the action is different. Can i combine this in 1 automation?
So, for example:
When trigger is A, do action 1
When trigger is B, do action 2,
etc
I combined my triggers as follows, and the action (example) i want is commented out:
- id: "vacation_mode_lights"
alias: "Vacation Mode: Lights"
description: "Simulate last weeks lights during vacation mode"
trigger:
- entity_id: sensor.vacation_sensor_zithoek
platform: state
- entity_id: sensor.vacation_sensor_eetkamer
platform: state
- entity_id: sensor.vacation_sensor_kitchen
platform: state
action:
# - choose:
# - conditions:
# - condition: state
# entity_id: sensor.vacation_sensor_zithoek # <---- this one changes based on trigger
# state: 1
# sequence:
# - service: light.turn_on
# entity_id: light.woonkamer_tv # <---- this one changes based on trigger
# - conditions:
# - condition: state
# entity_id: sensor.vacation_sensor_zithoek # <---- this one changes based on trigger
# state: 0
# sequence:
# - service: light.turn_off
# entity_id: light.woonkamer_tv # <---- this one changes based on trigger
Thanks, I found that one I think, but the issue is that I struggle with the IF/ELSE afterwards. How would I use this template variable in an if/else in an action?
Thanks, this is what I ended up doing, but it gives an error. Error is:
Invalid config for [automation]: expected str for dictionary value @ data['action'][0]['choose'][0]['sequence'][0]['choose'][0]['conditions'][0]['state']. Got None. (See /config/configuration.yaml, line 4).
Invalid config for [automation]: expected str for dictionary value @ data['action'][0]['choose'][0]['sequence'][0]['choose'][1]['conditions'][0]['state']. Got None. (See /config/configuration.yaml, line 4).