I’m writing a blueprint to prevent motorized blinds from closing when a window is open. Some blinds cover multiple windows / sensors, and some cover only one window / sensor.
My blinds only report position when they stop moving; I decided to create an action based on reported position, or when the close button is pressed on the remote. The issue is better described here.
It is easy to make this work using conditions with a static number of window sensors as below, but I can’t find a way to use multiple inputs within the conditions block.
blueprint:
name: Blind Safety
description: Don't close a blind if the window is open
domain: automation
input:
blind:
name: The blind
description: The blind we are controlling
selector:
entity:
filter:
domain: cover
last_seen:
name: Last time seen
description: The last time the blind was seen
selector:
entity:
filter:
domain: sensor
remote:
name: Blind Remote
description: The remote control (close button event) for the blind
selector:
entity:
filter:
domain: event
window_sensors:
name: Window sensors
description: The sensor(s) we are checking.
selector:
entity:
multiple: false
filter:
domain: binary_sensor
window_sensors_2:
name: Window sensors
description: The sensor(s) we are checking.
selector:
entity:
multiple: false
filter:
domain: binary_sensor
mode: single
triggers:
- trigger: state
entity_id:
- !input remote
to: null
- trigger: state
entity_id:
- !input last_seen
to: null
enabled: true
conditions:
- condition: or
conditions:
- condition: state
entity_id:
- !input window_sensors
state: "on"
- condition: state
entity_id:
- !input window_sensors_2
state: "on"
actions:
- action: cover.open_cover
target:
entity_id:
- !input blind
The blueprint below with an empty condition block works as expected (with trace errors) when one or zero windows are open, but fails when two windows are open. The last_seen trigger is currently disabled as it seems to create an infinite loop of doing nothing.
blueprint:
name: Blind Safety
description: Don't close a blind if the window is open
domain: automation
input:
blind:
name: The blind
description: The blind we are controlling
selector:
entity:
filter:
domain: cover
last_seen:
name: Last time seen
description: The last time the blind was seen
selector:
entity:
filter:
domain: sensor
remote:
name: Blind Remote
description: The remote control (close button) for the blind
selector:
entity:
filter:
domain: event
window_sensors:
name: Window sensors
description: The sensor(s) we are checking.
selector:
entity:
multiple: true
filter:
domain: binary_sensor
mode: single
variables:
window_sensors: !input 'window_sensors'
triggers:
- trigger: state
entity_id:
- !input remote
to: null
- trigger: state
entity_id:
- !input last_seen
to: null
enabled: false
conditions: []
actions:
- action: >
{% for window_sensor in window_sensors %}
{% if is_state(window_sensor,"on") %}
cover.open_cover
{% endif %}
{% endfor %}
target:
entity_id:
- !input blind
Basically I want the blind to fully open if a window is open, but continue moving as directed when no window is open.
With no window open, the trace shows an error because (I think) no window was open and no action is performed on the target.
With two windows open the blinds don’t stop (appears to be concatenating the two blind actions onto the target), and the trace shows an error:
With either of two windows open, the blind stops as expected (I think because there is a valid cover action) and the trace shows no error:
Suggestions?