Skip to content

Commit 1c476b5

Browse files
Merge pull request #5 from ApolloAutomation/8mb
Production Ready
2 parents de83812 + e2a38ab commit 1c476b5

File tree

2 files changed

+76
-90
lines changed

2 files changed

+76
-90
lines changed

Integrations/ESPHome/BTN-1.yaml

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -121,63 +121,52 @@ api:
121121
122122
// Trigger the corresponding binary sensor
123123
if (wake_button == "1") {
124-
id(button_1).publish_state(true);
124+
id(button_1_event).trigger("Single Click");
125125
} else if (wake_button == "2") {
126-
id(button_2).publish_state(true);
126+
id(button_2_event).trigger("Single Click");
127127
} else if (wake_button == "3") {
128-
id(button_3).publish_state(true);
128+
id(button_3_event).trigger("Single Click");
129129
} else if (wake_button == "4") {
130-
id(button_4).publish_state(true);
130+
id(button_4_event).trigger("Single Click");
131131
}
132-
}
133-
- delay: 1s
134-
- lambda: |-
135-
// Get which button woke up the device again
136-
std::string wake_button = id(wakeup_button_pressed).state;
137-
138-
if (wake_button != "0" && wake_button != "") {
139-
// Release the corresponding binary sensor
140-
if (wake_button == "1") {
141-
id(button_1).publish_state(false);
142-
} else if (wake_button == "2") {
143-
id(button_2).publish_state(false);
144-
} else if (wake_button == "3") {
145-
id(button_3).publish_state(false);
146-
} else if (wake_button == "4") {
147-
id(button_4).publish_state(false);
148-
}
149-
150-
// Reset the wake button sensor to "0"
151132
id(wakeup_button_pressed).publish_state("0");
152133
}
134+
135+
# Send Wake up Button State
153136
- component.update: wakeup_button_pressed
154-
- delay: 1s
137+
138+
# Check OTA Switch
139+
- delay: 3s
155140
- if:
156141
condition:
157142
or:
158143
- binary_sensor.is_on: ota_mode
159144
- switch.is_on: prevent_sleep
160145
then:
161-
- lambda: |-
146+
- lambda: |-
162147
ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA Or Switch");
163-
id(deep_sleep_1).prevent_deep_sleep();
164-
else:
165-
- delay: 10s
148+
id(deep_sleep_1).prevent_deep_sleep();
149+
else:
150+
- lambda: |-
151+
id(reportAllValues).execute();
152+
- delay: 2s
166153
- deep_sleep.enter:
167154
id: deep_sleep_1
168155

169156
external_components:
170157
- source: github://ApolloAutomation/ExternalComponents
171158
components: [deep_sleep]
159+
- source: github://ApolloAutomation/esphome-battery-component
160+
components: [max17048] #Forked OptionZero
172161

173162
dashboard_import:
174163
package_import_url: github://ApolloAutomation/BTN-1/Integrations/ESPHome/BTN-1.yaml
175164
import_full_config: false
176165

177-
#improv_serial:
166+
improv_serial:
178167

179-
#esp32_improv:
180-
# authorizer: none
168+
esp32_improv:
169+
authorizer: none
181170

182171
ota:
183172
- platform: esphome
@@ -194,14 +183,14 @@ update:
194183
- platform: http_request
195184
id: firmware_update
196185
name: Firmware Update
197-
source: https://apolloautomation.github.io/BTN-1/artifact/manifest.json
186+
source: https://apolloautomation.github.io/BTN-1/firmware/manifest.json
198187

199188
wifi:
200-
# on_connect:
201-
# - delay: 5s
202-
# - ble.disable:
203-
# on_disconnect:
204-
# - ble.enable:
189+
on_connect:
190+
- delay: 5s
191+
- ble.disable:
192+
on_disconnect:
193+
- ble.enable:
205194
ap:
206195
ssid: "Apollo BTN1 Hotspot"
207196

Integrations/ESPHome/Core.yaml

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,24 @@
11
substitutions:
22
name: apollo-btn-1
3-
version: "25.6.1.3"
3+
version: "25.8.21.1"
44
device_description: ${name} made by Apollo Automation - version ${version}.
55

66
esp32:
77
board: esp32-c6-devkitm-1
88
variant: esp32c6
9-
flash_size: 4MB
9+
flash_size: 8MB
1010
framework:
1111
type: esp-idf
1212

1313
api:
14+
id: api_server
1415
services:
1516
- service: play_buzzer
1617
variables:
1718
song_str: string
1819
then:
1920
- rtttl.play:
2021
rtttl: !lambda 'return song_str;'
21-
reboot_timeout: 0s
22-
on_client_connected:
23-
then:
24-
- delay: 5s
25-
- if:
26-
condition:
27-
or:
28-
- binary_sensor.is_on: ota_mode
29-
- switch.is_on: prevent_sleep
30-
then:
31-
- lambda: |-
32-
ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA Or Switch");
33-
id(deep_sleep_1).prevent_deep_sleep();
34-
else:
35-
- lambda: |-
36-
id(reportAllValues).execute();
37-
- delay: 2s
38-
- deep_sleep.enter:
39-
id: deep_sleep_1
4022

4123
globals:
4224
- id: cycleCounter
@@ -49,11 +31,14 @@ globals:
4931
initial_value: '0'
5032

5133
captive_portal:
34+
id: captive_portal_instance
5235

5336
web_server:
37+
id: web_server_instance
5438
port: 80
5539

5640
i2c:
41+
id: i2c_bus
5742
sda: GPIO1
5843
scl: GPIO0
5944

@@ -199,27 +184,27 @@ binary_sensor:
199184
- ON for at most 300ms
200185
- OFF for at least 0.5s
201186
then:
202-
- event.trigger:
203-
id: button_1_event
204-
event_type: Single Click
187+
- event.trigger:
188+
id: button_1_event
189+
event_type: Single Click
205190

206191
- timing:
207192
- ON for at most 300ms
208193
- OFF for at most 0.5s
209194
- ON for at most 300ms
210195
- OFF for at least 0.2s
211196
then:
212-
- event.trigger:
213-
id: button_1_event
214-
event_type: Double Click
197+
- event.trigger:
198+
id: button_1_event
199+
event_type: Double Click
215200

216201
- timing:
217202
- ON for 1s to 5s
218203
- OFF for at least 0.5s
219204
then:
220-
- event.trigger:
221-
id: button_1_event
222-
event_type: Long Press
205+
- event.trigger:
206+
id: button_1_event
207+
event_type: Long Press
223208

224209
- platform: gpio
225210
id: button_2
@@ -236,27 +221,27 @@ binary_sensor:
236221
- ON for at most 300ms
237222
- OFF for at least 0.5s
238223
then:
239-
- event.trigger:
240-
id: button_2_event
241-
event_type: Single Click
224+
- event.trigger:
225+
id: button_2_event
226+
event_type: Single Click
242227

243228
- timing:
244229
- ON for at most 300ms
245230
- OFF for at most 0.5s
246231
- ON for at most 300ms
247232
- OFF for at least 0.2s
248233
then:
249-
- event.trigger:
250-
id: button_2_event
251-
event_type: Double Click
234+
- event.trigger:
235+
id: button_2_event
236+
event_type: Double Click
252237

253238
- timing:
254239
- ON for 1s to 5s
255240
- OFF for at least 0.5s
256241
then:
257-
- event.trigger:
258-
id: button_2_event
259-
event_type: Long Press
242+
- event.trigger:
243+
id: button_2_event
244+
event_type: Long Press
260245

261246
- platform: gpio
262247
id: button_3
@@ -275,27 +260,27 @@ binary_sensor:
275260
- ON for at most 300ms
276261
- OFF for at least 0.5s
277262
then:
278-
- event.trigger:
279-
id: button_3_event
280-
event_type: Single Click
263+
- event.trigger:
264+
id: button_3_event
265+
event_type: Single Click
281266

282267
- timing:
283268
- ON for at most 300ms
284269
- OFF for at most 0.5s
285270
- ON for at most 300ms
286271
- OFF for at least 0.2s
287272
then:
288-
- event.trigger:
289-
id: button_3_event
290-
event_type: Double Click
273+
- event.trigger:
274+
id: button_3_event
275+
event_type: Double Click
291276

292277
- timing:
293278
- ON for 1s to 5s
294279
- OFF for at least 0.5s
295280
then:
296-
- event.trigger:
297-
id: button_3_event
298-
event_type: Long Press
281+
- event.trigger:
282+
id: button_3_event
283+
event_type: Long Press
299284

300285
- platform: gpio
301286
id: button_4
@@ -369,6 +354,19 @@ sensor:
369354
update_interval: 60s
370355
entity_category: "diagnostic"
371356

357+
- platform: max17048
358+
id: max_17048
359+
battery_voltage:
360+
name: Battery voltage
361+
id: batt_v
362+
battery_level:
363+
name: Battery level
364+
id: batt_pct
365+
filters:
366+
- lambda: |
367+
if (x > 100) return 100;
368+
else return (x);
369+
372370
switch:
373371
- platform: template
374372
name: "Prevent Sleep"
@@ -407,12 +405,11 @@ switch:
407405
setup_priority: 2000
408406
internal: true
409407

410-
# LED Configuration - Using monochromatic light since we have single GPIO
411408
light:
412409
- platform: partition
413410
name: "BTN 1 Light"
411+
default_transition_length: 0s
414412
segments:
415-
# Use first 10 LEDs from the light with ID light1
416413
- id: rgb_light
417414
from: 0
418415
to: 0
@@ -431,8 +428,8 @@ light:
431428
max_brightness: 100%
432429
- platform: partition
433430
name: "BTN 2 Light"
431+
default_transition_length: 0s
434432
segments:
435-
# Use first 10 LEDs from the light with ID light1
436433
- id: rgb_light
437434
from: 1
438435
to: 1
@@ -451,8 +448,8 @@ light:
451448
max_brightness: 100%
452449
- platform: partition
453450
name: "BTN 3 Light"
451+
default_transition_length: 0s
454452
segments:
455-
# Use first 10 LEDs from the light with ID light1
456453
- id: rgb_light
457454
from: 2
458455
to: 2
@@ -471,8 +468,8 @@ light:
471468
max_brightness: 100%
472469
- platform: partition
473470
name: "BTN 4 Light"
471+
default_transition_length: 0s
474472
segments:
475-
# Use first 10 LEDs from the light with ID light1
476473
- id: rgb_light
477474
from: 3
478475
to: 3

0 commit comments

Comments
 (0)