forked from panhans/HomeAssistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intelligent_vacuum_cleaning.yaml
147 lines (141 loc) · 4.54 KB
/
intelligent_vacuum_cleaning.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
blueprint:
name: Intelligent Vacuum Cleaning
description: This script starts a cleaning process of a vacuum cleaner robot depending on a device and its status. For this, the device must remain in a defined status for a certain time. Furthermore, a time period can be defined in which the process can start and the status must be fulfilled. In addition, an air cleaner can be defined for the cleaning process.
source_url: https://github.com/panhans/homeassistant/blob/main/blueprints/script/intelligent_vacuum_cleaning.yaml
domain: script
input:
# V A C U U M
vacuum:
name: Vacuum
description: Target vacuum robot
selector:
entity:
domain: vacuum
# T R I G G E R
trigger_device:
name: Trigger entity
description: Entity whose state starts the cleaning process.
selector:
entity:
trigger_state:
name: Entity state
description: Entity state waited for to start the process.
trigger_state_time:
name: Entity state time
description: Time the entity must be in the state for the cleaning process to start.
default: 10
selector:
number:
min: 0
max: 60
unit_of_measurement: Minutes
step: 1
mode: slider
trigger_timeout:
name: Trigger timeout
description: Time to wait for the status of the trigger entity before cancelling the cleaning process.
default: 3
selector:
number:
min: 0
max: 24
unit_of_measurement: Hours
step: 1
mode: slider
# F A N
fan:
name: Air purifier (optional)
description: Purifier that cleans the air during the cleaning process.
default:
selector:
entity:
domain: fan
fan_speed:
name: Fan speed
description: Speed of the purifier.
default: 10
selector:
number:
min: 0
max: 100
unit_of_measurement: Percent
step: 1
mode: slider
fan_after_cleaning_time:
name: Purifier overrun time
description: Time the air purifier should run after.
default: 2
selector:
number:
min: 0
max: 10
unit_of_measurement: Minutes
step: 1
mode: slider
fan_turn_off:
name: Turn off purifier after cleaning process
description: If switched off the purifier will be set to mode auto. Otherwise, it will be turned off after the cleaning process.
default: true
selector:
boolean:
estimated_cleaning_time:
name: Estimated cleaning time
description: Time the air purifier waits for the end of the cleaning process until it switches itself off.
default: 2
selector:
number:
min: 0
max: 10
unit_of_measurement: Hours
step: 1
mode: slider
mode: single
variables:
vacuum: !input vacuum
trigger_device: !input trigger_device
trigger_state: !input trigger_state
trigger_state_time: !input trigger_state_time
trigger_timeout: !input trigger_timeout
fan: !input fan
fan_speed: !input fan_speed
fan_after_cleaning_time: !input fan_after_cleaning_time
estimated_cleaning_time: !input estimated_cleaning_time
fan_turn_off: !input fan_turn_off
sequence:
- wait_template: >-
{{ states[trigger_device].state == trigger_state and ((as_timestamp(now()) - as_timestamp(states[trigger_device].last_changed | default(0)) | int ) / 60) >= (trigger_state_time | int) }}
timeout:
hours: "{{ trigger_timeout }}"
- service: vacuum.start
target:
entity_id: "{{ vacuum }}"
- wait_template: '{{ states[vacuum].state == "cleaning" }}'
timeout: '00:02:00'
continue_on_timeout: false
- choose:
- conditions:
- '{{ fan != none }}'
sequence:
- service: fan.turn_on
data:
percentage: "{{ fan_speed }}"
preset_mode: Favorite
entity_id: "{{ fan }}"
- wait_template: '{{ states[trigger_device].state != "cleaning" }}'
timeout:
hours: "{{ estimated_cleaning_time }}"
continue_on_timeout: true
- delay:
minutes: "{{ fan_after_cleaning_time }}"
- service: fan.turn_on
data:
preset_mode: Auto
target:
entity_id: "{{ fan }}"
- choose:
- conditions:
- "{{ fan_turn_off == true }}"
sequence:
- service: fan.turn_off
data:
entity_id: "{{ fan }}"