-
Notifications
You must be signed in to change notification settings - Fork 0
/
firmware.yaml
251 lines (229 loc) · 6.01 KB
/
firmware.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
substitutions:
board_type: "esp32doit-devkit-v1"
board_framework: "arduino"
device_name: "workshop"
device_desc: "Temp Humidity Sensor"
device_area: "Workshop"
humidity_target_initial: "60"
max_daily_stepdown_initial: "0.5"
display_address: "0x27"
display_dimensions: "16x2"
esphome:
name: $device_name
comment: Temp Humidity Sensor
friendly_name: $device_name
area: $device_area
on_boot:
- ds1307.read_time
- logger.log:
level: DEBUG
format: 'Humidity target is set to %d'
args: ['id(humidity_target)']
- logger.log:
level: DEBUG
format: 'Max Daily step-down is set to %d'
args: ['id(max_daily_stepdown)']
- logger.log:
level: DEBUG
format: 'Dry Programme Activation is set to %d'
args: ['id(dry_prog_active)']
esp32:
board: $board_type
framework:
type: $board_framework
logger:
api:
encryption:
key: !secret ha_api_key
ota:
- platform: esphome
password: !secret ota_flash_pass
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pw
ap:
ssid: ESPhome Fallback Hotspot
password: !secret wifi_fallback_pw
captive_portal:
i2c:
frequency: 400kHz
output:
- platform: ledc
pin: GPIO04
id: fan_control
frequency: 25000 Hz
min_power: 0%
max_power: 100%
fan:
- platform: speed
output: fan_control
name: "Dehumidifier"
id: dehumid_fan
restore_mode: ALWAYS_OFF
on_turn_on:
- switch.turn_on: dehumid_relay
on_turn_off:
- switch.turn_off: dehumid_relay
time:
- platform: ds1307
id: ds1307_time
update_interval: never
- platform: homeassistant
on_time_sync:
then:
ds1307.write_time:
web_server:
port: 80
version: 3
sensor:
- platform: wifi_signal
name: WiFi Strength
update_interval: 60s
- platform: sht4x
temperature:
name: "Temperature"
id: "sht_temp"
humidity:
name: "Humidity"
id: "sht_humidity"
on_value:
then:
- script.execute: dehumidifier_action
update_interval: 60s
- platform: homeassistant
name: "Humidity Target"
entity_id: input_number.sht45_humidity_target
id: sht45_humidity_target
unit_of_measurement: "%"
device_class: "humidity"
internal: true
accuracy_decimals: 1
on_value:
then:
if:
condition:
lambda: 'return id(humidity_target) != int(x);'
then:
- logger.log:
level: DEBUG
format: 'Humidity target changed from %d to %d'
args: ['id(humidity_target)', 'int(x)']
- globals.set:
id: humidity_target
value: !lambda 'return int(x);'
- script.execute: dehumidifier_action
- platform: homeassistant
name: "Max Daily Step-Down (Humidity)"
entity_id: input_number.sht45_max_daily_stepdown
id: sht45_max_daily_stepdown
unit_of_measurement: "%"
device_class: "humidity"
internal: false
accuracy_decimals: 1
on_value:
then:
if:
condition:
lambda: 'return id(max_daily_stepdown) != float(x);'
then:
- logger.log:
level: DEBUG
format: 'Max Daily Step-Down (Humidity) changed from %f to %f'
args: ['id(max_daily_stepdown)', 'float(x)']
- globals.set:
id: max_daily_stepdown
value: !lambda 'return float(x);'
- platform: pulse_counter
pin:
number: GPIO23
name: Dehumidifier Fan Speed (RPM)
id: fan_pulse
unit_of_measurement: 'RPM'
filters:
- multiply: 0.5
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
update_interval: 30s
switch:
- platform: gpio
pin:
number: GPIO18
name: "Dehumidifier Relay"
id: dehumid_relay
device_class: switch
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
- fan.turn_on: dehumid_fan
on_turn_off:
- fan.turn_off: dehumid_fan
- platform: template
name: "Humidity Target Status"
id: setpoint_switch
device_class: switch
restore_mode: RESTORE_DEFAULT_OFF
lambda: |-
if (id(setpoint_active)) {
return true;
} else {
return false;
}
turn_on_action:
- logger.log:
level: DEBUG
format: 'Set point active status ON'
- globals.set:
id: setpoint_active
value: "true"
- script.execute: dehumidifier_action
turn_off_action:
- logger.log:
level: DEBUG
format: 'Set point active status OFF'
- globals.set:
id: setpoint_active
value: "false"
- script.execute: dehumidifier_action
script:
id: dehumidifier_action
then:
- if:
condition:
lambda: 'return (int(id(sht_humidity).state) > id(humidity_target) && id(setpoint_active));'
then:
- logger.log:
format: 'The humidity (%d) is above the target humidity (%d). Switching dehumidifier on.'
args: ['int(id(sht_humidity).state)', 'id(humidity_target)']
- switch.turn_on: dehumid_relay
- delay: 30s
else:
- logger.log:
format: 'The humidity (%d) is under the target (%d) or the humidity target is not activated. Switching dehumidifier off.'
args: ['int(id(sht_humidity).state)', 'id(humidity_target)']
- switch.turn_off: dehumid_relay
globals:
- id: humidity_target
type: int
restore_value: true
initial_value: $humidity_target_initial
- id: max_daily_stepdown
type: float
restore_value: true
initial_value: $max_daily_stepdown_initial
- id: dry_prog_active
type: bool
restore_value: true
initial_value: "false"
- id: dry_prog_start
type: time_t
restore_value: true
initial_value: ""
- id: setpoint_active
type: bool
restore_value: true
initial_value: "false"
- id: dehumid_suspend
type: bool
restore_value: true
initial_value: "false"