-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailbox_cam.yaml
322 lines (268 loc) · 7.25 KB
/
mailbox_cam.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
# -------------------------------------
# ---- Implemented on ESP32-Cam board in Mailbox ----
# -------------------------------------
# 3.33mA in sleep
#https://www.rogerfrost.com/step-3a-esphome-and-esp32-devices/
#https://github.com/esphome/feature-requests/issues/547
#https://community.home-assistant.io/t/deep-sleep-and-multiple-buttons/167214/11
substitutions:
devicename: mailbox-cam
deviceip: !secret ip_mailbox_cam
esphome:
name: ${devicename}
platform: ESP32
board: esp32cam
platformio_options:
board_build.f_cpu: 80000000L # Slow it down to reduce power consumption. Dont go lower as WIFI wont work
wifi:
#power_save_mode: light # power reduced from ?.?w to ?.?w
fast_connect: true
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
hidden: True
manual_ip:
static_ip: !secret ip_mailbox_cam
gateway: !secret ip_gateway
subnet: 255.255.255.0
domain: .homelan
mqtt:
broker: !secret mqtt_host
username: !secret mqtt_username
password: !secret mqtt_password
reboot_timeout: 0s # Dont reboot..
discovery: true
on_message:
- topic: ${devicename}/ota_mode
payload: 'ON'
then:
- deep_sleep.prevent: deep_sleep_1
- topic: ${devicename}/sleep_mode
payload: 'ON'
then:
- deep_sleep.enter: deep_sleep_1
on_json_message:
- topic: ${devicename}/sleep_min # NOTE: This is for the next sleep event ONLY!!
then:
- lambda: |-
int min = x["min"];
id(deep_sleep_1).set_sleep_duration(min * 60 * 1000);
# Enable logging
logger:
# level: WARN
# Dont enable Home Assistant API with deep sleep
#api:
# reboot_timeout: 0s # Dont reboot..
# encryption:
# key: !secret encryption_key
ota:
password: !secret password
web_server:
port: 80
auth:
username: admin
password: !secret password
dallas:
- pin: GPIO14
#Configuration for Ai-Thinker Camera
esp32_camera:
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
name: ${devicename} cam
resolution: 1024X768
esp32_camera_web_server:
- port: 8080
mode: stream
- port: 8081
mode: snapshot
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM 15
#define XCLK_GPIO_NUM 27
#define SIOD_GPIO_NUM 25
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 17
#define VSYNC_GPIO_NUM 22
#define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 21
text_sensor:
- platform: template
name: ${devicename} camera stream
lambda: |-
return {"http://${deviceip}:8080"};
update_interval: 1d
- platform: template
name: ${devicename} camera snapshot
lambda: |-
return {"http://${deviceip}:8081"};
update_interval: 1d
output:
- platform: ledc
pin:
number: GPIO4
# mode: INPUT_PULLUP
channel: 2 # channel 1 is used for esp32_camera
id: led
light:
- platform: monochromatic
output: led
default_transition_length: 0s
name: ${devicename} light
#10k to gnd
sensor:
- platform: wifi_signal
name: ${devicename} wifi signal
update_interval: 60s
# - platform: uptime
# name: ${devicename} uptime
# update_interval: 3s
# - platform: template
# name: ${devicename} wake reason
# accuracy_decimals: 0
# lambda: |-
# return (id(wake_up_reason));
# - platform: template
# name: ${devicename} wake reason2
# lambda: |-
# int GPIO_reason = esp_sleep_get_ext1_wakeup_status();
# return ((log(GPIO_reason))/log(2));
# - platform: template
# name: ${devicename} wake reason3
# lambda: |-
# esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
# return wakeup_reason;
# - platform: template
# name: ${devicename} wake reason4
# accuracy_decimals: 0
# lambda: |-
# return (id(wake_up_reason2));
# 47k to Batt + and 47k to Gnd
- platform: adc
id: batt
pin: GPIO33
name: ${devicename} batt voltage
update_interval: 30s
attenuation: 11db
filters:
- multiply: 2
# - calibrate_linear:
# - 0.0 -> 3.0
# - 100.0 -> 4.2
# Cuts off at 2.8v
- platform: template
name: ${devicename} batt level
unit_of_measurement: '%'
update_interval: 30s
lambda: |-
return (id(batt).state);
filters:
- calibrate_linear:
- 3.5 -> 0.0
- 4.2 -> 100.0
- platform: dallas
address: 0x7b0000000519201d
name: "${devicename} water counter"
accuracy_decimals: 0
unit_of_measurement: "pulses"
icon: "mdi:water"
id: water_pulse
- platform: template
name: "${devicename} water usage"
accuracy_decimals: 3
unit_of_measurement: "litres"
icon: "mdi:water"
lambda: return (id(water_pulse).state / 100);
# Ester V100 water meter
# https://sbs.digital/products/v100-psm-water-meter
# Elster MEB7454 pulse probe
# T110 – Elster Pulse T Probe for V100 (PSM)
#esp32_ext1_wakeup seems to save more energy then wakeup_pin
deep_sleep:
id: deep_sleep_1
run_duration: 40sec
sleep_duration: 45min
#sleep_duration: 45sec
# esp32_ext1_wakeup:
# pins: GPIO2
# mode: ALL_LOW
#binary_sensor:
# - platform: gpio
# pin:
# number: GPIO2
# inverted: True
# mode: INPUT_PULLUP
# name: ${devicename} notification
# device_class: occupancy
# NODE RED
# on wake, take photo, send sleep command, process photo
#GPIO1 TX
#GPIO3 RX
#GPIO0 Cam - clock
#GPIO16 . Input (10k Ohm pull-up)
#GPIO4 Onboard Flashlight LED
#GPIO2 .
#GPIO14 . - TRY counter
#GPIO15 . pinMode(OUTPUT_OPEN_DRAIN, GPIO_NUM_15);
#GPIO13 .
#GPIO12 . pinMode(OUTPUT_OPEN_DRAIN, GPIO_NUM_12);
#GPIO33 ADC for batt voltage
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# This is for if the unit is NOT on battrey and use the ESP as the counter
# - platform: pulse_counter
# pin: GPIO14
# update_interval : 6s
# name: "${devicename} water counter"
# id: water_pulse
# total:
# name: "${devicename} water counter Total"
## unit_of_measurement: "m³"
## id: water_meter_total2
## accuracy_decimals: 3
# device_class: water
# state_class: total_increasing
# - platform: template
# name: "${devicename} water Usage Litre"
# id: water_flow_rate
# accuracy_decimals: 1
# unit_of_measurement: "l/min"
# icon: "mdi:water"
# lambda: return (id(water_pulse).state * 10);
# update_interval: 6s
# Doesnt work for some reason?????
# - platform: pulse_meter
# pin: GPIO14
# name: "${devicename} water meterzz"
# unit_of_measurement: "litre/min"
# icon: "mdi:water"
# internal_filter: 100ms
# accuracy_decimals: 3
# filters:
# - multiply: 1.001
# total:
# name: "${devicename} water meter Totalzz"
# unit_of_measurement: "m³"
# id: water_meter_total
# accuracy_decimals: 3
# device_class: water
# state_class: total_increasing
## filters:
## - multiply: 0.001
## on_value:
## then:
## - light.toggle: stat_led