HTTP Server to receive BLE commands to control Switch Bot devices.
495
This program aims to provide a better solution to control Switch Bot devices when integrating with Homebridge. The current official Switch Bot plugins on Homebridge does not provide a stable BLE connection to the SwitchBot devices, especially when running on a RaspberryPi. Users who use this program can consider to install homebridge-http-switch plugin to use with this program.
linux/arm/v7, linux/arm64, linux/amd64
docker run --rm --network=host -v /var/run/dbus:/var/run/dbus donkeystudio/switchbot-python-http-server
python3 main.py --help
usage: main.py [-h] [-u USER] [-pwd PASSWORD] [-p PORT] [-on ON_OR_OK] [-off OFF_OR_FAIL]
optional arguments:
-h, --help show this help message and exit
-u USER, --user USER Username (default: None)
-pwd PASSWORD, --password PASSWORD Password (default: None)
-p PORT, --port PORT Port (default: 8080)
-on ON_OR_OK, --on_or_ok ON_OR_OK Value to return if device is On or the requested action was executed successfully (default: 1)
-off OFF_OR_FAIL, --off_or_fail OFF_OR_FAIL Value to return if device is Off or the requested action was failed to execute (default: 0)
Basic HTTP Authorization is supported. Username and password are setup using -u/--user and -pwd / --password arguments
GET /?command=XXX&device=XX:XX:XX:XX:XX&interface=0&connect_timeout=5
| Parameter | Type | Description |
|---|---|---|
command | string | Required. Command to Switchbot device. Support the following: 1. on: Switch mode - Turn on 2. off: Switch mode - Turn off3. press: Press mode - Press4. status: Status of the device |
device | string | Required. BLE MAC address of the Switchbot device. Can be either XX:XX:XX or XX-XX-XX formats |
interface | number | Optional. ID of the HCI bluetooth interface. Default 0 for hci0 interface |
connect_timeout | number | Optional. Set connect timeout before stopping the request. Default 5 seconds |
Return: 1 for successful request or the device status is ON; 0 for otherwise. Response codes can be changed by setting -on / --on_or_ok and -off / --off_or_fail arguments
Content type
Image
Digest
sha256:4a0c5963e…
Size
85.2 MB
Last updated
about 4 years ago
docker pull donkeystudio/switchbot-python-http-server