-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhumidistat.yaml
executable file
·179 lines (166 loc) · 3.93 KB
/
humidistat.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
174
175
176
177
178
179
esphome:
name: humidistat
comment: Humidistat
esp32:
board: esp32dev
framework:
type: arduino
#logger:
# level: VERBOSE
<<: !include includes/common.yaml
font:
- file: 'fonts/OpenSans-Regular.ttf'
id: opensans
size: 10
- file: 'fonts/DejaVuSans-Bold.ttf'
id: dejavu_bold
size: 10
- file: 'fonts/DejaVuSans-Bold.ttf'
id: dejavu_bold_large
size: 40
color:
- id: black
red: 0%
green: 0%
blue: 0%
white: 0%
- id: red
red: 100%
green: 0%
blue: 0%
- id: green
red: 0%
green: 100%
blue: 0%
- id: blue
red: 0%
green: 0%
blue: 100%
spi:
clk_pin: 18
mosi_pin: 23
miso_pin: 19
display:
- platform: ili9341
model: TFT 2.4
rotation: 90
led_pin: 32
reset_pin: 33
cs_pin: 13
dc_pin: 27
update_interval: 1s
lambda: |-
it.fill(id(black));
it.print(0, 0, id(dejavu_bold), id(red), "Environment Data");
it.printf(0, 25, id(opensans), "Outdoor Temp: %.1f°F", id(outdoor_temp).state);
it.printf(0, 50, id(dejavu_bold), "Target Humidity: %.1f%%", id(target_humidity).state);
it.printf(15, 80, id(dejavu_bold), "Indoor Humidity");
it.printf(it.get_width() - 15, 80, id(dejavu_bold), TextAlign::TOP_RIGHT, "Target Humidity");
it.printf(10, 100, id(dejavu_bold_large), "%.1f%%", id(target_humidity).state);
it.printf(it.get_width() - 10, 100, id(dejavu_bold_large), TextAlign::TOP_RIGHT, "%.1f%%", id(target_humidity).state);
switch:
- platform: gpio
internal: true
icon: mdi:waves-arrow-up
name: Humidistat Relay
id: relay
pin: 27
- platform: template
name: "Automatic Mode"
id: automatic_mode
optimistic: true
restore_state: true
sensor:
- platform: rotary_encoder
internal: true
name: "Dial"
pin_a: 16 # CLK
pin_b: 17 # DT
on_clockwise:
- switch.turn_off: automatic_mode
- number.set:
id: manual_target
value: !lambda return id(manual_target).state + 1;
on_anticlockwise:
- switch.turn_off: automatic_mode
- number.set:
id: manual_target
value: !lambda return id(manual_target).state - 1;
- platform: homeassistant
name: "Outdoor Temp"
id: outdoor_temp
entity_id: sensor.outdoor_temp
binary_sensor:
- platform: gpio
internal: true
pin:
number: 5
mode: INPUT_PULLUP
inverted: true
name: "Mode Button"
on_press:
- switch.toggle: automatic_mode
number:
- platform: template
name: "Manual Target Humidity"
unit_of_measurement: "%"
icon: mdi:water-percent
id: manual_target
optimistic: true
min_value: 0
max_value: 60
initial_value: 40
restore_value: true
step: 1
- platform: template
internal: true
name: "Automatic Target Humidity"
unit_of_measurement: "%"
icon: mdi:water-percent
id: auto_target
min_value: 10
max_value: 45
step: 1
update_interval: 1s
lambda: !lambda |-
if (id(outdoor_temp).state < -20) {
return 10;
}
else if (id(outdoor_temp).state < -10) {
return 15;
}
else if (id(outdoor_temp).state < 0) {
return 20;
}
else if (id(outdoor_temp).state < 10) {
return 25;
}
else if (id(outdoor_temp).state < 20) {
return 30;
}
else if (id(outdoor_temp).state < 30) {
return 35;
}
else if (id(outdoor_temp).state < 40) {
return 40;
}
return 45;
set_action:
- lambda: !lambda |-
- platform: template
#internal: true
name: "Target Humidity"
unit_of_measurement: "%"
icon: mdi:water-percent
id: target_humidity
update_interval: 1s
min_value: 0
max_value: 60
step: 1
lambda: !lambda |-
if (id(automatic_mode).state) {
return id(auto_target).state;
}
return id(manual_target).state;
set_action:
- lambda: !lambda |-