switchbot.bluetooth
Platypush documentation
switchbot.bluetooth
- class platypush.plugins.switchbot.bluetooth.SwitchbotBluetoothPlugin(interface=None, connect_timeout=None, scan_timeout=2, devices=None, **kwargs)[source]
Bases:
SwitchPlugin
,BluetoothBlePlugin
Plugin to interact with a Switchbot (https://www.switch-bot.com/) device and programmatically control switches over a Bluetooth interface.
See
platypush.plugins.bluetooth.ble.BluetoothBlePlugin
for how to enable BLE permissions for the platypush user (a simple solution may be to run it as root, but that’s usually NOT a good idea).Requires:
pybluez (
pip install pybluez
)gattlib (
pip install gattlib
)libboost (on Debian
`apt-get install libboost-python-dev libboost-thread-dev
)
- __init__(interface=None, connect_timeout=None, scan_timeout=2, devices=None, **kwargs)[source]
- Parameters:
- off(device, **kwargs)[source]
Send a press-off button command to a device
- Parameters:
device (str) – Device name or address
- on(device, **kwargs)[source]
Send a press-on button command to a device
- Parameters:
device (str) – Device name or address
- press(device)[source]
Send a press button command to a device
- Parameters:
device (str) – Device name or address
- scan(interface: str = None, duration: int = 10) BluetoothScanResponse [source]
Scan for available Switchbot devices nearby.
- Parameters:
interface – Bluetooth interface to scan (default: default configured interface)
duration – Scan duration in seconds