Hi everyone,
I noticed that in many commercial systems, shutter or blinds are often connected to respective doors sensors. So when a shutter is (partly) closed and the door/window is opened, the state of said shutter will be saved and it will fully open. After the door is closed again, it will move back to its former state.
Is is extremely handy, so is there some purpose way of doing it?
Creating an automation for every door and window seems a bit clumsy.
You could work with similar object ids, replace and the snapshot service, for example:
trigger:
- platform: state
entity_id:
- binary_sensor.bedroom_window
- binary_sensor.livingroom_door
to:
variables:
cover: "{{ trigger.entity_id |replace('binary_sensor.', 'cover.') }}"
action:
- if:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
- condition: template
value_template: "{{ state_attr(cover, 'current_position') |int(0) < 90 }}"
then:
- service: scene.create
data:
scene_id: snapshot_cover
snapshot_entities: "{{ cover }}"
- delay: 0.5
- service: cover.set_cover_position
data:
position: 90
target:
entity_id: "{{ cover }}"
else:
- service: scene.turn_on
target:
entity_id: scene.snapshot_cover
Thanks a lot! I will give it a try and Report back.
I just figured, I never reported back! So if someone else is havin the problem: Cheers to @pedolsky ! This is working pretty good, I just adjusted it slightly to make it behave better on daylight:
alias: Window Shutters
description: Window Shutters
triggers:
- entity_id:
- binary_sensor.wohnzimmer_l
- binary_sensor.wohnzimmer_r
- binary_sensor.kueche_r
- binary_sensor.hwr
- binary_sensor.gaestebad
to: null
variables:
cover: "{{ trigger.entity_id |replace('binary_sensor.', 'cover.') }}"
cover_short: "{{ trigger.entity_id |replace('binary_sensor.', '') }}"
trigger: state
conditions: []
actions:
- if:
- condition: template
value_template: "{{ state_attr(cover, 'current_position') |int(0) < 95 }}"
then:
- if:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
then:
- data:
scene_id: snapshot_cover{{ cover_short }}
snapshot_entities: "{{ cover }}"
action: scene.create
- delay: 0.5
- data:
position: 94
target:
entity_id: "{{ cover }}"
action: cover.set_cover_position
else:
- target:
entity_id: scene.snapshot_cover{{ cover_short }}
action: scene.turn_on
data: {}
mode: single