I have multiple door / window magnet sensor & cover combinations. I am closing covers at a certin time of day but if the window / door is open the covers might get damaged while closing (they are roller curtains). Because there will be many of these, I want to “scriptize” this and want to pass the magnet & door combinations to this script.
The script below works OK:
alias: Wait until windor or door closed
sequence:
- if:
- type: is_open
condition: device
device_id: "{{ v_sensor_device_id }}"
entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
domain: binary_sensor
then:
- wait_for_trigger:
- type: not_opened
platform: device
device_id: "{{ v_sensor_device_id }}"
entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2
domain: binary_sensor
- service: cover.close_cover
data: {}
target:
entity_id: "{{ v_cover_entity_id }}"
else:
- service: cover.close_cover
data: {}
target:
entity_id: "{{ v_cover_entity_id }}"
mode: queued
icon: mdi:curtains
max: 10
However, there is one major one minor challenge with it:
- Major: When I try to change binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_2 to “{{ v_sensor_entity_id }}” I get an error - Message malformed: Entity ID {{ v_sensor_entity_id }} is an invalid entity ID for dictionary value @ data[‘entity_id’]
- Minor: I cannot remove device_ids even when I provide entity_id
How can I include entity_id as a variable? Also, is it possible to remove device_id?