switchbot
Platypush documentation
switchbot
- class platypush.plugins.switchbot.SwitchbotPlugin(api_token: str, **kwargs)[source]
Bases:
SwitchPlugin
Plugin to interact with the devices registered to a Switchbot (https://www.switch-bot.com/) account/hub.
The difference between this plugin and
platypush.plugins.switchbot.bluetooth.SwitchbotBluetoothPlugin
is that the latter acts like a Bluetooth hub/bridge that interacts directly with your Switchbot devices, while this plugin requires the devices to be connected to a Switchbot Hub and it controls them through your cloud account.In order to use this plugin:
Set up a Switchbot Hub and configure your devices through the Switchbot app.
Follow the steps on the Switchbot API repo to get an API token from the app.
- __init__(api_token: str, **kwargs)[source]
- Parameters:
api_token – API token (see Getting started with the Switchbot API).
- back(device: str)[source]
Send backward IR event to a device (for DVD and Speaker).
- Parameters:
device – Device name or ID.
- channel_next(device: str)[source]
Send next channel IR event to a device (for TV, IPTV/Streamer, and Set Top Box).
- Parameters:
device – Device name or ID.
- channel_prev(device: str)[source]
Send previous channel IR event to a device (for TV, IPTV/Streamer, and Set Top Box).
- Parameters:
device – Device name or ID.
- devices() List[dict] [source]
Get the list of devices associated to the specified Switchbot API account.
- Returns:
[ { "cloud_service_enabled": "True if cloud access is enabled on this device,False otherwise. Only cloud-enabled devices can be controlled from the switchbot plugin.", "device_type": "Default types: [Hub, Hub Plus, Hub Mini, Bot, Curtain, Plug, Meter, Humidifier, Smart Fan, Air Conditioner, TV, Light, IPTV / Streamer, Set Top Box, DVD, Fan, Projector, Camera, Air Purifier, Speaker, Water Heater, Vacuum Cleaner, Remote, Others]", "hub_id": "Parent hub device unique ID", "id": "Device unique ID", "is_calibrated": "[Curtain devices only] Set to True if the device has been calibrated, False otherwise", "is_virtual": "True if this is a virtual device, i.e. a device with an IR remote configuration but not managed directly by the Switchbot bridge", "name": "Device name", "open_direction": "[Curtain devices only] Direction where the curtains will be opened (\"left\" or \"right\")", "remote_type": "Default types: [Air Conditioner, TV, Light, IPTV / Streamer, Set Top Box, DVD, Fan, Projector, Camera, Air Purifier, Speaker, Water Heater, Vacuum Cleaner, Others]" } ]
- forward(device: str)[source]
Send forward IR event to a device (for DVD and Speaker).
- Parameters:
device – Device name or ID.
- mute(device: str)[source]
Send mute/unmute IR event to a device (for TV, IPTV/Streamer, Set Top Box, DVD and Speaker).
- Parameters:
device – Device name or ID.
- next(device: str)[source]
Send next IR event to a device (for DVD and Speaker).
- Parameters:
device – Device name or ID.
- off(device: str, **kwargs)[source]
Send a turn-off command to a device
- Parameters:
device – Device name or ID.
- on(device: str, **kwargs)[source]
Send a turn-on command to a device
- Parameters:
device – Device name or ID.
- pause(device: str)[source]
Send pause IR event to a device (for DVD and Speaker).
- Parameters:
device – Device name or ID.
- play(device: str)[source]
Send play IR event to a device (for DVD and Speaker).
- Parameters:
device – Device name or ID.
- press(device: str)[source]
Send a press-button command to a device.
- Parameters:
device – Device name or ID.
- previous(device: str)[source]
Send previous IR event to a device (for DVD and Speaker).
- Parameters:
device – Device name or ID.
- scenes() List[dict] [source]
Get the list of registered scenes.
- Returns:
[ { "id": "Scene ID", "name": "Scene name" } ]
- set_ac_fan_speed(device: str, fan_speed: int)[source]
Set the fan speed for an air conditioner.
- Parameters:
device – Device name or ID.
fan_speed –
Possible values:
1:
auto
2:
low
3:
medium
4:
high
- set_ac_mode(device: str, mode: int)[source]
Set the mode of an air conditioner.
- Parameters:
device – Device name or ID.
mode –
Air conditioner mode. Supported values:
1:
auto
2:
cool
3:
dry
4:
fan
5:
heat
- set_channel(device: str, channel: int)[source]
Set the channel on a TV, IPTV/Streamer, Set Top Box device.
- Parameters:
device – Device name or ID.
channel – Channel number.
- set_curtain_position(device: str, position: int)[source]
Set the position of a curtain device.
- Parameters:
device – Device name or ID.
position – An integer between 0 (open) and 100 (closed).
- set_fan_mode(device: str, mode: int)[source]
Set the mode of a fan.
- Parameters:
device – Device name or ID.
mode – Fan mode (1 or 2).
- set_fan_speed(device: str, speed: int)[source]
Set the speed of a fan.
- Parameters:
device – Device name or ID.
speed – Speed between 1 and 4.
- set_humidifier_efficiency(device: str, efficiency: Union[int, str])[source]
Set the nebulization efficiency of a humidifier device.
- Parameters:
device – Device name or ID.
efficiency – An integer between 0 (open) and 100 (closed) or auto.
- set_swing_range(device: str, swing_range: int)[source]
Set the swing range of a fan.
- Parameters:
device – Device name or ID.
swing_range – Swing range angle, between 0 and 120.
- set_temperature(device: str, temperature: float)[source]
Set the temperature of an air conditioner.
- Parameters:
device – Device name or ID.
temperature – Temperature, in Celsius.
- status(device: Optional[str] = None) Union[dict, List[dict]] [source]
Get the status of all the registered devices or of a specific device.
- Parameters:
device – Filter by device ID or name.
- Returns:
[ { "auto": "[Humidifier devices only] True if auto mode is on", "child_lock": "[Humidifier devices only] True if safety lock is on", "cloud_service_enabled": "True if cloud access is enabled on this device,False otherwise. Only cloud-enabled devices can be controlled from the switchbot plugin.", "device_type": "Default types: [Hub, Hub Plus, Hub Mini, Bot, Curtain, Plug, Meter, Humidifier, Smart Fan, Air Conditioner, TV, Light, IPTV / Streamer, Set Top Box, DVD, Fan, Projector, Camera, Air Purifier, Speaker, Water Heater, Vacuum Cleaner, Remote, Others]", "fan_speed": "[Air conditioner devices only] Speed of the fan", "hub_id": "Parent hub device unique ID", "humidity": "[Meter/humidifier devices only] Humidity in %", "id": "Device unique ID", "is_calibrated": "[Curtain devices only] Set to True if the device has been calibrated, False otherwise", "is_virtual": "True if this is a virtual device, i.e. a device with an IR remote configuration but not managed directly by the Switchbot bridge", "mode": "[Fan/Air conditioner devices only] Fan mode", "moving": "[Curtain devices only] True if the device is moving, False otherwise", "name": "Device name", "nebulization_efficiency": "[Humidifier devices only] Nebulization efficiency in %", "on": "True if the device is on, False otherwise", "open_direction": "[Curtain devices only] Direction where the curtains will be opened (\"left\" or \"right\")", "position": "[Curtain devices only] Position of the device on the curtain rail, between 0 (open) and 1 (closed)", "remote_type": "Default types: [Air Conditioner, TV, Light, IPTV / Streamer, Set Top Box, DVD, Fan, Projector, Camera, Air Purifier, Speaker, Water Heater, Vacuum Cleaner, Others]", "sound": "[Humidifier devices only] True if sound is muted", "speed": "[Smart fan devices only] Fan speed, between 1 and 4", "swing_direction": "[Smart fan devices only] Swing direction", "swing_range": "[Smart fan devices only] Swing range angle, between 0 and 120", "swinging": "[Smart fan devices only] True if the device is swinging", "temperature": "[Meter/humidifier/Air conditioner devices only] Temperature in Celsius" } ]
- stop(device: str)[source]
Send stop IR event to a device (for DVD and Speaker).
- Parameters:
device – Device name or ID.
- property switches: List[dict]
- Returns:
[ { "id": "Device unique ID", "name": "Device name", "on": "True if the device is on, False otherwise" } ]
- toggle(device: str, **kwargs)[source]
Shortcut for
press()
.- Parameters:
device – Device name or ID.