miio.gateway.gateway module

Xiaomi Gateway implementation using Miio protecol.

exception miio.gateway.gateway.GatewayException[source]

Bases: miio.exceptions.DeviceException

Exception for the Xioami Gateway communication.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
class miio.gateway.gateway.Gateway(ip: Optional[str] = None, token: Optional[str] = None, start_id: int = 0, debug: int = 0, lazy_discover: bool = True, *, model: Optional[str] = None, push_server=None)[source]

Bases: miio.device.Device

Main class representing the Xiaomi Gateway.

Use the given property getters to access specific functionalities such as alarm (for alarm controls) or light (for lights).

Commands whose functionality or parameters are unknown, feel free to implement! * toggle_device * toggle_plug * remove_all_bind * list_bind [0] * bind_page * bind * remove_bind

  • self.get_prop(“used_for_public”) # Return the ‘used_for_public’ status, return value: [0] or [1], probably this has to do with developer mode.

  • self.set_prop(“used_for_public”, state) # Set the ‘used_for_public’ state, value: 0 or 1, probably this has to do with developer mode.

  • welcome

  • set_curtain_level

  • get_corridor_on_time

  • set_corridor_light [“off”]

  • get_corridor_light -> “on”

  • set_default_sound

  • set_doorbell_push, get_doorbell_push [“off”]

  • set_doorbell_volume [100], get_doorbell_volume

  • set_gateway_volume, get_gateway_volume

  • set_clock_volume

  • set_clock

  • get_sys_data

  • update_neighbor_token [{“did”:x, “token”:x, “ip”:x}]

## property getters * ctrl_device_prop * get_device_prop_exp [[sid, list, of, properties]]

## scene * get_lumi_bind [“scene”, <page number>] for rooms/devices

clock(*args, **kwargs)
close()[source]

Cleanup all subscribed events and registered callbacks.

configure_wifi(ssid, password, uid=0, extra_params=None)

Configure the wifi settings.

discover_devices(*args, **kwargs)
enable_telnet(*args, **kwargs)
gateway_push_callback(action: str, params: str)[source]

Callback from the push server regarding the gateway itself.

get_developer_key(*args, **kwargs)
classmethod get_device_group()
get_devices_from_dict(*args, **kwargs)
get_illumination(*args, **kwargs)
get_prop(*args, **kwargs)
get_prop_exp(*args, **kwargs)
get_properties(properties, *, property_getter='get_prop', max_properties=None)

Request properties in slices based on given max_properties.

This is necessary as some devices have limitation on how many properties can be queried at once.

If max_properties is None, all properties are requested at once.

Parameters
  • properties (list) – List of properties to query from the device.

  • max_properties (int) – Number of properties that can be requested at once.

:return List of property values.

info(*args, **kwargs)
match_type_id(*args, **kwargs)
match_zigbee_model(*args, **kwargs)
push_callback(source_device: str, action: str, params: str)[source]

Callback from the push server.

raw_command(*args, **kwargs)
register_callback(id: str, callback: Callable[[str, str], None])[source]

Register a external callback function for updates of this subdevice.

remove_callback(id: str)[source]

Remove a external callback using its id.

send(command: str, parameters: Optional[Any] = None, retry_count: Optional[int] = None, *, extra_parameters=None) Any

Send a command to the device.

Basic format of the request: {“id”: 1234, “method”: command, “parameters”: parameters}

extra_parameters allows passing elements to the top-level of the request. This is necessary for some devices, such as gateway devices, which expect the sub-device identifier to be on the top-level.

Parameters
  • command (str) – Command to send

  • parameters (dict) – Parameters to send

  • retry_count (int) – How many times to retry on error

  • extra_parameters (dict) – Extra top-level parameters

  • model (str) – Force model to avoid autodetection

send_handshake()

Send initial handshake to the device.

set_developer_key(*args, **kwargs)
set_prop(*args, **kwargs)
setup_device(*args, **kwargs)
test_properties(*args, **kwargs)
timezone(*args, **kwargs)
update(url: str, md5: str)

Start an OTA update.

update_progress() int

Return current update progress [0-100].

update_state()

Return current update state.

property alarm: miio.gateway.alarm.Alarm

Return alarm control interface.

property device_id: int

Return device id (did), if available.

property devices

Return a dict of the already discovered devices.

property light: miio.gateway.light.Light

Return light control interface.

property mac

Return the mac address of the gateway.

property model: str

Return device model.

property radio: miio.gateway.radio.Radio

Return radio control interface.

property raw_id: int

Return the last used protocol sequence id.

retry_count = 3
property subdevice_model_map

Return the subdevice model map.

supported_models = ['lumi.gateway.v3', 'lumi.gateway.mieu01', 'lumi.gateway.mgl03', 'lumi.gateway.aqhm01', 'lumi.acpartner.v1', 'lumi.acpartner.v2', 'lumi.acpartner.v3']
timeout = 5
token: Optional[str]
property zigbee: miio.gateway.zigbee.Zigbee

Return zigbee control interface.