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:
|
# Vehicle iBeacon on an M5Stack ATOM Lite: BLE only, Wi-Fi + OTA by holding the button.
|
||||||
variant: esp32
|
# LED: short blue blink at boot, then dark; blue while the home beacon (mcu-gate) is seen;
|
||||||
toolchain: esp-idf
|
# green while Wi-Fi is on.
|
||||||
framework:
|
#
|
||||||
advanced:
|
|
||||||
flash_chip: gd # ESP32-PICO-D4, like every other ATOM Lite
|
|
||||||
type: esp-idf
|
|
||||||
|
|
||||||
external_components:
|
|
||||||
- source: components
|
|
||||||
|
|
||||||
# PINOUTS: M5ATOM
|
# PINOUTS: M5ATOM
|
||||||
# IR G12
|
# IR G12
|
||||||
# NEO G27
|
# NEO G27
|
||||||
@@ -24,85 +17,99 @@ external_components:
|
|||||||
# 1-WIRE G22
|
# 1-WIRE G22
|
||||||
# NC G19
|
# 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:
|
esphome:
|
||||||
on_loop:
|
on_boot:
|
||||||
then:
|
then:
|
||||||
lambda: |-
|
- light.turn_on:
|
||||||
static uint32_t last_state = 0;
|
id: led
|
||||||
auto state = App.get_app_state();
|
red: 0%
|
||||||
if (state != last_state) {
|
green: 0%
|
||||||
if (state & STATUS_LED_ERROR) {
|
blue: 50%
|
||||||
auto call = id(led).turn_on();
|
transition_length: 0s
|
||||||
call.set_effect("ERROR");
|
- delay: 300ms
|
||||||
call.perform();
|
- light.turn_off:
|
||||||
} else if (state & STATUS_LED_WARNING) {
|
id: led
|
||||||
auto call = id(led).turn_on();
|
transition_length: 0s
|
||||||
call.set_effect("BOOT");
|
|
||||||
call.perform();
|
wifi:
|
||||||
} else {
|
enable_on_boot: false
|
||||||
auto call = id(led).turn_on();
|
|
||||||
call.set_effect("BEACON");
|
# flashed over USB straight to encrypted OTA, no password migration needed
|
||||||
call.perform();
|
ota:
|
||||||
}
|
- platform: esphome
|
||||||
last_state = state;
|
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:
|
light:
|
||||||
- platform: esp32_rmt_led_strip
|
- platform: esp32_rmt_led_strip
|
||||||
name: LED
|
|
||||||
id: led
|
id: led
|
||||||
rgb_order: GRB
|
channel_colors: GRB
|
||||||
pin: 27
|
pin: 27
|
||||||
num_leds: 1
|
num_leds: 1
|
||||||
chipset: ws2812
|
chipset: ws2812
|
||||||
restore_mode: ALWAYS_OFF
|
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;
|
|
||||||
@@ -34,6 +34,11 @@ esp32:
|
|||||||
flash_chip: gd
|
flash_chip: gd
|
||||||
type: esp-idf
|
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:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
ipv6_only: !include common/ipv6_only.yaml
|
ipv6_only: !include common/ipv6_only.yaml
|
||||||
@@ -107,8 +112,20 @@ globals:
|
|||||||
|
|
||||||
esp32_ble_tracker:
|
esp32_ble_tracker:
|
||||||
id: ${device}_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:
|
scan_parameters:
|
||||||
duration: 1min
|
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:
|
binary_sensor:
|
||||||
- platform: ble_presence
|
- platform: ble_presence
|
||||||
|
|||||||
@@ -22,3 +22,4 @@ esp32_ble_beacon:
|
|||||||
uuid: !secret ble_beacon_honda_uuid
|
uuid: !secret ble_beacon_honda_uuid
|
||||||
major: !secret ble_beacon_honda_major
|
major: !secret ble_beacon_honda_major
|
||||||
minor: !secret ble_beacon_honda_minor
|
minor: !secret ble_beacon_honda_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -22,3 +22,4 @@ esp32_ble_beacon:
|
|||||||
uuid: !secret ble_beacon_suzuki_uuid
|
uuid: !secret ble_beacon_suzuki_uuid
|
||||||
major: !secret ble_beacon_suzuki_major
|
major: !secret ble_beacon_suzuki_major
|
||||||
minor: !secret ble_beacon_suzuki_minor
|
minor: !secret ble_beacon_suzuki_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -12,29 +12,14 @@ esphome:
|
|||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
on_boot:
|
|
||||||
then:
|
|
||||||
- if:
|
|
||||||
condition:
|
|
||||||
- binary_sensor.is_off: button
|
|
||||||
then:
|
|
||||||
- wifi.disable:
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
base: !include common/vehicle_base.yaml
|
base: !include common/vehicle_base.yaml
|
||||||
wifi: !include common/wifi.yaml
|
|
||||||
logger: !include common/logger.yaml
|
logger: !include common/logger.yaml
|
||||||
ota: !include common/ota.yaml
|
|
||||||
|
|
||||||
binary_sensor:
|
|
||||||
- platform: gpio
|
|
||||||
id: button
|
|
||||||
filters:
|
|
||||||
- invert:
|
|
||||||
pin: 39
|
|
||||||
|
|
||||||
esp32_ble_beacon:
|
esp32_ble_beacon:
|
||||||
type: iBeacon
|
type: iBeacon
|
||||||
uuid: !secret ble_beacon_toyota_auris_uuid
|
uuid: !secret ble_beacon_toyota_auris_uuid
|
||||||
major: !secret ble_beacon_toyota_auris_major
|
major: !secret ble_beacon_toyota_auris_major
|
||||||
minor: !secret ble_beacon_toyota_auris_minor
|
minor: !secret ble_beacon_toyota_auris_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -22,3 +22,4 @@ esp32_ble_beacon:
|
|||||||
uuid: !secret ble_beacon_toyota_yaris_uuid
|
uuid: !secret ble_beacon_toyota_yaris_uuid
|
||||||
major: !secret ble_beacon_toyota_yaris_major
|
major: !secret ble_beacon_toyota_yaris_major
|
||||||
minor: !secret ble_beacon_toyota_yaris_minor
|
minor: !secret ble_beacon_toyota_yaris_minor
|
||||||
|
tx_power: 9dBm
|
||||||
@@ -31,8 +31,9 @@ ble_beacon_toyota_auris_uuid: "00000000-0000-0000-0000-000000000000"
|
|||||||
ble_beacon_toyota_auris_major: 10167
|
ble_beacon_toyota_auris_major: 10167
|
||||||
ble_beacon_toyota_auris_minor: 61958
|
ble_beacon_toyota_auris_minor: 61958
|
||||||
ble_beacon_toyota_yaris_uuid: "00000000-0000-0000-0000-000000000000"
|
ble_beacon_toyota_yaris_uuid: "00000000-0000-0000-0000-000000000000"
|
||||||
ble_beacon_toyota_yaris_honda_major: 10167
|
ble_beacon_toyota_yaris_major: 10167
|
||||||
ble_beacon_toyota_yaris_honda_minor: 61958
|
ble_beacon_toyota_yaris_minor: 61958
|
||||||
|
ble_beacon_gate_uuid: "00000000-0000-0000-0000-000000000000"
|
||||||
|
|
||||||
# Thread active dataset (hex TLV) from Home Assistant
|
# Thread active dataset (hex TLV) from Home Assistant
|
||||||
thread_tlv: "0E080000000000010000"
|
thread_tlv: "0E080000000000010000"
|
||||||
|
|||||||
Reference in new issue
Block a user