-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchinese-night-heater.yaml
193 lines (169 loc) · 5.29 KB
/
chinese-night-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
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
esphome:
name: chinese-night-heater
friendly_name: chinese-night-heater
includes:
- heater.h
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Chinese-Night-Heater"
password: !secret wifi_password
captive_portal:
uart:
tx_pin: 4
rx_pin: 4
baud_rate: 25000
id: heater_serial
sensor:
- platform: template
id: set_temperature
name: "Set Duty"
unit_of_measurement: ""
lambda: "return {};"
accuracy_decimals: 0
- platform: template
id: mode
name: "Mode"
lambda: "return {};"
accuracy_decimals: 0
- platform: template
id: pump_frequency
name: "Pump Frequency"
unit_of_measurement: "Hz"
lambda: "return {};"
- platform: template
id: fan_speed
name: "Fan Speed"
unit_of_measurement: "RPM"
lambda: "return {};"
accuracy_decimals: 0
- platform: template
id: chamber_temperature
name: "Chamber Temperature"
unit_of_measurement: "°C"
lambda: "return {};"
accuracy_decimals: 0
- platform: template
id: state_int
name: "State (Int)"
lambda: "return {};"
internal: true
accuracy_decimals: 0
- platform: template
id: error_int
name: "Error (Int)"
lambda: "return {};"
accuracy_decimals: 0
internal: true
- platform: template
id: duty_cycle
name: "Duty Cycle"
unit_of_measurement: "%"
lambda: "return {};"
accuracy_decimals: 0
text_sensor:
- platform: template
id: state
name: "State"
update_interval: 5s
lambda: |-
if (id(error_int).state != 0 && id(error_int).state != 1) {
if (id(error_int).state == 0) {
return optional<std::string>("No Error");
} else if (id(error_int).state == 1) {
return optional<std::string>("No Error, but started");
} else if (id(error_int).state == 2) {
return optional<std::string>("Voltage too low");
} else if (id(error_int).state == 3) {
return optional<std::string>("Voltage too high");
} else if (id(error_int).state == 4) {
return optional<std::string>("Ignition plug failure");
} else if (id(error_int).state == 5) {
return optional<std::string>("Pump Failure – over current");
} else if (id(error_int).state == 6) {
return optional<std::string>("Too hot");
} else if (id(error_int).state == 7) {
return optional<std::string>("Motor Failure");
} else if (id(error_int).state == 8) {
return optional<std::string>("Serial connection lost");
} else if (id(error_int).state == 9) {
return optional<std::string>("Gone-Out");
} else if (id(error_int).state == 10) {
return optional<std::string>("Temperature sensor failure");
} else if (id(error_int).state == 11) {
return optional<std::string>("Ignition fail");
} else if (id(error_int).state == 12) {
return optional<std::string>("Failed 1st ignite");
} else if (id(error_int).state == 13) {
return optional<std::string>("Excess fuel usage");
} else {
return optional<std::string>("Unknown");
};
} else {
if (id(state_int).state == 0) {
return optional<std::string>("Off");
} else if (id(state_int).state == 1) {
return optional<std::string>("Starting");
} else if (id(state_int).state == 2) {
return optional<std::string>("Pre-Heat");
} else if (id(state_int).state == 3) {
return optional<std::string>("Failed Start - Retrying");
} else if (id(state_int).state == 4) {
return optional<std::string>("Ignition - Now heating up");
} else if (id(state_int).state == 5) {
return optional<std::string>("Running Normally");
} else if (id(state_int).state == 6) {
return optional<std::string>("Stop Command Received");
} else if (id(state_int).state == 7) {
return optional<std::string>("Stopping");
} else if (id(state_int).state == 8) {
return optional<std::string>("Cooldown");
} else {
return optional<std::string>("Unknown");
}
};
custom_component:
- lambda: |-
auto my_custom = new HeaterUart(id(heater_serial),id(set_temperature),id(state_int),id(error_int),id(mode),id(pump_frequency),id(fan_speed),id(chamber_temperature),id(duty_cycle));
App.register_component(my_custom);
return {my_custom};
button:
- platform: restart
name: Restart
#Buttons have no functinality, WIP
# - platform: template
# name: "Heater On"
# id: heater_on
# icon: "mdi:fire"
# on_press:
# then:
# - switch.turn_on: heater_switch
# - platform: template
# name: "Heater Off"
# id: heater_off
# icon: "mdi:fire-off"
# on_press:
# then:
# - switch.turn_off: heater_switch
#switch:
# - platform: custom
# switches:
# - name: "Heater"
# icon: "mdi:fire"
# id: heater_switch
# internal: true
# lambda: |-
# auto my_switch = new HeaterSwitch(id(heater_serial));
# App.register_component(my_switch);
# return {my_switch};
web_server:
port: 80