-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsmart_heater.yaml
173 lines (161 loc) · 5.14 KB
/
smart_heater.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
blueprint:
name: Smart Heater
description: Smartly heat a room using proximity, time and workday.
domain: automation
input:
room_proximity_nearest_distance:
name: Room Owner Nearest Distance
selector:
entity:
domain: sensor
device_class: distance
room_nearest_direction_of_travel:
name: Room Owner Nearest Direction Of Travel
selector:
entity:
domain: sensor
device_class: enum
residence_nearest_distance:
name: Residence Residents Nearest Distance
description: If house is empty, away temperature will be used otherwise setback temperature
selector:
entity:
domain: sensor
device_class: distance
override:
name: Override
description: Turn heat on anyways
selector:
entity:
domain:
- binary_sensor
- light
- switch
away_distance:
name: Away Distance
selector:
number:
min: 0
max: 100
step: 1
away_temperature:
name: Away Temperature
selector:
number:
min: 0
max: 30
step: 0.1
unit_of_measurement: °C
setback_temperature:
name: Setback Temperature
selector:
number:
min: 0
max: 30
step: 0.1
unit_of_measurement: °C
active_temperature:
name: Active Temperature
selector:
number:
min: 0
max: 30
step: 0.1
unit_of_measurement: °C
active_time_start_weekday:
name: Active Time Start Weekday
selector:
time:
active_time_end_weekday:
name: Active Time End Weekday
selector:
time:
active_time_start_weekend:
name: Active Time Start Weekend
description: Also includes public holidays
selector:
time:
active_time_end_weekend:
name: Active Time End Weekend
description: Also includes public holidays
selector:
time:
climate:
name: Climate
selector:
entity:
domain: climate
mode: restart
variables:
room_proximity_nearest_distance: !input room_proximity_nearest_distance
room_nearest_direction_of_travel: !input room_nearest_direction_of_travel
residence_nearest_distance: !input residence_nearest_distance
override: !input override
away_distance: !input away_distance
away_temperature: !input away_temperature
setback_temperature: !input setback_temperature
active_temperature: !input active_temperature
active_time_start_weekday: !input active_time_start_weekday
active_time_end_weekday: !input active_time_end_weekday
active_time_start_weekend: !input active_time_start_weekend
active_time_end_weekend: !input active_time_end_weekend
climate: !input climate
room_proximity_nearest_distance_state: '{{ states(room_proximity_nearest_distance) }}'
room_nearest_direction_of_travel_state: '{{ states(room_nearest_direction_of_travel) }}'
residence_nearest_distance_state: '{{ states(residence_nearest_distance) }}'
override_state: '{{ states(override) }}'
current_active_distance: '{{ [away_distance - room_proximity_nearest_distance_state, 0] | max }}'
max_temperature_difference: '{{ active_temperature - away_temperature }}'
temperature_per_distance: '{{ max_temperature_difference / away_distance }}'
step: '{{ state_attr(climate, "target_temp_step") }}'
active_hour: >-
{% set is_weekday = states("binary_sensor.workday_sensor") == "on" %}
{% if is_weekday -%}
{{ today_at(active_time_start_weekday) <= now() and now() < today_at(active_time_end_weekday) }}
{%- else -%}
{{ today_at(active_time_start_weekend) <= now() and now() < today_at(active_time_end_weekend) }}
{%- endif %}
new_setpoint: '{{ current_active_distance * temperature_per_distance + away_temperature }}'
new_setpoint_bounded: >-
{% if override_state == "on" -%}
{{ active_temperature }}
{% elif away_distance <= residence_nearest_distance_state -%}
{{ away_temperature }}
{% elif not active_hour -%}
{{ setback_temperature }}
{% elif room_proximity_nearest_distance_state == 0 or room_nearest_direction_of_travel_state == "towards" -%}
{{ active_temperature }}
{%- else -%}
{{ new_setpoint - new_setpoint % step }}
{%- endif %}
trigger:
- platform: time
at: !input active_time_start_weekday
- platform: time
at: !input active_time_end_weekday
- platform: time
at: !input active_time_start_weekend
- platform: time
at: !input active_time_end_weekend
- platform: state
entity_id: !input room_proximity_nearest_distance
- platform: state
entity_id: !input residence_nearest_distance
- platform: state
entity_id: !input override
action:
- service: climate.set_temperature
target:
entity_id: !input climate
data:
temperature: '{{ new_setpoint_bounded }}'
- if:
- condition: state
entity_id: !input climate
state: "off"
then:
- service: climate.set_hvac_mode
data:
hvac_mode: heat
target:
entity_id: !input climate