miio.integrations.lumi.gateway.devices.switch module

Xiaomi Zigbee switches.

class miio.integrations.lumi.gateway.devices.switch.Switch(gw: Gateway, dev_info: SubDeviceInfo, model_info: Dict | None = None)[source]

Bases: SubDevice

Base class for one channel switch subdevice that supports on/off.

class ChannelMap(value)[source]

Bases: IntEnum

Option to select wich channel to control.

channel_0 = 0
channel_1 = 1
channel_2 = 2
get_battery() int | None

Update the battery level, if available.

get_firmware_version() int | None

Returns firmware version.

get_property(property)

Get the value of a property of the subdevice.

get_property_exp(properties)

Get the value of a bunch of properties of the subdevice.

get_voltage() float | None

Update the battery voltage, if available.

off(channel: int = 0)[source]

Turn off a channel of the switch, default channel_0.

on(channel: int = 0)[source]

Turn on a channel of the switch, default channel_0.

push_callback(action: str, params: str)

Push callback received from the push server.

register_callback(id: str, callback: Callable[[str, str], None])

Register a external callback function for updates of this subdevice.

remove_callback(id: str)

Remove a external callback using its id.

send(command)

Send a command/query to the subdevice.

send_arg(command, arguments)

Send a command/query including arguments to the subdevice.

set_property(property, value)

Set a device property of the subdevice.

async subscribe_events()

subscribe to all subdevice events using the push server.

toggle(channel: int = 0)[source]

Toggle a channel of the switch, default channel_0.

unpair()

Unpair this device from the gateway.

async unsubscribe_events()

Unsubscibe from events registered in the gateway memory.

update()

Update all device properties.

property battery

Return the battery level in %.

property device_type

Return the device type name.

property firmware_version

Return the firmware version.

property model

Return the device model.

property name

Return the name of the device.

property status

Return sub-device status as a dict containing all properties.

property voltage

Return the battery voltage in V.

property zigbee_model

Return the zigbee device model.