forked from rotilho/home-assistant-blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smart_heater.yaml
143 lines (131 loc) · 3.88 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
blueprint:
name: Smart Heater
description: Smartly heat a room using proximity, time and workday.
domain: automation
input:
proximity:
name: Proximity Sensor
selector:
entity:
domain: proximity
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
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:
proximity: !input proximity
override: !input override
away_distance: !input away_distance
away_temperature: !input away_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
proximity_state: '{{ states(proximity) }}'
proximity_direction: '{{ state_attr(proximity, "dir_of_travel") }}'
override_state: '{{ states(override) }}'
current_active_distance: '{{ [away_distance - proximity_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 <= proximity_state or not active_hour -%}
{{ away_temperature }}
{% elif proximity_state == 0 or proximity_direction == "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 proximity
- 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