I’m trying to write an automation to toggle the enabled state of other automations based on the state change of an input_boolean variable.
- alias: "Manual lights: Toggle automations for automatic lights based on override mode"
initial_state: "on"
trigger:
platform: state
entity_id: input_boolean.override_automatic_lights
action:
- service_template: automation.turn_{{trigger.to_state.state}}
data:
entity_id: automation.automatic_lights_turn_on_lights_when_dark_mode
- service_template: automation.turn_{{trigger.to_state.state}}
data:
entity_id: automation.automatic_lights_turn_off_lights_when_not_dark_mode
The log shows me that this automation is triggered as it should, but it doesn’t enable/disable the other automations. If I replace with these two instead it works
- alias: "Manual lights: Disable automations for automatic lights when override mode is enabled"
initial_state: "on"
trigger:
platform: state
entity_id: input_boolean.override_automatic_lights
from: "off"
to: "on"
action:
- service: automation.turn_off
entity_id: automation.automatic_lights_turn_on_lights_when_dark_mode
- service: automation.turn_off
entity_id: automation.automatic_lights_turn_off_lights_when_not_dark_mode
- alias: "Manual lights: Enable automations for automatic lights when override mode is disabled"
initial_state: "on"
trigger:
platform: state
entity_id: input_boolean.override_automatic_lights
from: "on"
to: "off"
action:
- service: automation.turn_on
entity_id: automation.automatic_lights_turn_on_lights_when_dark_mode
- service: automation.turn_on
entity_id: automation.automatic_lights_turn_off_lights_when_not_dark_mode
It would be nice to be able to toggle the state instead.
Any ideas?