-
Notifications
You must be signed in to change notification settings - Fork 0
/
battery-powered-keypad.yaml
150 lines (149 loc) · 3.24 KB
/
battery-powered-keypad.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
esphome:
# Battery powered version. This uses deepsleep and sends the wake reason (button press) in a sensor to HA.
# Only supports single click, no double click, hold, etc like the USB powered version.
name: dev-esp32
on_boot:
- priority: 900
then:
- lambda: |-
id(wake_up_reason) = esp_sleep_get_ext1_wakeup_status();
- wait_until:
condition:
api.connected
timeout: 60s
- priority: 900
then:
- lambda: esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
esp32:
board: esp-wrover-kit #or whatever your board is
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Dev-Esp32 Fallback Hotspot"
password: !secret hotspot_password
captive_portal:
sensor:
- platform: template
id: wakereasonsensor
name: "Wake Reason"
accuracy_decimals: 0
lambda: |-
return id(wake_up_reason);
#sleepstart: GPIO26
#sleepstop: GPIO33
#tummytimestart: GPIO25
#tummytimestop: GPIO32
#feedingstart: GPIO27
#feedingstop: GPIO14
#diaperwet: GPIO12
#diapersolid: GPIO13
binary_sensor:
- platform: gpio
pin:
number: GPIO26
mode:
input: true
pulldown: true
id: sleepstart
name: Sleep Start
- platform: gpio
pin:
number: GPIO33
mode:
input: true
pulldown: true
id: sleepstop
name: Sleep Stop
- platform: gpio
pin:
number: GPIO25
mode:
input: true
pulldown: true
id: tummytimestart
name: Tummy Time Start
- platform: gpio
pin:
number: GPIO32
mode:
input: true
pulldown: true
id: tummytimestop
name: Tummy Time Stop
- platform: gpio
pin:
number: GPIO27
mode:
input: true
pulldown: true
id: feedingstart
name: Feeding Start
- platform: gpio
pin:
number: GPIO14
mode:
input: true
pulldown: true
id: feedingstop
name: Feeding Stop
- platform: gpio
pin:
number: GPIO12
mode:
input: true
pulldown: true
id: diaperwet
name: Diaper Wet
- platform: gpio
pin:
number: GPIO1
mode:
input: true
pulldown: true
id: diapersolid
name: Diaper Solid
deep_sleep:
id: deep_sleep_1
run_duration: 10s #10s
sleep_duration:
days: 1
esp32_ext1_wakeup:
pins:
- number: GPIO12
- number: GPIO13
- number: GPIO14
- number: GPIO25
- number: GPIO26
- number: GPIO27
- number: GPIO32
- number: GPIO33
mode: ANY_HIGH
globals:
- id: wake_up_reason
type: int #or uint64_t if your board requires it
restore_value: no
initial_value: '0'
mqtt:
broker: 192.168.1.88
username: !secret mqttuser
password: !secret mqttpassword
on_message:
- topic: babybuttonpanel/ota_mode
payload: 'ON'
then:
- deep_sleep.prevent: deep_sleep_1
- topic: babybuttonpanel/sleep_mode
payload: 'ON'
then:
- deep_sleep.enter: deep_sleep_1