-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnspanel_kitchen.yaml
202 lines (164 loc) · 4.14 KB
/
nspanel_kitchen.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
esphome:
name: nsp-kitchen
esp32:
board: esp32dev
wifi:
ssid: !secret wifi-east
password: !secret wifi-pwd
use_address: nsp-kitchen.ak-online.be
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "NSPanel Kitchen Fallback Hotspot"
password: !secret fallback-password
mdns:
disabled: true
time:
- platform: sntp
id: sntp_time
servers:
- 172.16.0.1
api:
mqtt:
broker: mqtt.ak-online.be
discovery: true
topic_prefix: esphome/nsp-kitchen
logger:
ota:
web_server:
port: 80
include_internal: true
uart:
tx_pin: 16
rx_pin: 17
baud_rate: 115200
button:
- platform: restart
name: restart
- platform: template
name: Kitchen Panel Upload TFT file
entity_category: config
on_press:
- lambda: |
id(disp).set_protocol_reparse_mode(false); // Force passive reparse protocol
id(disp)->upload_tft();
display:
- platform: nextion
id: disp
update_interval: 250ms
tft_url: http://172.16.0.253/kitchen.tft
lambda: |-
static int first_run = 1;
auto time = id(sntp_time).now();
// don't do our first run, if the time is not valid yet
if( ! time.is_valid() ) return;
// update when starting and when it's midnight
if( first_run || time.hour == 0 && time.minute == 0 && time.second == 0) {
it.set_component_value("day", time.day_of_month);
it.set_component_text("weekday", time.strftime("%a").c_str());
}
// update only once on the first minute of an hour
if( first_run || time.minute == 0 && time.second == 0 ) it.set_component_value("hour", time.hour);
// update only once every 15sec
if( first_run || time.second % 15 == 0 ) it.set_component_value("minute", time.minute);
// update each interval
it.set_component_value("second", time.second);
// update once a minute
if( first_run || time.second == 0 ) it.set_component_value("temperature", id(temperature).state);
// disable the forced update only needed on first run
first_run = 0;
script:
- id: flip_the_breaker
then:
- switch.turn_off: relay_1
- delay: 2s
- switch.turn_on: relay_1
binary_sensor:
- platform: gpio
id: left_button
pin:
number: 14
inverted: true
on_click:
- if:
condition:
mqtt.connected:
then:
- binary_sensor.template.publish:
id: mainlight_switch
state: ON
else:
- logger.log: "no MQTT, performing relay powercycle"
- script.execute: flip_the_breaker
on_double_click:
- script.execute: flip_the_breaker
- platform: gpio
id: right_button
pin:
number: 27
inverted: true
on_click:
- binary_sensor.template.publish:
id: counter_switch
state: ON
- platform: template
name: Kitchen Main Light Switch
id: mainlight_switch
entity_category: config
lambda: |-
return false;
- platform: template
name: Kitchen Counter Light Switch
id: counter_switch
entity_category: config
lambda: |-
return false;
output:
- platform: ledc
id: buzzer_out
pin:
number: 21
switch:
- platform: gpio
name: Relay 1
id: relay_1
pin:
number: 22
restore_mode: ALWAYS_ON
entity_category: config
- platform: gpio
name: Relay 2
id: relay_2
pin:
number: 19
restore_mode: ALWAYS_ON
entity_category: config
- platform: gpio
name: Kitchen Panel Screen Power
id: screen_power
entity_category: config
pin:
number: 4
inverted: true
restore_mode: ALWAYS_ON
rtttl:
id: buzzer
output: buzzer_out
sensor:
- platform: adc
id: ntc_source
pin: 38
update_interval: 10s
attenuation: 11db
- platform: resistance
id: resistance_sensor
sensor: ntc_source
configuration: DOWNSTREAM
resistor: 11.2kOhm
- platform: ntc
id: temperature
sensor: resistance_sensor
calibration:
b_constant: 3950
reference_temperature: 25°C
reference_resistance: 10kOhm
name: "Kitchen Panel Temperature"