-
Notifications
You must be signed in to change notification settings - Fork 0
/
volet_up.yaml
65 lines (64 loc) · 2.09 KB
/
volet_up.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
blueprint:
name: Open a blind
description: open a blind and adjust the position once stopped
domain: automation
input:
cover_id:
name: Id of the cover
description: The entity of the cover to close
selector:
entity:
domain: cover
id:
name: Channel id
description: Channel id of the cover
time_all_way:
name: Time for the cover to open/close totally
mode: single
trigger:
platform: event
event_type: mqtt_cover_cmd
event_data:
cmd: u
variables:
id: !input id
condition: '{{ ((trigger.event.data.blind_id | int / id) | int) % 2 == 1 }}'
action:
- variables:
init_time: '{{ as_timestamp(now()) }}'
cover: !input cover_id
position: '{{ state_attr(cover, "current_position") | int}}' #100 is open 0 is closed
position_cmd_topic: '{{ "cmd/blinds_etage1a_position/" ~ ("0" if (id|int < 10)) ~ id }}'
time_all_way: !input time_all_way
- wait_for_trigger:
- platform: event
event_type: mqtt_cover_cmd
event_data:
blind_id: '{{id|int}}'
cmd: s
- platform: event
event_type: mqtt_cover_cmd
event_data:
blind_id: '{{15 if (id|int < 16) else 48}}'
cmd: s
- platform: event
event_type: mqtt_cover_cmd
event_data:
blind_id: 63
cmd: s
timeout:
seconds: '{{ time_all_way|int*(100-position)/100 }}' #23 sec to fully open the blind (position = 100), we wait less if the blind was not fully closed
continue_on_timeout: true
- if: '{{ wait.trigger == None}}' # if the blind went all way up, force position to 100
then:
- service: mqtt.publish
data:
topic: '{{position_cmd_topic}}'
payload: '100'
retain: true
else:
- service: mqtt.publish
data:
topic: '{{position_cmd_topic}}'
payload: '{{ position + (((as_timestamp(now()) - init_time) | int)/time_all_way|int*100) | int }}'
retain: true