switchbot_utility package

Submodules

switchbot_utility.battery_mixin module

class switchbot_utility.battery_mixin.BatteryMixin[source]

Bases: object

get_battery()[source]

Returns battery level

switchbot_utility.onoff_mixin module

class switchbot_utility.onoff_mixin.OnOffMixin[source]

Bases: object

On/Off devices.

turn_off() str[source]

Turn off device

turn_on() str[source]

Turn on device

switchbot_utility.switchbot module

class switchbot_utility.switchbot.Switchbot[source]

Bases: object

Switchbot Utility class

devicelist() None[source]

Create all Switchbot device list as deviceList.txt

gen_sign() dict[source]

Generate Switchbot API v1.1 sign header

Returns: Switchbot API v1.1 sign header

get_scene_list() None[source]

Get scene List as sceneList.txt

read_token() tuple[source]

Import access token and secret from settings.json

scene_execute(sceneId: str) str[source]

Execute scene

switchbot_utility.switchbot_blind_tilt module

class switchbot_utility.switchbot_blind_tilt.SwitchbotBlindTilt(deviceId)[source]

Bases: SwitchbotDevice, OnOffMixin

Switchbot Blind Tilt class

close_down() str[source]

Set the position of Blind Tilt to closed down.

Returns:

result

Return type:

str

close_up() str[source]

Set the position of Blind Tilt to closed up.

Returns:

result

Return type:

str

fully_open() str[source]

Set the position of Blind Tilt to open.

Returns:

result

Return type:

str

get_direction() str[source]

Return the opening direction of a Blind Tilt device

Returns:

result

Return type:

str

get_slide_position() int[source]

Return the current position, 0-100.

Returns:

current position

Return type:

int

set_position(direction: str, position: int) str[source]

Set blind position.

Parameters:
  • direction (str) – up/down

  • position (int) – 0~100 (0 means closed,

  • open (100 means) –

  • 2. (it MUST be set to a multiple of) –

Returns:

result

Return type:

str

switchbot_utility.switchbot_bot module

class switchbot_utility.switchbot_bot.SwitchbotBot(deviceId)[source]

Bases: SwitchbotDevice, OnOffMixin, BatteryMixin

Switchbot bot class

get_power() dict[source]

Returns ON/OFF state

press() str[source]

press action

switchbot_utility.switchbot_ceiling_light module

class switchbot_utility.switchbot_ceiling_light.SwitchbotCeilingLight(deviceId)[source]

Bases: SwitchbotColorBulb

Switchbot Ceiling Light class

get_brightness()[source]

Returns the brightness value, range from 1 to 100

get_color_temperature()[source]

Returns the color temperature value, range from 2700 to 6500

get_power()[source]

Returns ON/OFF state

set_color(r, g, b)[source]

Do nothing

switchbot_utility.switchbot_ceiling_light_pro module

class switchbot_utility.switchbot_ceiling_light_pro.SwithbotCeilingLightPro(deviceId)[source]

Bases: SwitchbotCeilingLight

Switchbot Ceiling Light class

switchbot_utility.switchbot_color_bulb module

class switchbot_utility.switchbot_color_bulb.SwitchbotColorBulb(deviceId)[source]

Bases: SwitchbotStripLight

Constructor

get_color_temperature() dict[source]

Returns the color temperature value, range from 2700 to 6500

set_color_temperature(temperature: int) str[source]

Set color temperature

switchbot_utility.switchbot_contact_sensor module

class switchbot_utility.switchbot_contact_sensor.SwitchbotContactSensor(deviceId)[source]

Bases: SwitchbotMotionSensor

Switchbot Contact Sensor class

get_open_state() dict[source]

Returns the open state of the sensor

switchbot_utility.switchbot_curtain module

class switchbot_utility.switchbot_curtain.SwitchbotCurtain(deviceId)[source]

Bases: SwitchbotDevice, OnOffMixin, BatteryMixin

Switchbot Curtain class

close() str[source]

Aliase of turn off command

get_curtain_position() dict[source]

Returns curtain position 0(open) to 100(close)

open() str[source]

Aliase of turn on command

set_position(position: int) str[source]

Set curtain position 0-100%

arg: position curtain position 0-100%

switchbot_utility.switchbot_device module

class switchbot_utility.switchbot_device.SwitchbotDevice(deviceId)[source]

Bases: Switchbot

Switchbot device class

command(deviceId: str, body: dict)[source]

Send command

get_status() dict[source]

Get device information

switchbot_utility.switchbot_humidifier module

class switchbot_utility.switchbot_humidifier.SwitchbotHumidifier(deviceId: str)[source]

Bases: SwitchbotDevice, OnOffMixin

Switchbot Humicifier class

get_auto()[source]

Returns if a Humidifier is in Auto Mode or not

get_child_lock()[source]

Returns if a Humidifier’s safety lock is on or not

get_humidity()[source]

Returns humidity percentage

get_lack_water()[source]

Returns if the water tank is empty or not

get_nebulization_efficiency()[source]

Returns atomization efficiency percentage

get_power()[source]

Returns ON/OFF state

get_sound()[source]

Returns if a Humidifier is muted or not

get_temperature()[source]

Returns temperature in celsius

set_mode(mode: int)[source]

Set device mode

switchbot_utility.switchbot_ir_air_conditioner module

class switchbot_utility.switchbot_ir_air_conditioner.IrAirConditioner(deviceId)[source]

Bases: SwitchbotIrDevice

Switchbot virtual ir Air Conditioner

set_all(temperature: int, mode: int, fan_speed: int, power_state: str) str[source]

Set the unit of temperature is in celsius

Parameters:
  • temperature – temperature in celsius

  • mode – 1(auto), 2(cool), 3(dry), 4(fan), 5(heat)

  • fan_speed – 1(auto), 2(low), 3(medium), 4(high)

  • power_state – ‘on’ or ‘off’ (must be quoted)

e.g. set_all(26,1, 3, ‘on’)

switchbot_utility.switchbot_ir_device module

class switchbot_utility.switchbot_ir_device.SwitchbotIrDevice(deviceId)[source]

Bases: OnOffMixin

Switchbot virtual ir device

switchbot_utility.switchbot_ir_dvd_speaker module

class switchbot_utility.switchbot_ir_dvd_speaker.IrDvd(deviceId)[source]

Bases: SwitchbotIrDevice

Switchbot virtual ir Tv

fast_forward() str[source]

Fast forward

next_track() str[source]

Next track

pause() str[source]

Pause

play() str[source]

Play/resume

previous() str[source]

Last track

rewind() str[source]

Rewind

set_mute() str[source]

Mute/unmute

stop() str[source]

Stop

class switchbot_utility.switchbot_ir_dvd_speaker.IrSpeaker(deviceId)[source]

Bases: IrDvd

IPTV/Streamer class

volume_add() str[source]

Volume up

volume_sub() str[source]

Volume down

switchbot_utility.switchbot_ir_fan module

class switchbot_utility.switchbot_ir_fan.IrFan(deviceId)[source]

Bases: SwitchbotIrDevice

Switchbot virtual IR fan

high_speed() str[source]

set fan speed to high

low_speed() str[source]

set fan speed to low

middle_speed() str[source]

set fan speed to middle

swing() str[source]

Swing

timer() str[source]

Set timer

switchbot_utility.switchbot_ir_light module

class switchbot_utility.switchbot_ir_light.IrLight(deviceId)[source]

Bases: SwitchbotIrDevice

Switchbot virtual IR Light

brightness_down() str[source]

Brightness down

brightness_up() str[source]

Brightness up

switchbot_utility.switchbot_ir_others module

class switchbot_utility.switchbot_ir_others.IrOthers(deviceId)[source]

Bases: SwitchbotDevice

IR virtual device others class

customize(button_name: str) str[source]

Execute customized button

Parameters:

button_name (str) –

switchbot_utility.switchbot_ir_tv_ipstreamer_stb module

class switchbot_utility.switchbot_ir_tv_ipstreamer_stb.IrSetTopBox(deviceId)[source]

Bases: IrTv

Set Top Box class

class switchbot_utility.switchbot_ir_tv_ipstreamer_stb.IrStreamer(deviceId)[source]

Bases: IrTv

Streamer class

class switchbot_utility.switchbot_ir_tv_ipstreamer_stb.IrTv(deviceId)[source]

Bases: SwitchbotIrDevice

Switchbot virtual ir Tv

channel_add() str[source]

Next channel

channel_sub() str[source]

Previous channel

set_channel(channel: int) str[source]

Next channel

volume_add() str[source]

Volume up

volume_sub() str[source]

Volume down

switchbot_utility.switchbot_keypad module

class switchbot_utility.switchbot_keypad.SwitchbotKeypad(deviceId)[source]

Bases: SwitchbotDevice

Switchbot Keypad class

create_key(name: str, type_: str, password: str) str[source]

Create a new passcode(permanent or urgent)

Parameters:
  • name – passcode name

  • type – type of passcode permanent or urgent

  • password – a 6 to 12-digit passcode in plain text

create_key_limited(name: str, type_: str, password: str, start_time: str, end_time: str) str[source]

Create a new passcode(timiLimit or disposable)

Parameters:
  • name – passcode name

  • type – type of passcode timeLimit or disposable

  • password – a 6 to 12-digit passcode in plain text

  • start_time – start time like 2000/12/31 23:59:15

  • end_time – end time like start_time

delete_key(keyId: str) str[source]
key_list() None[source]

Get keypad key list to file

switchbot_utility.switchbot_keypad_touch module

class switchbot_utility.switchbot_keypad_touch.SwitchbotKeypadTouch(deviceId)[source]

Bases: SwitchbotKeypad

Switchbot Keypad touch class

switchbot_utility.switchbot_lock module

class switchbot_utility.switchbot_lock.SwitchbotLock(deviceId)[source]

Bases: SwitchbotDevice, BatteryMixin

Switchbot Lock class

get_door_state() str[source]

Returns if closed or not

get_lock_state() str[source]

Returns if locked or not

lock() str[source]

Lock a lock

unlock() str[source]

Unlock a lock

switchbot_utility.switchbot_meter module

class switchbot_utility.switchbot_meter.SwitchbotMeter(deviceId)[source]

Bases: SwitchbotDevice, BatteryMixin

Switchbot meter class

get_humidity() str[source]

Returns humidity from meter

get_temperature() str[source]

Returns temperature from meter

switchbot_utility.switchbot_meter_plus module

class switchbot_utility.switchbot_meter_plus.SwitchbotMeterPlus(deviceId)[source]

Bases: SwitchbotMeter

Switchbot Meter Plus class

switchbot_utility.switchbot_motion_sensor module

class switchbot_utility.switchbot_motion_sensor.SwitchbotMotionSensor(deviceId)[source]

Bases: SwitchbotDevice, BatteryMixin

Switchbot Motion Sensor class

get_brightness() str[source]

Returns ambient brightness picked up by the sensor

get_move_detected() str[source]

Returns if move detected

switchbot_utility.switchbot_plug module

class switchbot_utility.switchbot_plug.SwitchbotPlug(deviceId)[source]

Bases: SwitchbotDevice, OnOffMixin

Switchbot Plug class

get_power() str[source]

Returns device power status

switchbot_utility.switchbot_plug_mini_jp module

class switchbot_utility.switchbot_plug_mini_jp.SwitchbotPlugMiniJP(deviceId)[source]

Bases: SwitchbotPlugMiniUS

Switchbot Plug Mini(US) class

switchbot_utility.switchbot_plug_mini_us module

class switchbot_utility.switchbot_plug_mini_us.SwitchbotPlugMiniUS(deviceId)[source]

Bases: SwitchbotPlug

Switchbot Plug Mini(US) class

get_electric_current() str[source]

Returns the current of the device at the moment, measured in Amp

get_electricity_of_day() str[source]

Returns the duration that device has been used during a day(min)

get_voltage() str[source]

Returns the voltage of the device, measured in Volt

get_weight() str[source]

Returns the power consumed in a day, measured in Watts

toggle() str[source]

Toggle plug state

switchbot_utility.switchbot_robot_vacuum_cleaner_s1 module

class switchbot_utility.switchbot_robot_vacuum_cleaner_s1.SwitchbotRobotVacuumCleanerS1(deviceId)[source]

Bases: SwitchbotDevice, BatteryMixin

Switchbot Robot Vacuum Cleaner S1 class

dock() str[source]

Return to charging dock

get_battery() str[source]

Returns the current battery level

get_online_status() str[source]

Returns the connection status of the device

get_working_status() str[source]

Returns the working status of the device

power_level(powerlevel: int) str[source]

Set suction power level

arg: 0-3

start() str[source]

Start vacuuming

stop() str[source]

Stop vacuuming

switchbot_utility.switchbot_robot_vacuum_cleaner_s1_plus module

class switchbot_utility.switchbot_robot_vacuum_cleaner_s1_plus.SwitchbotRobotVacuumCleanerS1Plus(deviceId)[source]

Bases: SwitchbotRobotVacuumCleanerS1

Switchbot Vacuum Cleaner S1 Plus class

switchbot_utility.switchbot_strip_light module

class switchbot_utility.switchbot_strip_light.SwitchbotStripLight(deviceId)[source]

Bases: SwitchbotDevice, OnOffMixin

Switchbot Strip Light class

get_brightness() str[source]

Returns the brightness value, range from 1 to 100

get_color() str[source]

Returns the color value, RGB ‘255:255:255’

get_power() str[source]

Returns ON/OFF state

set_brightness(brightness: int) str[source]

Set brightness

set_color(r: int, g: int, b: int) str[source]

Set color

args: r_value, g_value, b_value 0-255

toggle() str[source]

Toggle state

switchbot_utility.switchbot_webhook module

class switchbot_utility.switchbot_webhook.SwitchbotWebhook[source]

Bases: Switchbot

delete_webhook(url: str) str[source]

Delete webhook

query_details(url: str) str[source]

Get webhook detail configurations

query_url() str[source]

Get webhook configuration

setup_webhook(url: str) str[source]

Setup Webhook

update_webhook(url: str, enable: bool) str[source]

Update webhook url

Module contents