Hi,
I’m trying to make an automation for 4 different screens, using only 1 “general” cover, script and sensor template.
The screens are called: kitchen, living room, bedroom1 and bedroom2.
The screens must be able to be operated independently of each other.
Before I run the cover template, my intention is to add a variable in the automation that controls the corresponding screen.
Something like {% set window = ‘kitchen’ %} before calling the “cover.close_cover” service, but that doesn’t work.
It seems that the variable is not taken over by the cover template.
Who can help me to solve this problem.
Thank you.
cover:
- platform: template
covers:
cover_group:
device_class: shade
friendly_name: "Cover Group"
value_template: '{{ is_state("sensor.cover_group", "open") }}'
open_cover:
service: script.cover_group
data:
modus: "open"
window: '{{ window }}'
close_cover:
service: script.cover_group
data:
modus: "close"
window: '{{ window }}'
stop_cover:
service: script.cover_group
data:
modus: "stop"
window: '{{ window }}'
set_cover_position:
service: script.cover_group_position
data:
position: '{{ position }}'
window: '{{ window }}'
icon_template: >-
{% if is_state("sensor.cover_group", "open") %}
mdi:window-open
{% else %}
mdi:window-closed
{% endif %}
script:
cover_group:
sequence:
- service: 'cover.{{ modus }}_cover'
target:
entity_id: 'screen.{{ window }}'
cover_group_position:
sequence:
- service: cover.set_cover_position
target:
entity_id: 'screen.{{ window }}'
data:
position: '{{ position }}'
sensor:
- platform: template
sensors:
cover_group:
value_template: >-
{% if is_state("screen.{{ window }}", "open") %}
open
{% else %}
closed
{% endif %}
automation:
trigger:
- platform: sun
event: sunset
offset: "+00:30:00"
action:
- service: cover.close_cover
target:
entity_id: cover.cover_group
{% set window = 'kitchen' %}