miio.integrations.lumi.gateway.gateway module
Xiaomi Gateway implementation using Miio protecol.
- class miio.integrations.lumi.gateway.gateway.Gateway(ip: str | None = None, token: str | None = None, start_id: int = 0, debug: int = 0, lazy_discover: bool = True, timeout: int | None = None, *, model: str | None = None, push_server=None)[source]
Bases:
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
- actions() DescriptorCollection[ActionDescriptor]
Return device actions.
- configure_wifi(ssid, password, uid=0, extra_params=None)
Configure the wifi settings.
- descriptors() DescriptorCollection[Descriptor]
Return a collection containing all descriptors for the device.
- enable_telnet()[source]
Enable root telnet acces to the operating system, use login “admin” or “app”, no password.
- gateway_push_callback(action: str, params: str)[source]
Callback from the push server regarding the gateway itself.
- classmethod get_device_group()
- get_devices_from_dict(device_dict)[source]
Get SubDevices from a dict containing at least “mac”, “did”, “parent_id” and “model”.
This dict can be obtained with the micloud package: https://github.com/squachen/micloud
- 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.
- info(*, skip_cache=False) DeviceInfo
Get (and cache) miIO protocol information from the device.
This includes information about connected wlan network, and hardware and software versions.
- Parameters:
bool (skip_cache) – Skip the cache
- raw_command(command, parameters)
Send a raw command to the device. This is mostly useful when trying out commands which are not implemented by a given device instance.
- register_callback(id: str, callback: Callable[[str, str], None])[source]
Register a external callback function for updates of this subdevice.
- send(command: str, parameters: Any | None = None, retry_count: int | None = 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.
- send_handshake()
Send initial handshake to the device.
- sensors() DescriptorCollection[PropertyDescriptor]
Return read-only properties.
- settings() DescriptorCollection[PropertyDescriptor]
Return settable properties.
- status() DeviceStatus
Return device status.
- supports_miot() bool
Return True if the device supports miot commands.
This requests a single property (siid=1, piid=1) and returns True on success.
- update_state()
Return current update state.
- property devices
Return a dict of the already discovered devices.
- property mac
Return the mac address of the gateway.
- 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