Hi,
thanks dietah for your post
. Unfortunately I have problems with the deployment.
I’m using a Raspi 4B with Raspberry Pi OS (64-bit). On the Raspi, there are running OH and MQTT containers. I’m using Portainer for container administration. I have connected a z-Wave USB-stick and the EnOncean Pi module on GPIO of the Raspi. My plan is to use the internal Bluetooth interface on the Raspi to control Switchbot switches.
I tried the following according to your readme. I am listing everything in detail as I am still quite a beginner:
- Installing of the necessary Bluetooth libraries => worked well
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
- Read out Bluetooth interface (i have changed Bluetooth to mini-UART because of the EnOcean Pi on the GPIO):
root@*******:~# ls -l /sys/class/bluetooth
insgesamt 0
lrwxrwxrwx 1 root root 0 10. Aug 01:19 hci0 -> ../../devices/platform/soc/fe215040.serial/tty/ttyS0/hci0
As far as I understand, Bluetooth is now on device /ttyS0/hci0
- Own directory created for the switchbot container
mkdir /opt/switchbot
- The docker-compose.yml is created in it (mode privileged: true and network_mode: host added):
version: '3.6'
services:
mqtt-switchbot:
container_name: switchbot
image: deetoreu/mqtt-switchbot
restart: always
privileged: true
environment:
MQTT_HOST: "192.xxx.xxx.xxx"
MQTT_PORT: 1883
MQTT_USERNAME: xxxxx
MQTT_PASSWORD: xxxxx
MQTT_TOPIC: switchbot
LOG_LEVEL: "DEBUG"
SCAN_DURATION: 5*1000
DEVICE_LIST: "xx:xx:xx:xx:xx:xx,xx:xx:xx:xx:xx:xx"
devices:
- "/dev/ttyS0"
- "/dev/hci0"
- "/dev/ttyS0/hci0"
network_mode: host
volumes:
- ./volumes/switchbot/logs:/usr/src/app/logs
- Apply the container with:
docker-compose -f docker-compose.yml up -d
The switchbot container is running well according to Portainer. Unfortunately, I still don’t see any incoming topics from the Switchbot switch in the MQTT Explorer 
I have also checked Bluetooth connections with
sudo bluetoothctl
agent on
default-agent
scan on
The switchbot switches are listed and have good RSSI values. So I think that the Bluetooth connection generally works.
- In OH I created a generic MQTT thing, created an on-off switch as a channel and adapted the code for the value to be transferred:
UID: mqtt:topic:2e5f0240eb:Switchbottest
label: Switchbottest
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:2e5f0240eb
channels:
- id: Switchbottest
channelTypeUID: mqtt:switch
label: Switchbottest
description: ""
configuration:
commandTopic: /switchbottest
stateTopic: /switchbottest
off: switchbottest/switch/xx:xx:xx:xx:xx:xx/set off
on: switchbottest/switch/xx:xx:xx:xx:xx:xx/set on
The topic with the values arrives correctly at the MQTT broker.
Unfortunately, the Switchbot switch is not responding. Anyone have any ideas what could be wrongly configured? Are the topic settings in the .yml correct? Should the Switch also send it’s status (battery, linkquality) after operate with the Switchbot app?