mirror of
https://github.com/esphome/esphome.git
synced 2026-01-10 04:00:51 -07:00
Refactored the component to use a list-based configuration structure that
reduces duplication and makes it clearer that multiple sensors come from
the same device.
New configuration format:
sensor:
- platform: bthome_ble
mac_address: "A4:C1:38:12:34:56"
bindkey: "..." # optional
sensors:
- type: temperature
name: "Temperature"
- type: humidity
name: "Humidity"
binary_sensor:
- platform: bthome_ble
mac_address: "A4:C1:38:9A:BC:DE"
binary_sensors:
- type: motion
name: "Motion"
- type: door
name: "Door"
Benefits:
- MAC address and bind key are specified once per device
- More efficient (one BLE listener per device instead of per sensor)
- Clearer relationship between sensors from the same device
- Matches user expectations for multi-sensor devices
Updated test configurations to demonstrate the new format.
91 lines
2.2 KiB
YAML
91 lines
2.2 KiB
YAML
esp32_ble_tracker:
|
|
scan_parameters:
|
|
interval: 1100ms
|
|
window: 1100ms
|
|
active: true
|
|
|
|
sensor:
|
|
# Multiple sensors from the same device without encryption
|
|
- platform: bthome_ble
|
|
mac_address: "A4:C1:38:12:34:56"
|
|
sensors:
|
|
- type: temperature
|
|
name: "BTHome Temperature"
|
|
- type: humidity
|
|
name: "BTHome Humidity"
|
|
- type: pressure
|
|
name: "BTHome Pressure"
|
|
- type: illuminance
|
|
name: "BTHome Illuminance"
|
|
|
|
# Sensors from encrypted device
|
|
- platform: bthome_ble
|
|
mac_address: "A4:C1:38:78:90:AB"
|
|
bindkey: "231d39c1d7cc1ab1aee224cd096db932"
|
|
sensors:
|
|
- type: battery
|
|
name: "BTHome Battery Encrypted"
|
|
- type: temperature
|
|
name: "BTHome Temperature Encrypted"
|
|
|
|
# Power monitoring device
|
|
- platform: bthome_ble
|
|
mac_address: "A4:C1:38:CD:EF:12"
|
|
sensors:
|
|
- type: power
|
|
name: "BTHome Power"
|
|
- type: energy
|
|
name: "BTHome Energy"
|
|
- type: voltage
|
|
name: "BTHome Voltage"
|
|
- type: current
|
|
name: "BTHome Current"
|
|
|
|
# Air quality device
|
|
- platform: bthome_ble
|
|
mac_address: "A4:C1:38:34:56:78"
|
|
sensors:
|
|
- type: pm25
|
|
name: "BTHome PM2.5"
|
|
- type: pm10
|
|
name: "BTHome PM10"
|
|
- type: co2
|
|
name: "BTHome CO2"
|
|
- type: voc
|
|
name: "BTHome VOC"
|
|
- type: moisture
|
|
name: "BTHome Moisture"
|
|
|
|
binary_sensor:
|
|
# Motion and occupancy sensors
|
|
- platform: bthome_ble
|
|
mac_address: "A4:C1:38:9A:BC:DE"
|
|
binary_sensors:
|
|
- type: motion
|
|
name: "BTHome Motion"
|
|
- type: occupancy
|
|
name: "BTHome Occupancy"
|
|
|
|
# Door and window sensors with encryption
|
|
- platform: bthome_ble
|
|
mac_address: "A4:C1:38:AB:CD:EF"
|
|
bindkey: "231d39c1d7cc1ab1aee224cd096db932"
|
|
binary_sensors:
|
|
- type: door
|
|
name: "BTHome Door Encrypted"
|
|
- type: window
|
|
name: "BTHome Window Encrypted"
|
|
- type: battery_low
|
|
name: "BTHome Battery Low"
|
|
|
|
# Safety sensors
|
|
- platform: bthome_ble
|
|
mac_address: "A4:C1:38:FE:DC:BA"
|
|
binary_sensors:
|
|
- type: smoke
|
|
name: "BTHome Smoke"
|
|
- type: opening
|
|
name: "BTHome Opening"
|
|
- type: moisture
|
|
name: "BTHome Moisture Binary"
|