Skip to content

Commit

Permalink
readme: about section about network stack/namespace & home assistant;…
Browse files Browse the repository at this point in the history
… fix instructions for docker; changelog: document now required access to D-Bus system socket
  • Loading branch information
fphammerle committed Nov 5, 2023
1 parent e964cce commit 62fb2e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- TLS now enabled by default (disable via `--mqtt-disable-tls`)
- require `PySwitchbot>=0.14.0,<0.41` instead of `PySwitchbot>=0.10.0,<0.13`
- switchbot-mqtt now requires access to the D-Bus' system socket
`/var/run/dbus/system_bus_socket`
as `bleak` controls bluetooth via BlueZ over D-Bus.
access to network namespace containing bluetooth interface is thus
no longer required.
- `--fetch-device-info` no longer requires `CAP_NET_ADMIN`
(bluepy-helper replaced with bleak)
- replaced [paho-mqtt](https://github.com/eclipse/paho.mqtt.python)
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,18 @@ When disconnecting (graceful shutdown or unexpected loss of connection), `offlin

Why not use the official [SwitchBot integration](https://www.home-assistant.io/integrations/switchbot/)?

I prefer not to share the host's **network stack** with home assistant
Older versions of pySwitchbot (before bleak replaced bluepy) required access to the host's **network stack**.
I prefer not to share the host's network stack with home assistant's container
(more complicated network setup
and additional [netfilter](https://en.wikipedia.org/wiki/Netfilter) rules required for isolation).

Sadly, `docker run --network host` even requires `--userns host`:
> docker: Error response from daemon: cannot share the host's network namespace when user namespaces are enabled.
The docker image built from this repository works around this limitation
by explicitly running as an **unprivileged user**.

The [official home assistant image](https://hub.docker.com/r/homeassistant/home-assistant)
runs as `root`.
This imposes an unnecessary security risk, especially when disabling user namespace remapping
(`--userns host`).
See https://github.com/fphammerle/docker-home-assistant for an alternative.

### Setup

Expand Down Expand Up @@ -166,7 +163,8 @@ Annotation of signed tags `docker/*` contains docker image digests: https://gith
```sh
$ docker build -t switchbot-mqtt .
$ docker run --name spelunca_switchbot \
--userns host --network host \
--userns host \
-v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
switchbot-mqtt:latest \
switchbot-mqtt --mqtt-host HOSTNAME_OR_IP_ADDRESS
```
Expand All @@ -179,14 +177,15 @@ services:
switchbot-mqtt:
image: switchbot-mqtt
container_name: switchbot-mqtt
network_mode: host
userns_mode: host
environment:
- MQTT_HOST=localhost
- MQTT_PORT=1883
#- MQTT_USERNAME=username
#- MQTT_PASSWORD=password
#- FETCH_DEVICE_INFO=yes
volumes:
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
restart: unless-stopped
```

Expand Down

0 comments on commit 62fb2e2

Please sign in to comment.