『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: riceball

自制开源ESPHome通用蓝牙网关(ESP32)

  [复制链接]

2

主题

12

帖子

166

积分

注册会员

Rank: 2

积分
166
金钱
154
HASS币
0
发表于 2022-11-15 11:40:39 | 显示全部楼层
hatonas 发表于 2022-11-14 15:06
谢谢,看来是要手动配置的,我挂了一晚上,也连上了。连接速度只能说很慢很慢 ...

如果有IPEX接口的话,可以考虑加个IPEX天线。
我手边有个NUC盒预留了wifi天线,试着把板子接上去以后信号一下变强了,连的速度也快了
回复

使用道具 举报

56

主题

929

帖子

4103

积分

论坛元老

Rank: 8Rank: 8

积分
4103
金钱
3174
HASS币
0
发表于 2022-11-24 11:05:10 | 显示全部楼层
请教楼主:我买的是普通的esp32,修改了相关模块代码,其他完全是按楼主的代码编译通过并刷进固件。
1、blegateway1网关可发现并在hass里提交配置,看到一个实体,但是显示不可用(灰色)
2、在hass前端配置yaml开关和hacs下载的Passive BLE Monitor 集成重启并提交,
3、前端开关已打开,
4、在esphome能看到blegateway1网关log里跑蓝色代码,显示能看到我家小米系列蓝牙设备,温度计、青萍人体、小米人体
所有操作都按楼主的流程进行,但就是在Passive BLE Monitor 集成配置里不能发现设备。不知道是什么原因?
6628_1669257375_hd.jpeg
回复

使用道具 举报

32

主题

285

帖子

1825

积分

金牌会员

Rank: 6Rank: 6

积分
1825
金钱
1540
HASS币
0
发表于 2022-11-24 11:25:04 | 显示全部楼层
楼主你好,我使用了你的代码成功刷入了,也接入了ha,并且小米门磁和温湿度计检测都没有问题,但是到了设备track就出现问题了,我要检测手机和手表的蓝牙作为判断是否在家,但是没用,状态一直都没有变化,不知道是什么情况,麻烦帮我看一下esphome的代码以及esphome的日志吧,谢谢了。
substitutions:
  # Name the device and it's entities
  device: ble_gateway
  device_name: blegateway1

esphome:
  name: $device_name
  comment: $device
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32-c3-devkitm-1
  variant: esp32c3
  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:
  scan_parameters:
   interval: 120ms
   window: 100ms
# Enable logging
logger:

# Enable Home Assistant API
api:
  reboot_timeout: 1h

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: on
  reboot_timeout: 23min
  manual_ip:    
    static_ip: 192.168.1.118    
    gateway: 192.168.1.1    
    subnet: 255.255.255.0

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: "$device_name Fallback Hotspot"
    password: !secret ap_password

ble_gateway:
  id: $device_name
  # devices:
  #   - mac_address: 01:23:45:67:89:AB
  #   - 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;

binary_sensor:
  - platform: homeassistant
    id: ble_gateway_discovery
    entity_id: binary_sensor.ble_gateway
    attribute: discovery
    on_state:
      then:
        lambda: id($device_name).set_discovery(x);
- platform: ble_presence
 id: S21Ultra
 mac_address: C8:BD:69:D5:87:46
 name: "S21 Ultra(BT)"
 - platform: ble_presence
 id: GalaxyWatch4
 mac_address: 60:3A:AF:E1:20:40
 name: "Galaxy Watch4 Classic (4LQJ)"

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);
  # IP address of device. Not really needed for HA (as HA already knows it), but for showing on the display during startup. The startup screen will leave on if no instance connects to the API.
  - platform: wifi_info
    ip_address:
      name: $device_name IP address
      id: ip_address
  # ESPHome version used to compile the app
  - platform: version
    name: $device_name ESPHome Version

sensor:
  # WiFi signals strength sensor
  - platform: wifi_signal
    name: $device_name WiFi Signal Sensor
    update_interval: 60s

INFO Reading configuration /config/esphome/blegateway.yaml...
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Starting log output from 192.168.1.118 using esphome API
INFO Successfully connected to 192.168.1.118
[09:51:56][I][app:102]: ESPHome version 2022.11.2 compiled on Nov 24 2022, 00:39:09
[09:51:56][C][wifi:504]: WiFi:
[09:51:56][C][wifi:362]:   Local MAC: 60:55:F9:74:3C:34
[09:51:56][C][wifi:363]:   SSID: 'OpenWrt'[redacted]
[09:51:56][C][wifi:364]:   IP Address: 192.168.1.118
[09:51:56][C][wifi:366]:   BSSID: 10:44:00:48:26:28[redacted]
[09:51:56][C][wifi:367]:   Hostname: 'blegateway1'
[09:51:56][C][wifi:369]:   Signal strength: -24 dB ▂▄▆█
[09:51:56][C][wifi:373]:   Channel: 6
[09:51:56][C][wifi:374]:   Subnet: 255.255.255.0
[09:51:56][C][wifi:375]:   Gateway: 192.168.1.1
[09:51:56][C][wifi:376]:   DNS1: 0.0.0.0
[09:51:56][C][wifi:377]:   DNS2: 0.0.0.0
[09:51:56][C][logger:293]: Logger:
[09:51:56][C][logger:294]:   Level: DEBUG
[09:51:56][C][logger:295]:   Log Baud Rate: 115200
[09:51:56][C][logger:296]:   Hardware UART: UART0
[09:51:56][C][ble_gateway:055]: BLE Gateway: Discovery NO, 2 device(s) configured:
[09:51:56][C][ble_gateway:057]:   MAC address: A4:C1:38:EC:AA:60
[09:51:56][C][ble_gateway:057]:   MAC address: E4:AA:EC:5F:71:E5
[09:51:56][C][ble_presence:011]: BLE Presence 'S21 Ultra(BT)'
[09:51:56][C][ble_presence:011]: BLE Presence 'Galaxy Watch4 Classic (4LQJ)'
[09:51:56][C][version.text_sensor:021]: Version Text Sensor 'blegateway1 ESPHome Version'
[09:51:56][C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[09:51:56][C][esp32_ble_tracker:796]: BLE Tracker:
[09:51:56][C][esp32_ble_tracker:797]:   Scan Duration: 300 s
[09:51:56][C][esp32_ble_tracker:798]:   Scan Interval: 120.0 ms
[09:51:56][C][esp32_ble_tracker:799]:   Scan Window: 100.0 ms
[09:51:56][C][esp32_ble_tracker:800]:   Scan Type: ACTIVE
[09:51:56][C][esp32_ble_tracker:801]:   Continuous Scanning: True
[09:51:56][C][mdns:103]: mDNS:
[09:51:56][C][mdns:104]:   Hostname: blegateway1
[09:51:56][C][ota:093]: Over-The-Air Updates:
[09:51:56][C][ota:094]:   Address: 192.168.1.118:3232
[09:51:56][C][ota:097]:   Using Password.
[09:51:56][C][api:138]: API Server:
[09:51:56][C][api:139]:   Address: 192.168.1.118:6053
[09:51:56][C][api:143]:   Using noise encryption: NO
[09:51:56][C][homeassistant.binary_sensor:039]: Homeassistant Binary Sensor 'ble_gateway_discovery'
[09:51:56][C][homeassistant.binary_sensor:040]:   Entity ID: 'binary_sensor.ble_gateway'
[09:51:56][C][homeassistant.binary_sensor:042]:   Attribute: 'discovery'
[09:51:56][C][wifi_info:009]: WifiInfo IPAddress 'blegateway1 IP address'
[09:51:56][C][wifi_signal.sensor:009]: WiFi Signal 'blegateway1 WiFi Signal Sensor'
[09:51:56][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[09:51:56][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[09:51:56][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[09:51:56][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[09:51:56][C][homeassistant.text_sensor:023]: Homeassistant Text Sensor 'ble_gateway_devices'
[09:51:56][C][homeassistant.text_sensor:024]:   Entity ID: 'binary_sensor.ble_gateway'
[09:51:56][C][homeassistant.text_sensor:026]:   Attribute: 'devices'
[09:51:57][D][ble_gateway:063]: [A4:C1:38:EC:AA:60] Packet 043E2B0201000060AAEC38C1A41F12161A1860AAEC38C1A40C08CC1AE60A41F60F0B094154435F454341413630CB
[09:52:07][D][ble_gateway:063]: [A4:C1:38:EC:AA:60] Packet 043E2B0201000060AAEC38C1A41F12161A1860AAEC38C1A40C08CC1AE60A41F60F0B094154435F454341413630CB
[09:52:12][D][ble_gateway:063]: [A4:C1:38:EC:AA:60] Packet 043E2B0201000060AAEC38C1A41F12161A1860AAEC38C1A40C08CD1AEA0A42F70F0B094154435F454341413630CB
[09:52:16][D][sensor:127]: 'blegateway1 WiFi Signal Sensor': Sending state -23.00000 dBm with 0 decimals of accuracy
[09:52:17][D][ble_gateway:063]: [A4:C1:38:EC:AA:60] Packet 043E2B0201000060AAEC38C1A41F12161A1860AAEC38C1A40C08CD1AEA0A42F70F0B094154435F454341413630CB
[09:52:19][D][esp32_ble_tracker:812]: Found device F1:4D:CF:5E:3E:F1 RSSI=-95
[09:52:19][D][esp32_ble_tracker:833]:   Address Type: RANDOM
[09:52:27][D][ble_gateway:063]: [A4:C1:38:EC:AA:60] Packet 043E2B0201000060AAEC38C1A41F12161A1860AAEC38C1A40C08CD1AEA0A42F70F0B094154435F454341413630CD
[09:52:32][D][ble_gateway:063]: [A4:C1:38:EC:AA:60] Packet 043E2B0201000060AAEC38C1A41F12161A1860AAEC38C1A40B08CD1AE30A41F80F0B094154435F454341413630CE



回复

使用道具 举报

32

主题

285

帖子

1825

积分

金牌会员

Rank: 6Rank: 6

积分
1825
金钱
1540
HASS币
0
发表于 2022-11-24 11:27:10 | 显示全部楼层
justion 发表于 2022-11-24 11:25
楼主你好,我使用了你的代码成功刷入了,也接入了ha,并且小米门磁和温湿度计检测都没有问题,但是到了设备 ...

刚刚这个日志里BLE Gateway: Discovery NO,这个地方我变成yes也试过了,也不行
回复

使用道具 举报

3

主题

27

帖子

214

积分

中级会员

Rank: 3Rank: 3

积分
214
金钱
187
HASS币
0
发表于 2022-12-7 19:58:13 | 显示全部楼层
win741852 发表于 2022-11-8 12:23
我也是这个情况 用的是ESP-C3-13U-KIT 已经确定不是路由器的问题

最新测试结果,我刚添加了手动配置网络 ...

我试了手动配置网络,还是不行,能秒联网,能ping通,但是6053的端口打不开了。log提示Can't connect to ESPHome API
回复

使用道具 举报

0

主题

7

帖子

56

积分

注册会员

Rank: 2

积分
56
金钱
49
HASS币
0
发表于 2023-1-3 07:20:07 | 显示全部楼层
请教,配置configuration.yaml后,出现了错误:
Integration error:   - - Integration '  -' not found.
Integration error:   settings_ble_gateway_add_device - Integration '  settings_ble_gateway_add_device' not found.
Integration error:   settings_ble_gateway_discovery - Integration '  settings_ble_gateway_discovery' not found.
Integration error:   settings_ble_gateway - Integration '  settings_ble_gateway' not found.

这是passive ble monitor 这个集成,版本导致的么?当前安装的版本是11.2.0
回复

使用道具 举报

0

主题

1

帖子

42

积分

新手上路

Rank: 1

积分
42
金钱
41
HASS币
0
发表于 2023-2-17 10:16:28 | 显示全部楼层
hackyjso 发表于 2022-7-7 12:40
我也是这个那个 ESP32 C3 板子,为什么不能联网呢,

就 arduino 不行,可是esp-idf平台就可以

我也是这样情况
回复

使用道具 举报

0

主题

5

帖子

50

积分

注册会员

Rank: 2

积分
50
金钱
45
HASS币
0
发表于 2023-4-1 13:04:27 | 显示全部楼层
本帖最后由 spaceman 于 2023-4-1 13:26 编辑

12.9元的合宙 ESP32C3 经典版按楼主的配置刷,wifi连不上,按76楼介绍手动配置ip地址,重新编辑固件还是连不上。郁闷了,找不到原因。
删除蓝牙相关配置,用idf刷可以连上wifi, 但是不知道怎样在idf模式下做蓝牙网关。
回复

使用道具 举报

0

主题

13

帖子

47

积分

新手上路

Rank: 1

积分
47
金钱
34
HASS币
0
发表于 2023-4-13 09:25:01 | 显示全部楼层
改了这个之后,终于wifi稳定了,之前基本不能成功的。。。。。因为ble和wifi同时进行

esphome:
  name: esp32c3
  friendly_name: esp32C3
  on_boot:
    priority: 250
    then:
      - delay: 15s
      - lambda: |-
          id(ble_tracker).set_scan_continuous(true); 
          id(ble_tracker).start_scan();

回复

使用道具 举报

0

主题

3

帖子

86

积分

注册会员

Rank: 2

积分
86
金钱
83
HASS币
0
发表于 2023-4-17 10:40:08 | 显示全部楼层
准备购入1个来照葫芦画瓢,谢谢大佬分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 10:25 , Processed in 0.063709 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表