-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflorasense.yaml
1139 lines (1031 loc) · 27.7 KB
/
florasense.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# substitutions (change these to make automatic updates to the code device & entity names)
substitutions:
name: "florasense" # esphome device name
friendly_name: "FloraSense" # home assistant device name
project_name: "FloraSense"
project_version: "2024.10.1"
default_drybulb: "68.0" # defaults to 68.0 °F
default_dewpoint: "55.8" # defaults to 55.8 °F
heatsink_pid_mode: "COOL" # change to "HEAT_COOL" if usng the TEC in bidirectional mode (default: "COOL")
drybulb_pid_mode: "HEAT_COOL" # change to "COOL" if not using aux heater (default: "HEAT_COOL")
dewpoint_pid_mode: "COOL" # change to "HEAT_COOL" if usng a humidifier (default: "COOL")
cooling_fan_speed: "100" # default fan speed: 100
circulation_fan_speed: "50" # default fan speed: 50
hidden_ssid: "false"
log_level: "INFO"
# esphome config
esphome:
name: $name # do not change this
friendly_name: $friendly_name # do not change this
name_add_mac_suffix: true # change to "false" to set the name manually without mac address
project:
name: $project_name
version: $project_version
on_boot:
priority: -100
then:
- script.execute: return_to_default # set defaults (set in substitutions)
- script.execute: ti_driver_startup # start TEC drivers
esp32:
board: mhetesp32minikit # quinled esp32
framework:
type: esp-idf
# enable logging
logger:
level: $log_level
# enable Home Assistant API
api:
# enable over the air updates
ota:
- platform: esphome
id: ota_esphome
dashboard_import:
package_import_url: github://everythingsmarthome/everything-presence-one/everything-presence-one.yaml@main
import_full_config: false
# wifi config
wifi:
ap:
captive_portal:
# i2c bus (dont change unless you know what you are doing)
i2c:
id: i2c_bus_main
sda: 21
scl: 22
scan: true
frequency: 400khz
timeout: 10ms
# one_wire bus (disabled by default, uncomment to enable)
# one_wire:
# - platform: gpio
# pin: GPIO27
# ADC configuration (for reading current)
ads1115:
- address: 0x49 # i2c address
# DAC configuration (for controlling drivers)
mcp4728:
- id: dac_output
address: 0x60
select:
- platform: template
name: Mode
id: mode
options:
- "Dry"
- "Cure"
- "Hold"
initial_option: "Dry"
optimistic: true
set_action:
- logger.log:
format: "Chosen option: %s"
args: ["x.c_str()"]
# input numbers
number:
# dry_stage_drybulb: "68"
- platform: template
name: "Dry Stage Dry Bulb"
id: d_stage_db
initial_value: 68.0
min_value: 0.0 # fixed universal range
max_value: 100.0 # fixed universal range
step: 0.5
icon: "mdi:thermometer"
optimistic: true
mode: box
# dry_stage_dewpoint: "54"
- platform: template
name: "Dry Stage Dew Point"
id: d_stage_dp
initial_value: 54.0
min_value: 0.0 # fixed universal range
max_value: 100.0 # fixed universal range
step: 0.5
icon: "mdi:thermometer"
optimistic: true
mode: box
# dry_stage_circ: "0.5"
- platform: template
name: "Dry Stage Air Circulation"
id: d_stage_circ
initial_value: 0.5
min_value: 0.0
max_value: 1.0
step: 0.1
icon: "mdi:fan"
optimistic: true
mode: box
# dry_stage_duration: "3" # days for cycle
- platform: template
name: "Dry Stage Duration"
id: d_stage_time
initial_value: 3
min_value: 0
max_value: 365
step: 1
icon: "mdi:calendar"
optimistic: true
mode: box
# dry_stage_ramp: "0"
- platform: template
name: "Dry Stage Ramp"
id: d_stage_ramp
initial_value: 0
min_value: 0.0
max_value: 1.0
step: 0.1
optimistic: true
mode: box
# cure_stage_drybulb: "68"
- platform: template
name: "Cure Stage Dry Bulb"
id: c_stage_db
initial_value: 68.0
min_value: 0.0 # fixed universal range
max_value: 100.0 # fixed universal range
step: 0.5
icon: "mdi:thermometer"
optimistic: true
mode: box
# cure_stage_dewpoint: "54"
- platform: template
name: "Cure Stage Dew Point"
id: c_stage_dp
initial_value: 54.0
min_value: 0.0 # fixed universal range
max_value: 100.0 # fixed universal range
step: 0.5
icon: "mdi:thermometer"
optimistic: true
mode: box
# cure_stage_circ: "0.5"
- platform: template
name: "Cure Stage Air Circulation"
id: c_stage_circ
initial_value: 0.5
min_value: 0.0
max_value: 1.0
step: 0.1
icon: "mdi:fan"
optimistic: true
mode: box
# cure_stage_duration: "3" # days for cycle
- platform: template
name: "Cure Stage Duration"
id: c_stage_time
initial_value: 3
min_value: 0
max_value: 365
step: 1
icon: "mdi:calendar"
optimistic: true
mode: box
# cure_stage_ramp: "0"
- platform: template
name: "Cure Stage Duration"
id: c_stage_ramp
initial_value: 0
min_value: 0.0
max_value: 1.0
step: 0.1
optimistic: true
mode: box
# hold_stage_drybulb: "68"
- platform: template
name: "Hold Stage Dry Bulb"
id: h_stage_db
initial_value: 68.0
min_value: 0.0 # fixed universal range
max_value: 100.0 # fixed universal range
step: 0.5
icon: "mdi:thermometer"
optimistic: true
mode: box
# hold_stage_dewpoint: "54"
- platform: template
name: "Hold Stage Dew Point"
id: h_stage_dp
initial_value: 54.0
min_value: 0.0 # fixed universal range
max_value: 100.0 # fixed universal range
step: 0.5
icon: "mdi:thermometer"
optimistic: true
mode: box
# hold_stage_circ: "0.5"
- platform: template
name: "Hold Stage Air Circulation"
id: h_stage_circ
initial_value: 0.5
min_value: 0.0
max_value: 1.0
step: 0.1
icon: "mdi:fan"
optimistic: true
mode: box
# hold_stage_duration: "3" # days for cycle
- platform: template
name: "Hold Stage Duration"
id: h_stage_time
initial_value: 3
min_value: 0
max_value: 365
step: 1
icon: "mdi:calendar"
optimistic: true
mode: box
# hold_stage_ramp: "0"
- platform: template
name: "Hold Stage Duration"
id: h_stage_ramp
initial_value: 0
min_value: 0.0
max_value: 1.0
step: 0.1
optimistic: true
mode: box
# Dewpoint Set Point
- platform: template
name: "Dewpoint Target"
id: dewpoint_setpoint
min_value: 0.0 # fixed universal range
max_value: 100.0 # fixed universal range
step: 0.01
icon: "mdi:thermometer"
optimistic: true
mode: box
# Drybulb Set Point
- platform: template
name: "Drybulb Target"
id: drybulb_setpoint
min_value: 0.0 # Fixed universal range
max_value: 100.0 # Fixed universal range
step: 0.01
icon: "mdi:thermometer"
optimistic: true
mode: box
# relative humidity set point for calculation
- platform: template
name: "Relative Humidity Target"
id: rh_setpoint
min_value: 0
max_value: 100
step: 1
icon: mdi:water-percent
optimistic: true
device_class: humidity
mode: box
# Cold Heatsink Set Point
- platform: template
internal: true
id: cold_hs_setpoint
optimistic: true
min_value: 2.0
max_value: 20.0
step: 0.01
# Output Level
- platform: template
internal: true
id: tec_pl_number
optimistic: true
min_value: 0.0
max_value: 1.0
step: 0.01
# Max Current Level milliAmps
- platform: template
internal: true
id: pwm_max_current_number
optimistic: true
min_value: 0
max_value: 80
step: 1
# Frost limit is the lowest temperature the system will target to prevent frost (default: 2.0°C)
- platform: template
name: Frost Limit
id: frost_limit
optimistic: true
initial_value: 2.0
min_value: 0.0
max_value: 10.0
step: 0.5
mode: box
# Cold Heatsink Range # Range above the dewpoint setpoint to take the target temperature (default: 2.0°C)
- platform: template
name: Heatsink Heating Range
id: cold_hs_up_range
optimistic: true
initial_value: 2.0
min_value: 0.0
max_value: 10.0
step: 0.5
mode: box
# Cold Heatsink Range # Range below the dewpoint setpoint to take the target temperature. negative number or zero. (default: -10.0°C)
- platform: template
name: Heatsink Cooling Range
id: cold_hs_dn_range
optimistic: true
initial_value: -10.0
min_value: -15.0
max_value: 0.0
step: 0.5
mode: box
# Bias Temperature # Authority of drybulb on cold side temp when near dewpoint target. (default: 2°C)
- platform: template
name: Heatsink Bias
id: bias_range
optimistic: true
initial_value: 2.0
min_value: -10.0
max_value: 10.0
step: 0.5
mode: box
# Low Fan Speed # Lowest speed the fan will go when air is hot and wet(default: 0.05)
- platform: template
name: Lowest Fan Speed
id: low_speed
optimistic: true
initial_value: 0.05
min_value: 0.0
max_value: 1.0
step: 0.05
mode: box
binary_sensor:
- platform: template
device_class: problem
id: sponge_dry
name: Add Water
sensor:
# Cold Fan Speed
- platform: template
name: "Cold Fan Speed"
id: cold_fan_speed
accuracy_decimals: 2
lambda: |-
float dry_action = id(dewpoint_cool_result).state;
float cool_action = id(drybulb_cool_result).state;
float fan_minimum = id(low_speed).state;
float fan_speed = 0.0;
if (cool_action <= 0.2 && dry_action > 0.2) {
fan_speed = fan_minimum;
}
else if (cool_action > 0.2 && dry_action <= 0.2) {
fan_speed = cool_action;
}
else if (cool_action <= 0.01 && dry_action <= 0.01) {
fan_speed = 0.0;
}
return fan_speed;
update_interval: 20s
filters:
- round: 2
- clamp:
min_value: 0.0
max_value: 1.0
on_value:
then:
- output.set_level:
id: fan_cold
level: !lambda return id(cold_fan_speed).state;
# Cold Heatsink Target Calculation
- platform: template
name: "Cold Heatsink Target Calculation"
id: cold_calc
accuracy_decimals: 1
device_class: temperature
unit_of_measurement: "°C"
state_class: measurement
lambda: |-
float dp_error = id(dewpoint_error).state;
float mid_point = id(dewpoint_celcius).state;
float dp_dn_action = id(dewpoint_cool_result).state;
float dp_up_action = 1.0 - id(dewpoint_cool_result).state;
float cold_limit = std::max((mid_point + id(cold_hs_dn_range).state), id(frost_limit).state);
float hot_limit = mid_point + id(cold_hs_up_range).state;
float cool_action = id(drybulb_cool_result).state;
float bias_value = id(bias_range).state;
float range_up = hot_limit - mid_point;
float range_dn = mid_point - cold_limit;
float current_setpoint = id(cold_hs_setpoint).state;
float max_rate_of_change = 0.1; // Uniform rate limit for all changes
float target_temp = mid_point; // Default target temperature
// Determine the target temperature based on dewpoint error and control actions
if (dp_error < -0.5) {
target_temp = mid_point - range_dn * dp_dn_action;
} else if (dp_error >= -0.5 && dp_error <= 0.5) {
target_temp = mid_point - (range_dn * dp_dn_action + bias_value * cool_action);
} else if (dp_error > 0.5) {
target_temp = mid_point + range_up * cool_action;
}
// Apply a uniform rate limit (0.2°C per 10 seconds) to all changes
if (target_temp > current_setpoint) {
// Limit upward (warming) rate of change
return std::min(current_setpoint + max_rate_of_change, target_temp);
} else if (target_temp < current_setpoint) {
// Limit downward (cooling) rate of change
return std::max(current_setpoint - max_rate_of_change, target_temp);
} else {
// No change if the target is equal to the current setpoint
return current_setpoint;
}
update_interval: 10s
filters:
- round: 1
on_value:
then:
- number.set:
id: cold_hs_setpoint
value: !lambda return id(cold_calc).state;
- button.press: submit_cold_sp
# drybulb setpoint °C
- platform: template
name: "Drybulb Set Point"
id: drybulb_celcius
device_class: temperature
unit_of_measurement: "°C"
accuracy_decimals: 2
state_class: measurement
filters:
- round: 2
update_interval: never
# dewpoint setpoint °C
- platform: template
name: "Dewpoint Set Point"
id: dewpoint_celcius
device_class: temperature
unit_of_measurement: "°C"
accuracy_decimals: 2
state_class: measurement
filters:
- round: 2
update_interval: never
#PID Cool Result Dewpoint
- platform: pid
climate_id: pid_dewpoint
name: "Dewpoint Cool Result"
id: dewpoint_cool_result
type: COOL
filters:
- multiply: 0.01
#PID Cool Result Drybulb
- platform: pid
climate_id: pid_drybulb
name: "Drybulb Cool Result"
id: drybulb_cool_result
type: COOL
filters:
- multiply: 0.01
# Dew Point Error (Set Point - Process Variable)
- platform: template
id: dewpoint_error
lambda: |-
float dew_point = id(dewpoint).state;
float set_point = id(dewpoint_celcius).state;
float error = set_point - dew_point;
return error;
update_interval: 10s
on_value_range:
- below: 1.0
then:
- binary_sensor.template.publish:
id: sponge_dry
state: false
- above: 1.0
then:
- binary_sensor.template.publish:
id: sponge_dry
state: true
# Drybulb Error (Set Point - Process Variable)
- platform: template
id: drybulb_error
lambda: |-
float drybulb_temp = id(chamber_temp).state;
float set_point = id(drybulb_celcius).state;
float error = set_point - drybulb_temp;
return error;
update_interval: 10s
# TEC Current Sum
- platform: template
id: tec_current
name: Driver Current
lambda: |-
float driver_a = id(ipropi_a).state;
float driver_b = id(ipropi_b).state;
float sum_of = driver_a + driver_b;
return sum_of;
filters:
- round: 2
update_interval: 60s
# air VPD Calculation
- platform: template
name: "VPD"
id: air_vpd
unit_of_measurement: "kPa"
accuracy_decimals: 1
lambda: |-
float vpd = id(saturated_vapor_pressure).state - id(actual_vapor_pressure).state;
return vpd;
update_interval: 30s
# Saturated Vapor Pressure Calculation
- platform: template
name: "Saturated Vapor Pressure"
id: saturated_vapor_pressure
unit_of_measurement: "kPa"
accuracy_decimals: 3
lambda: |-
const float temperature = id(chamber_temp).state;
if (isnan(temperature)) {
return NAN;
}
const float es = 0.6108 * exp((17.27 * temperature) / (temperature + 237.3));
return es;
update_interval: 30s
# Template sensor for Actual Vapor Pressure (Ea)
- platform: template
name: "Vapor Pressure"
id: actual_vapor_pressure
unit_of_measurement: "kPa"
accuracy_decimals: 3
lambda: |-
const float temperature = id(chamber_temp).state;
const float humidity = id(chamber_rh).state;
if (isnan(temperature) || isnan(humidity)) {
return NAN;
}
const float es = 0.6108 * exp((17.27 * temperature) / (temperature + 237.3));
const float ea = es * (humidity / 100.0);
return ea;
filters:
- round: 3
update_interval: 10s
# Dew Point Temperature Calculation
- platform: template
name: "Dew Point"
id: dewpoint
device_class: temperature
unit_of_measurement: "°C"
accuracy_decimals: 2
state_class: measurement
lambda: |-
float avp = id(actual_vapor_pressure).state;
float avp_log_div = log(avp / 0.6108);
float dew_point = (237.3 * avp_log_div) / (17.27 - avp_log_div);
return dew_point;
filters:
- sliding_window_moving_average:
window_size: 6
send_every: 3
send_first_at: 3
- round: 2
update_interval: 10s
- platform: tmp117
name: "Cold Side Temperature"
id: cold_temp
address: 0x4B
device_class: temperature
unit_of_measurement: "°C"
accuracy_decimals: 2
state_class: measurement
filters:
- round: 2
update_interval: 10s
- platform: tmp117
name: "Hot Side Temperature"
address: 0x48
device_class: temperature
unit_of_measurement: "°C"
accuracy_decimals: 2
state_class: measurement
filters:
- round: 2
update_interval: 60s
- platform: bme280_i2c
address: 0x76
iir_filter: 16x
temperature:
name: "Ambient Temperature"
pressure:
name: "Ambient Pressure"
humidity:
name: "Ambient Humidity"
update_interval: 120s
- platform: sht3xd
temperature:
name: "Probe Temperature"
id: chamber_temp
accuracy_decimals: 2
filters:
- round: 2
humidity:
name: "Probe Humidity"
id: chamber_rh
accuracy_decimals: 2
filters:
- round: 2
address: 0X44
update_interval: 15s
- platform: ads1115
multiplexer: 'A0_GND'
gain: 6.144
id: ipropi_a
resolution: 12 bits
update_interval: 60s
filters:
- lambda: return x / 0.6825;
- platform: ads1115
multiplexer: 'A1_GND'
gain: 6.144
id: ipropi_b
resolution: 12 bits
update_interval: 60s
filters:
- lambda: return x / 0.6825;
- platform: ads1115
multiplexer: 'A2_GND'
gain: 4.096
id: vref_a_in
resolution: 12 bits
update_interval: 60s
- platform: ads1115
multiplexer: 'A3_GND'
gain: 4.096
id: vref_b_in
resolution: 12 bits
update_interval: 60s
# Fan Tach Sensors
# Hot Fan RPM
- platform: pulse_counter
pin:
number: 34
mode:
input: True
name: "Hot Fan RPM"
id: rpm_hot
unit_of_measurement: "RPM"
accuracy_decimals: 0
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
filters:
- multiply: 0.5
- round: 2
update_interval: 1.5min
# Cold Fan RPM
- platform: pulse_counter
pin:
number: 16
mode:
input: True
name: "Cold Fan RPM"
id: rpm_cold
unit_of_measurement: "RPM"
accuracy_decimals: 0
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
filters:
- multiply: 0.5
- round: 2
update_interval: 30s
# Circulation Fan RPM
- platform: pulse_counter
pin:
number: 35
mode:
input: True
name: "Circulation Fan RPM"
id: rpm_circ
unit_of_measurement: "RPM"
accuracy_decimals: 0
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
filters:
- multiply: 0.5
- round: 2
update_interval: 1.5min
# Output Pin Configuration
output:
# tec outpout level
- platform: template
id: tec_output
type: float
write_action:
- number.set:
id: tec_pl_number
value: !lambda return state;
- button.press: set_pwm
# cold side fan
- platform: template
id: cold_fan_compensated_output
type: float
write_action:
- output.set_level:
id: fan_cold
level: !lambda return state;
- sensor.template.publish:
id: cold_fan_speed
state: !lambda return state;
# dewpoint pid output
- platform: template
id: dewpoint_pid_output
type: float
write_action:
- logger.log: "Dewpoint PID Output Changed"
- platform: template
id: dewpoint_pid_heat
type: float
write_action:
- logger.log: "Dewpoint PID Output Changed"
# nSleep
- platform: gpio
pin: GPIO26
id: nsleep_a
- platform: gpio
pin: GPIO18
id: nsleep_b
# pMODE
- platform: gpio
pin: GPIO19
id: p_mode
# DAC
- platform: mcp4728
id: vref_a_out
channel: A
vref: vdd
- platform: mcp4728
id: imode_a
channel: B
vref: internal
gain: X1
- platform: mcp4728
id: vref_b_out
channel: C
vref: vdd
- platform: mcp4728
id: imode_b
channel: D
vref: internal
gain: X1
# TEC Driver PWM channel
- platform: ledc
pin:
number: 13
frequency: 19531Hz
id: pwm_a
- platform: ledc
pin:
number: 33
frequency: 19531Hz
id: pwm_b
# Hot Fan PWM channel
- platform: ledc
pin:
number: 32
frequency: 25000 Hz
id: fan_hot
# Cold Fan PWM channel
- platform: ledc
pin:
number: 25
frequency: 25000 Hz
id: fan_cold
# Circulation Fan PWM channel
- platform: ledc
pin:
number: 17
frequency: 25000 Hz
id: fan_circ
# Heater Output Sigma Delta
- platform: sigma_delta_output
update_interval: 10s
id: heater_output
turn_on_action:
then:
- switch.turn_on: heat
turn_off_action:
then:
- switch.turn_off: heat
# switch config
switch:
# chamber heat
- platform: gpio
pin: GPIO12
name: "Chamber Heat"
id: heat
inverted: true
# °F/°C toggle (on for Fahrenheit)
- platform: template
name: "Use Fahrenheit"
id: use_fahrenheit
icon: "mdi:thermometer"
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
on_turn_on:
- number.set:
id: drybulb_setpoint
value: !lambda |-
return round((id(drybulb_celcius).state * 9/5) + 32);
- number.set:
id: dewpoint_setpoint
value: !lambda |-
return round((id(dewpoint_celcius).state * 9/5) + 32);
- logger.log: "Units changed to °F"
on_turn_off:
- number.set:
id: drybulb_setpoint
value: !lambda |-
return id(drybulb_celcius).state;
- number.set:
id: dewpoint_setpoint
value: !lambda |-
return id(dewpoint_celcius).state;
- logger.log: "Units changed to °C"
button:
# calculate dewpoint set point from relative humidity and temperature # set temperature first
- platform: template
name: "Calculate Dewpoint"
id: calculate_dewpoint
icon: mdi:water-percent
on_press:
then:
- number.set:
id: dewpoint_setpoint
value: !lambda |-
const float temperature = id(drybulb_setpoint).state;
const float humidity = id(rh_setpoint).state;
const float es = 0.6108 * exp((17.27 * temperature) / (temperature + 237.3));
const float avp = es * (humidity / 100.0);
float avp_log_div = log(avp / 0.6108);
float dew_point = (237.3 * avp_log_div) / (17.27 - avp_log_div);
return round(dew_point);
# Send Setpoint to Cold Heatsink PID controller
- platform: template
id: submit_cold_sp
icon: "mdi:emoticon-outline"
on_press:
then:
- climate.control:
id: pid_cold
mode: COOL
target_temperature: !lambda |-
return id(cold_hs_setpoint).state;
# submit setpoint values
- platform: template
name: "Submit Setpoints"
id: submit_values
icon: mdi:check
on_press:
then:
# run script
- script.execute: setpoints_return
- platform: template
id: apply_current_settings
on_press:
then:
- output.set_level:
id: vref_a_out
level: !lambda |-
return (id(pwm_max_current_number).state * 0.0076);
- output.set_level:
id: vref_b_out
level: !lambda |-
return (id(pwm_max_current_number).state * 0.0076);
- platform: template
id: set_pwm
icon: mdi:check
on_press:
then:
- output.set_level:
id: pwm_a
level: !lambda |-
return id(tec_pl_number).state / 2;
- output.set_level:
id: pwm_b
level: !lambda |-
return id(tec_pl_number).state / 2;