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
CI / YAML lint (push) Successful in 7s
CI / ESPHome config validation (push) Successful in 1m3s

This commit is contained in:
randy committed 2026-12-04 00:53:07 +01:00
1 parent 6591b47c01
commit 0da0cd1544
7 files changed
+114 -101

No files matched your search

+90 -83
View File
@@ -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;
+17
View File
@@ -34,6 +34,11 @@ esp32:
flash_chip: gd
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:
common: !include common/common.yaml
ipv6_only: !include common/ipv6_only.yaml
@@ -107,8 +112,20 @@ globals:
esp32_ble_tracker:
id: ${device}_ble_tracker
# window 160/320 ms (default 30): hears the vehicle beacons sooner, half the airtime stays for Wi-Fi
scan_parameters:
duration: 1min
interval: 320ms
window: 160ms
active: false
# home beacon: the vehicles light their LED while they see it
esp32_ble_beacon:
type: iBeacon
uuid: !secret ble_beacon_gate_uuid
min_interval: 1s
max_interval: 1s
tx_power: 9dBm
binary_sensor:
- platform: ble_presence
+1
View File
@@ -22,3 +22,4 @@ esp32_ble_beacon:
uuid: !secret ble_beacon_honda_uuid
major: !secret ble_beacon_honda_major
minor: !secret ble_beacon_honda_minor
tx_power: 9dBm
+1
View File
@@ -22,3 +22,4 @@ esp32_ble_beacon:
uuid: !secret ble_beacon_suzuki_uuid
major: !secret ble_beacon_suzuki_major
minor: !secret ble_beacon_suzuki_minor
tx_power: 9dBm
+1 -16
View File
@@ -12,29 +12,14 @@ esphome:
friendly_name: ${name}
area: ${area}
comment: ${comment}
on_boot:
then:
- if:
condition:
- binary_sensor.is_off: button
then:
- wifi.disable:
packages:
base: !include common/vehicle_base.yaml
wifi: !include common/wifi.yaml
logger: !include common/logger.yaml
ota: !include common/ota.yaml
binary_sensor:
- platform: gpio
id: button
filters:
- invert:
pin: 39
esp32_ble_beacon:
type: iBeacon
uuid: !secret ble_beacon_toyota_auris_uuid
major: !secret ble_beacon_toyota_auris_major
minor: !secret ble_beacon_toyota_auris_minor
tx_power: 9dBm
+1
View File
@@ -22,3 +22,4 @@ esp32_ble_beacon:
uuid: !secret ble_beacon_toyota_yaris_uuid
major: !secret ble_beacon_toyota_yaris_major
minor: !secret ble_beacon_toyota_yaris_minor
tx_power: 9dBm
+3 -2
View File
@@ -31,8 +31,9 @@ ble_beacon_toyota_auris_uuid: "00000000-0000-0000-0000-000000000000"
ble_beacon_toyota_auris_major: 10167
ble_beacon_toyota_auris_minor: 61958
ble_beacon_toyota_yaris_uuid: "00000000-0000-0000-0000-000000000000"
ble_beacon_toyota_yaris_honda_major: 10167
ble_beacon_toyota_yaris_honda_minor: 61958
ble_beacon_toyota_yaris_major: 10167
ble_beacon_toyota_yaris_minor: 61958
ble_beacon_gate_uuid: "00000000-0000-0000-0000-000000000000"
# Thread active dataset (hex TLV) from Home Assistant
thread_tlv: "0E080000000000010000"