I’m stuck with one of my blueprints:
- The technical problem I am facing is to enhance a blueprint. What I have, is a blueprint to synchronize one light to another, i.e., I switch the trigger light and the state gets copied to the target light. Now, I’d like to add a (user-definable) condition to the action.
- The intended actual behavior is to not switch off the target light, if I just “blinked” the trigger light. That would give me a way to only switch on the target light (which does not have a manual switch).
I thought, it would be a good idea to just add an arbitrary action input. That could also contain a condition and would therefore be able to interrupt my main action. But as it seems, the “standard” way to include the action (within a choose) prevents the condition from stopping the rest of the automation (see here). So, the state is copied regardless of the the condition.
Here is the relevant part of my (copying but not conditioning) blueprint:
variables:
target_entity: !input target_entity
action:
- alias: Run actions or condition before copying the state
choose: []
default: !input 'pre_actions'
- alias: Copy the state
service: "homeassistant.turn_{{ trigger.id }}"
data_template:
entity_id: "{{ target_entity }}"
And that is how I would like to use it:
use_blueprint:
path: akloeckner/synchronize_lights.yaml
input:
trigger_entity: switch.A
target_entity: switch.B
pre_actions:
- condition: template
value_template: '{{ (now() - states[target_entity].last_changed).total_seconds() > 10 }}'
I’d appreciate your help on either fixing my code to work the way it should. Or, if you have any ideas how to achieve the intended actual behavior in a different way, I’d also be glad to read about it!