mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
Vehicle beacons: LED dark except a boot blink and while the gate's home beacon is seen, Wi-Fi + OTA on a 3 s button hold, 9 dBm, esp32_ble without the empty advertisement; gate: own home beacon, scan window 160/320 ms
This commit is contained in:
1 parent
6591b47c01
commit
0da0cd1544
7 files changed
+114
-101
No files matched your search
+90
-83
@@ -1,14 +1,7 @@
|
||||
esp32:
|
||||
variant: esp32
|
||||
toolchain: esp-idf
|
||||
framework:
|
||||
advanced:
|
||||
flash_chip: gd # ESP32-PICO-D4, like every other ATOM Lite
|
||||
type: esp-idf
|
||||
|
||||
external_components:
|
||||
- source: components
|
||||
|
||||
# Vehicle iBeacon on an M5Stack ATOM Lite: BLE only, Wi-Fi + OTA by holding the button.
|
||||
# LED: short blue blink at boot, then dark; blue while the home beacon (mcu-gate) is seen;
|
||||
# green while Wi-Fi is on.
|
||||
#
|
||||
# PINOUTS: M5ATOM
|
||||
# IR G12
|
||||
# NEO G27
|
||||
@@ -24,85 +17,99 @@ external_components:
|
||||
# 1-WIRE G22
|
||||
# NC G19
|
||||
|
||||
esp32:
|
||||
variant: esp32
|
||||
toolchain: esp-idf
|
||||
framework:
|
||||
advanced:
|
||||
flash_chip: gd # ESP32-PICO-D4, like every other ATOM Lite
|
||||
type: esp-idf
|
||||
|
||||
# iBeacon on air from boot without the empty standard advertisement every 10 s
|
||||
external_components:
|
||||
- source: github://randybb/esphome-components
|
||||
components: [esp32_ble]
|
||||
|
||||
packages:
|
||||
wifi: !include wifi.yaml
|
||||
|
||||
esphome:
|
||||
on_loop:
|
||||
on_boot:
|
||||
then:
|
||||
lambda: |-
|
||||
static uint32_t last_state = 0;
|
||||
auto state = App.get_app_state();
|
||||
if (state != last_state) {
|
||||
if (state & STATUS_LED_ERROR) {
|
||||
auto call = id(led).turn_on();
|
||||
call.set_effect("ERROR");
|
||||
call.perform();
|
||||
} else if (state & STATUS_LED_WARNING) {
|
||||
auto call = id(led).turn_on();
|
||||
call.set_effect("BOOT");
|
||||
call.perform();
|
||||
} else {
|
||||
auto call = id(led).turn_on();
|
||||
call.set_effect("BEACON");
|
||||
call.perform();
|
||||
}
|
||||
last_state = state;
|
||||
}
|
||||
- light.turn_on:
|
||||
id: led
|
||||
red: 0%
|
||||
green: 0%
|
||||
blue: 50%
|
||||
transition_length: 0s
|
||||
- delay: 300ms
|
||||
- light.turn_off:
|
||||
id: led
|
||||
transition_length: 0s
|
||||
|
||||
wifi:
|
||||
enable_on_boot: false
|
||||
|
||||
# flashed over USB straight to encrypted OTA, no password migration needed
|
||||
ota:
|
||||
- platform: esphome
|
||||
encryption:
|
||||
key: !secret api_key
|
||||
|
||||
esp32_ble_tracker:
|
||||
scan_parameters:
|
||||
active: false
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
id: button
|
||||
pin:
|
||||
number: 39
|
||||
inverted: true
|
||||
on_press:
|
||||
- delay: 3s
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: button
|
||||
then:
|
||||
- wifi.enable:
|
||||
- light.turn_on:
|
||||
id: led
|
||||
red: 0%
|
||||
green: 50%
|
||||
blue: 0%
|
||||
transition_length: 0s
|
||||
- platform: ble_presence
|
||||
id: home
|
||||
ibeacon_uuid: !secret ble_beacon_gate_uuid
|
||||
timeout: 1min
|
||||
on_press:
|
||||
- if:
|
||||
condition:
|
||||
not:
|
||||
wifi.enabled:
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: led
|
||||
red: 0%
|
||||
green: 0%
|
||||
blue: 50%
|
||||
transition_length: 0s
|
||||
on_release:
|
||||
- if:
|
||||
condition:
|
||||
not:
|
||||
wifi.enabled:
|
||||
then:
|
||||
- light.turn_off:
|
||||
id: led
|
||||
transition_length: 0s
|
||||
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
name: LED
|
||||
id: led
|
||||
rgb_order: GRB
|
||||
channel_colors: GRB
|
||||
pin: 27
|
||||
num_leds: 1
|
||||
chipset: ws2812
|
||||
restore_mode: ALWAYS_OFF
|
||||
effects:
|
||||
- strobe:
|
||||
name: "BEACON"
|
||||
colors:
|
||||
- state: true
|
||||
red: 0%
|
||||
green: 0%
|
||||
blue: 50%
|
||||
duration: 200ms
|
||||
- state: false
|
||||
duration: 200ms
|
||||
- state: true
|
||||
red: 0%
|
||||
green: 0%
|
||||
blue: 50%
|
||||
duration: 200ms
|
||||
- state: false
|
||||
duration: 10s
|
||||
- lambda:
|
||||
name: "ERROR"
|
||||
update_interval: 0.5s
|
||||
lambda: |-
|
||||
static bool state = false;
|
||||
auto call = id(led).turn_on();
|
||||
call.set_transition_length(500);
|
||||
call.set_rgb(1, 0, 0);
|
||||
if (!state) {
|
||||
call.set_brightness(1);
|
||||
} else {
|
||||
// If using 0, it freaks Home Assistant UI.
|
||||
call.set_brightness(0.01);
|
||||
}
|
||||
call.perform();
|
||||
state = !state;
|
||||
- lambda:
|
||||
name: "BOOT"
|
||||
update_interval: 0.5s
|
||||
lambda: |-
|
||||
static bool state = false;
|
||||
auto call = id(led).turn_on();
|
||||
call.set_transition_length(500);
|
||||
call.set_rgb(0, 1, 0);
|
||||
if (!state) {
|
||||
call.set_brightness(1);
|
||||
} else {
|
||||
// If using 0, it freaks Home Assistant UI.
|
||||
call.set_brightness(0.01);
|
||||
}
|
||||
call.perform();
|
||||
state = !state;
|
||||
Reference in new issue
Block a user