API reference
Contents:
Virtual Switch Bot
- class switchbot_api.VirtualSwitchBot(mac_address: str, device: Optional[BLEDevice] = None, password_str: Optional[str] = None)[source]
-
- async set_password(new_password: Optional[str])[source]
Sends a set password message or clears the password if None
- Parameters
new_password (Optional[str]) – The new password string or None if clearing the password
- async set_bot_state(state: SwitchBotAction)[source]
Sends a “set state” command
Only can send PRESS, ON, or OFF
- Parameters
state (SwitchBotAction) – The action to take (PRESS, ON, and OFF)
- async run_action_set(action_set: List[Tuple[float, SwitchBotAction]])[source]
Run a set of actions in order (no more than 8)
- Parameters
action_set (List[Tuple[float, SwitchBotAction]]) – The set of actions to run in order with delay (seconds) between them (first ignored)
- async set_basic_device_info(bot_mode: SwitchBotMode, is_inverse: bool)[source]
Sends a set basic device info message
- async fetch_basic_device_info()[source]
Update internal
info
object with basic info (after response is received)
- async update_alarm_count(alarm_count: int)[source]
Change the amount of alarms (0 <= n <= 4)
- Parameters
alarm_count (int) – The number of alarms to set
- async update_alarm_info(alarm_id: int, alarm_info: AlarmInfo)[source]
Update the information for an alarm (alarm count must be set)
- Parameters
alarm_id (int) – The ID of the alarm to update (0 <= id < # of alarms)
alarm_info (AlarmInfo) – The new alarm info
- async fetch_alarm_info(alarm_id: int)[source]
Fetch information for alarm information :param alarm_id: The ID of the alarm to fetch (0 <= id < # of alarms) :type alarm_id: int
- async set_long_press_duration(duration_s: int)[source]
Set the duration of a “long press” command
- Parameters
duration_s (int) – Duration in seconds
- property mac_address: str
Connected SwitchBot’s MAC address
- Returns
MAC Address
- Return type
str
- property info: BotInformation
Connected SwitchBot’s Information
- Returns
SwitchBot Information
- Return type
SwitchBot Scanner
- class switchbot_api.SwitchBotScanner(bot_count: int = 1)[source]
- async next_bot()
Scans for the next SwitchBot until the desired number of SwitchBots are found
- Returns
The VirtualSwitchBot found
- Return type
AsyncIterator[VirtualSwitchBot]