8

Docker Compose – 在 Home assistant 使用树莓派蓝牙模块

 9 months ago
source link: https://i.lckiss.com/?p=8390
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

树莓派使用的是 Ubuntu server 20.04 ,Home assistant 作为 docker 中的一个容器,需要在容器中连接小米温湿度计 Pro。

Docker Compose

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /your/homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true
    network_mode: host

在这个过程中遇到很多问题,其中主要是

1、确保板载蓝牙处于启用状态,可见:RPI 4B – Bluetooth unavailable on Ubuntu server 20.04

2、将宿主中的 dbus 正确的映射至容器中

这里主要是说第二个问题,当容器中使用了 HACS 安装了 Passive BLE monitor integration,展示各种蓝牙无法启动,设备不可用时。

首先检查 Docker Compose 中是否包含不必要的映射,诸如:

- /var/run/dbus:/var/run/dbus:ro
- /etc:/etc:ro
- /sys/class/bluetooth:/sys/class/bluetooth:ro
- /var/lib/bluetooth:/var/lib/bluetooth:ro

仅需要一项 dbus 即可,至于位置可以通过 find / -name dbus 进行寻找,一般情况下,/var/run/dbus/run/dbus 任选其一即可。

其他官方要求可参考:https://www.home-assistant.io/integrations/bluetooth#requirements-for-linux-systems

Passive BLE 不再提示问题后,其他则是使用 Xiaomi Miot Auto 进行连接即可。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK