A Python library to control SwitchBot devices connected to SwitchBot Hub
Project description
python-switchbot
A Python library to control SwitchBot devices connected to SwitchBot Hub
Requirements
- Python 3.8+
- A SwitchBot Token
Installation
pip install python-switchbot
Usage
from switchbot import SwitchBot
# To get the token, please refer to https://github.com/OpenWonderLabs/SwitchBotAPI#getting-started
your_switch_bot_token = '98a6732b2ac256d40ffab7db31a82f518969f4d1a64eadff581d45e902327b7c577aa6ead517bda589c19b4ca0b2599b'
switchbot = SwitchBot(token=your_switch_bot_token)
# To list all devices
devices = switchbot.devices()
for device in devices:
print(device)
# Bot(id=CD0A18B1C291)
# HubMini(id=4CAF08629A21)
# Bot(id=5F0B798AEF91)
# If you already know a device id:
device = switchbot.device(id='5F0B798AEF91')
# Device(id=5F0B798AEF91)
# To query a status of a device
print(device.status())
# {'power': 'off'}
# To command actions,
device.command('turn_on')
device.command('turn_off')
device.command('press')
device.command('set_position', parameter='0,ff,80)
Contributors
Thanks to all contributors!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-switchbot-2.0.0.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for python_switchbot-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0cd0abbe35c80c9e510bb160d9ee3a24c0386b031b55b49b87383a8a614057c |
|
MD5 | a1addec0d90b96e553aeba113c356afc |
|
BLAKE2b-256 | 008ce3b53a9a398b290c8a4f437a7a0784dc6af9d7e94095bcfd57877e0db46c |