-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp32-test
195 lines (165 loc) · 6.23 KB
/
esp32-test
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
esphome:
name: esp32-test
friendly_name: Pellet Controller Fan test
esp32:
board: esp32dev # Hiletgo esp32-DevKitc-32 esp-32d esp-32 cp2012 usbc board
framework:
type: arduino
api:
ota:
platform: esphome
logger:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
manual_ip:
static_ip: 192.168.2.21
gateway: 192.168.2.1
subnet: 255.255.255.0
web_server:
version: 3
port: 80
captive_portal:
output:
- platform: ac_dimmer
id: pellet_fan_dimmer
gate_pin: GPIO16
zero_cross_pin:
number: GPIO19
method: LEADING
min_power: 42% # Minimum power level set to 42%
one_wire:
- platform: gpio
pin: GPIO4
sensor:
- platform: dallas_temp # DS18b20 3 pin wire digital thermometer
address: 0xc00000004421a328
id: dallastemp3
name: "stove fan temperature"
icon: "mdi:thermometer"
device_class: "temperature"
unit_of_measurement: "°C"
accuracy_decimals: 2
update_interval: 60s # Updated interval to 60 seconds
- platform: template
name: "Fan Speed"
id: fan_speed
unit_of_measurement: "%"
accuracy_decimals: 0
text_sensor:
- platform: template
name: "Fan Speed Level"
id: fan_speed_level
- platform: template
name: "Fan Status"
id: fan_status
select:
- platform: template
name: "Fan Speed Level"
id: fan_speed_select
options:
- "Off"
- "Low"
- "Medium-Low"
- "Medium"
- "Medium-High"
- "High"
optimistic: true
initial_option: "Off"
set_action:
- lambda: |-
if (x == "Off") {
id(pellet_fan_dimmer).set_level(0.0);
id(fan_status).publish_state("Off");
id(fan_speed).publish_state(0);
id(fan_speed_level).publish_state("Off");
} else if (x == "Low") {
id(pellet_fan_dimmer).set_level(0.35); // Updated speed level 1 to 0.35
id(fan_status).publish_state("On");
id(fan_speed).publish_state(35); // Adjusted percentage to match the level
id(fan_speed_level).publish_state("Low");
} else if (x == "Medium-Low") {
id(pellet_fan_dimmer).set_level(0.4);
id(fan_status).publish_state("On");
id(fan_speed).publish_state(40);
id(fan_speed_level).publish_state("Medium-Low");
} else if (x == "Medium") {
id(pellet_fan_dimmer).set_level(0.5); // Updated speed level 3 to 0.5
id(fan_status).publish_state("On");
id(fan_speed).publish_state(50); // Adjusted percentage to match the level
id(fan_speed_level).publish_state("Medium");
} else if (x == "Medium-High") {
id(pellet_fan_dimmer).set_level(0.7); // Updated speed level 4 to 0.7
id(fan_status).publish_state("On");
id(fan_speed).publish_state(70); // Adjusted percentage to match the level
id(fan_speed_level).publish_state("Medium-High");
} else if (x == "High") {
id(pellet_fan_dimmer).set_level(1.0);
id(fan_status).publish_state("On");
id(fan_speed).publish_state(100);
id(fan_speed_level).publish_state("High");
}
# Temperature ranges and Fan on or off controlled with Lambda below
# Adjust fan speed with set_level(0.35) = 35% to fine-tune fan speed percentage at each 1 to 5 step. Level 1 would be 35%
# Match the fan speed set action for set level and published % state in the above lambda "Low", "Medium-Low" etc. to the settings below
interval:
- interval: 31s
then:
- lambda: |-
float temp = id(dallastemp3).state;
if (temp < 31.5) { // Off state for when stove is cooling down shut off at 31.5
id(pellet_fan_dimmer).set_level(0.0);
id(fan_status).publish_state("Off");
id(fan_speed).publish_state(0);
id(fan_speed_level).publish_state("Off");
// When STOVE is starting up and running, fan will turn on and run on low (35%) at above 33 then increase speeds with temperature ranges
} else if (temp >= 33 && temp <= 36) {
id(pellet_fan_dimmer).set_level(0.35); // Updated speed level 1 to 0.35
id(fan_status).publish_state("On");
id(fan_speed).publish_state(35); // Adjusted percentage to match the level
id(fan_speed_level).publish_state("Low");
} else if (temp > 36 && temp <= 45) {
id(pellet_fan_dimmer).set_level(0.4);
id(fan_status).publish_state("On");
id(fan_speed).publish_state(40);
id(fan_speed_level).publish_state("Medium-Low");
} else if (temp > 45 && temp <= 50) {
id(pellet_fan_dimmer).set_level(0.5); // Updated speed level 3 to 0.5
id(fan_status).publish_state("On");
id(fan_speed).publish_state(50); // Adjusted percentage to match the level
id(fan_speed_level).publish_state("Medium");
} else if (temp > 50 && temp <= 60) {
id(pellet_fan_dimmer).set_level(0.7); // Updated speed level 4 to 0.7
id(fan_status).publish_state("On");
id(fan_speed).publish_state(70); // Adjusted percentage to match the level
id(fan_speed_level).publish_state("Medium-High");
} else if (temp > 60) {
id(pellet_fan_dimmer).set_level(1.0);
id(fan_status).publish_state("On");
id(fan_speed).publish_state(100);
id(fan_speed_level).publish_state("High");
}
- interval: 8h # Run this every 8 hours
then:
- if:
condition:
binary_sensor.is_on: fan_off_10_min
then:
- logger.log: "Fan has been off for 10 minutes. Rebooting device."
- delay: 5s # Short delay before rebooting
- switch.turn_on: restart_switch
# Create a binary sensor to track if the fan has been off for at least 10 minutes
binary_sensor:
- platform: template
name: "Fan Off for 10 Minutes"
id: fan_off_10_min
lambda: |-
return id(fan_status).state == "Off";
filters:
- delayed_on: 600s # 10 minutes
# Switch to trigger a reboot
switch:
- platform: restart
name: "Restart Switch"
id: restart_switch