Skip to main content

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

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')

# For some device types like Bot:
bot = devices[0]
bot.turn('on')
bot.turn('off')
bot.toggle()
bot.press()

Contributors

Thanks to all contributors!

Project details


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.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_switchbot-2.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file python-switchbot-2.0.1.tar.gz.

File metadata

  • Download URL: python-switchbot-2.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for python-switchbot-2.0.1.tar.gz
Algorithm Hash digest
SHA256 3ae4c1a31a7bf6745a3286a25f545484b9ed60497836e7d3e412b393f87b15c4
MD5 e00d4887cc0d19a68d6a12b996c16979
BLAKE2b-256 a1afdb9b8432fde301fe87e33163b719accb7a11273830aad21f12d8fbfb84fb

See more details on using hashes here.

File details

Details for the file python_switchbot-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: python_switchbot-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for python_switchbot-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92dc8408a9a1cc4898e86a08d77261a38af8e1c12efd537131b15f5057616061
MD5 9d42ab70960582eb7ce3bafb04cb1d8b
BLAKE2b-256 46cdaf1cfbbf20512340cdf0384d4049a8feb8517fd8b94b0bbce7305f6a2c1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page