本帖最后由 shavn1984 于 2022-5-20 12:57 编辑
esp32编译烧录正常,启动后有扫描到设备日志。ha没有自动扫描添加实体
配置如下
esphome:
substitutions:
# Name the device and it's entities
device: ble_gateway
device_name: ble_gateway4
esphome:
name: esphome-web-084270
comment: $device
platformio_options:
board_build.flash_mode: dio
esp32:
board: nodemcu-32s
framework:
type: arduino
version: 2.0.2
platform_version: https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.3/platform-espressif32-2.0.2.3.zip
external_components:
- source: github://myhomeiot/esphome-components
esp32_ble_tracker:
# Enable logging
logger:
web_server:
port: 80
# Enable Home Assistant API
api:
reboot_timeout: 1h
ota:
password: "wxb1984626**"
wifi:
ssid: "XXX"
password: "XXX"
# manual_ip:
# static_ip: "192.168.2.41"
# gateway: "192.168.2.1"
# subnet: "255.255.255.0"
# dns1: "192.168.2.1"
# Enable fallback hotspot in case wifi connection fails
ap:
ssid: "4fblegateway"
password: "XXX"
ble_gateway:
id: $device_name
# devices:
# - mac_address: B8:7C:6F:32:95:DF
# - mac_address: !secret lywsd03mmc_mac
on_ble_advertise:
then:
- homeassistant.service:
service: ble_monitor.parse_data
data:
packet: !lambda return packet;
gateway_id: $device_name
- homeassistant.event:
event: esphome.on_ble_advertise
data:
packet: !lambda return packet;
text_sensor:
- platform: homeassistant
id: ble_gateway_devices
entity_id: binary_sensor.ble_gateway
attribute: devices
on_value:
then:
lambda: id($device_name).set_devices(x);
复制代码
ha configuration.yaml:
ha automations.yaml
- id: '1652780647472'
alias: HA Start automation
trigger:
platform: homeassistant
event: start
action:
service: input_boolean.turn_on
entity_id: input_boolean.ha_started
initial_state: true
复制代码