miio.integrations.viomi.vacuum.viomivacuum module

Viomi Vacuum.

# https://github.com/rytilahti/python-miio/issues/550#issuecomment-552780952 # https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum/blob/ee10cbb3e98dba75d9c97791a6e1fcafc1281591/miio/lib/devices/vacuum.js # https://github.com/homebridge-xiaomi-roborock-vacuum/homebridge-xiaomi-roborock-vacuum/blob/ee10cbb3e98dba75d9c97791a6e1fcafc1281591/miio/lib/devices/viomivacuum.js

Features:

Main: - Area/Duration - Missing (get_clean_summary/get_clean_record - Battery - battery_life - Dock - set_charge - Start/Pause - set_mode_withroom - Modes (Vacuum/Vacuum&Mop/Mop) - set_mop/is_mop - Fan Speed (Silent/Standard/Medium/Turbo) - set_suction/suction_grade - Water Level (Low/Medium/High) - set_suction/water_grade

Settings: - Cleaning history - MISSING (cleanRecord) - Scheduled cleanup - get_ordertime - Vacuum along the edges - get_mode/set_mode - Secondary cleanup - set_repeat/repeat_cleaning - Mop or vacuum & mod mode - set_moproute/mop_route - DND(DoNotDisturb) - set_notdisturb/get_notdisturb - Voice On/Off - set_sound_volume/sound_volume - Remember Map - remember_map - Virtual wall/restricted area - MISSING - Map list - get_maps/rename_map/delete_map/set_map - Area editor - MISSING - Reset map - MISSING - Device leveling - MISSING - Looking for the vacuum-mop - Consumables statistics - get_properties - Remote Control - MISSING

Misc: - Get Properties - Language - set_language - Led - set_light - Rooms - get_ordertime (hack) - Clean History Path - MISSING (historyPath) - Map plan - MISSING (map_plan)

class miio.integrations.viomi.vacuum.viomivacuum.ViomiBinType(value)[source]

Bases: Enum

An enumeration.

NoBin = 0
Vacuum = 1
VacuumAndWater = 3
Water = 2
class miio.integrations.viomi.vacuum.viomivacuum.ViomiCarpetTurbo(value)[source]

Bases: Enum

An enumeration.

Medium = 1
Off = 0
Turbo = 2
class miio.integrations.viomi.vacuum.viomivacuum.ViomiConsumableStatus(data: List[int])[source]

Bases: ConsumableStatus

Consumable container for viomi vacuums.

Note that this exposes mop and mop_left that are not available in the base class, while returning zeroed timedeltas for sensor_dirty and sensor_dirty_left which it doesn’t report.

descriptors() DescriptorCollection[PropertyDescriptor]

Return the dict of sensors exposed by the status container.

Use @sensor and @setting decorators to define properties.

embed(name: str, other: DeviceStatus)

Embed another status container to current one.

This makes it easy to provide a single status response for cases where responses from multiple I/O calls is wanted to provide a simple interface for downstreams.

Internally, this will prepend the name of the other class to the attribute names, and override the __getattribute__ to lookup attributes in the embedded containers.

property cleaning_brush_cleaned_count: int | None

Return cleaning brush cleaned count.

property dustbin_auto_empty_used: int | None

Return dust_collection_work_times

property filter: timedelta

Filter usage time.

property filter_left: timedelta

How long until the filter should be changed.

property main_brush: timedelta

Main brush usage time.

property main_brush_left: timedelta

How long until the main brush should be changed.

property mop: timedelta

Return sensor_dirty_time

property mop_left: timedelta

How long until the mop should be changed.

property sensor_dirty: timedelta

Viomi has no sensor dirty, so we return zero here.

property sensor_dirty_left: timedelta

Viomi has no sensor dirty, so we return zero here.

property side_brush: timedelta

Side brush usage time.

property side_brush_left: timedelta

How long until the side brush should be changed.

property strainer_cleaned_count: int | None

Return strainer cleaned count.

class miio.integrations.viomi.vacuum.viomivacuum.ViomiEdgeState(value)[source]

Bases: Enum

An enumeration.

Off = 0
On = 2
Unknown = 1
Unknown2 = 5
class miio.integrations.viomi.vacuum.viomivacuum.ViomiLanguage(value)[source]

Bases: Enum

An enumeration.

CN = 1
EN = 2
class miio.integrations.viomi.vacuum.viomivacuum.ViomiMode(value)[source]

Bases: Enum

An enumeration.

CleanSpot = 4
CleanZone = 3
Mop = 2
Vacuum = 0
VacuumAndMop = 1
class miio.integrations.viomi.vacuum.viomivacuum.ViomiMovementDirection(value)[source]

Bases: Enum

An enumeration.

Backward = 4
Forward = 1
Left = 2
Right = 3
Stop = 5
Unknown = 10
class miio.integrations.viomi.vacuum.viomivacuum.ViomiPositionPoint(pos_x, pos_y, phi, update, plan_multiplicator=1)[source]

Bases: object

Vacuum position coordinate.

image_pos_x(offset, img_center)[source]

X coordinate on an image.

image_pos_y(offset, img_center)[source]

Y coordinate on an image.

property pos_x

X coordinate with multiplicator.

property pos_y

Y coordinate with multiplicator.

class miio.integrations.viomi.vacuum.viomivacuum.ViomiRoutePattern(value)[source]

Bases: Enum

Mopping pattern.

S = 0
Y = 1
class miio.integrations.viomi.vacuum.viomivacuum.ViomiVacuum(ip: str, token: str | None = None, start_id: int = 0, debug: int = 0, lazy_discover: bool = False, timeout: int | None = None, *, model: str | None = None)[source]

Bases: Device

Interface for Viomi vacuums (viomi.vacuum.v7).

actions() DescriptorCollection[ActionDescriptor]

Return device actions.

add_timer()[source]

Not implemented yet.

call_action(name: str, params=None)

Call action by name.

carpet_mode(mode: ViomiCarpetTurbo)[source]

Set the carpet mode.

This seems doing nothing on STYJ02YM

change_setting(name: str, params=None)

Change setting value.

clean_mode(mode: ViomiMode)[source]

Set the cleaning mode.

[vacuum, vacuumAndMop, mop, cleanzone, cleanspot]

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

Configure the wifi settings.

consumable_status() ViomiConsumableStatus[source]

Return information about consumables.

delete_map(map_id: int)[source]

Delete map.

delete_timer()[source]

Not implemented yet.

descriptors() DescriptorCollection[Descriptor]

Return a collection containing all descriptors for the device.

dnd_status()[source]

Returns do-not-disturb status.

fan_speed_presets() Dict[str, int][source]

Return available fan speed presets.

find()[source]

Find the robot.

get_current_position() ViomiPositionPoint | None[source]

Return the current position.

classmethod get_device_group()
get_maps() List[Dict[str, Any]][source]

Return map list.

[{‘name’: ‘MapName1’, ‘id’: 1598622255, ‘cur’: False},
{‘name’: ‘MapName2’, ‘id’: 1599508355, ‘cur’: True},

…]

get_positions(plan_multiplicator=1) List[ViomiPositionPoint][source]

Return the last positions.

plan_multiplicator scale up the coordinates values

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.

Returns:

List of property values.

get_rooms(map_id: int | None = None, map_name: str | None = None, refresh: bool = False)[source]

Return room ids and names.

get_scheduled_cleanup()[source]

Not implemented yet.

home()[source]

Return to home.

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

led(state: bool)[source]

Switch the button leds on or off.

This seems doing nothing on STYJ02YM

move(direction: ViomiMovementDirection, duration=0.5)[source]

Manual movement.

pause()[source]

Pause cleaning.

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.

Parameters:
  • command (str) – Command to send

  • parameters (dict) – Parameters to send

rename_map(map_id: int, map_name: str)[source]

Rename map.

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.

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.

sensors() DescriptorCollection[PropertyDescriptor]

Return read-only properties.

set_dnd(disable: bool, start_hr: int, start_min: int, end_hr: int, end_min: int)[source]

Set do-not-disturb.

Parameters:
  • start_hr (int) – Start hour

  • start_min (int) – Start minute

  • end_hr (int) – End hour

  • end_min (int) – End minute

set_edge(state: ViomiEdgeState)[source]

Vacuum along edges.

This is valid for a single cleaning.

set_fan_speed(speed: ViomiVacuumSpeed)[source]

Set fanspeed [silent, standard, medium, turbo].

set_fan_speed_preset(speed_preset: int) None[source]

Set fan speed preset speed.

set_language(language: ViomiLanguage)[source]

Set the device’s audio language.

This seems doing nothing on STYJ02YM

set_map(map_id: int)[source]

Change current map.

set_power(on: bool)[source]

Set power on or off.

set_remember_map(state: bool)[source]

Set remember map state.

set_repeat_cleaning(state: bool)[source]

Set or Unset repeat mode (Secondary cleanup).

set_route_pattern(route_pattern: ViomiRoutePattern)[source]

Set the mop route pattern.

set_sound_volume(volume: int)[source]

Switch the voice on or off.

set_water_grade(watergrade: ViomiWaterGrade)[source]

Set water grade.

[low, medium, high]

settings() DescriptorCollection[PropertyDescriptor]

Return settable properties.

start()[source]

Start cleaning.

start_with_room(rooms)[source]

Start cleaning specific rooms.

status() ViomiVacuumStatus[source]

Retrieve properties.

stop()[source]

Validate that Stop cleaning.

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(url: str, md5: str)

Start an OTA update.

update_progress() int

Return current update progress [0-100].

update_state()

Return current update state.

property device_id: int

Return the device id (did).

property model: str

Return device model.

property raw_id: int

Return the last used protocol sequence id.

retry_count = 10
supported_models = ['viomi.vacuum.v6', 'viomi.vacuum.v7', 'viomi.vacuum.v8', 'viomi.vacuum.v10', 'viomi.vacuum.v13']
timeout = 5
token: str | None
class miio.integrations.viomi.vacuum.viomivacuum.ViomiVacuumSpeed(value)[source]

Bases: Enum

An enumeration.

Medium = 2
Silent = 0
Standard = 1
Turbo = 3
class miio.integrations.viomi.vacuum.viomivacuum.ViomiVacuumState(value)[source]

Bases: Enum

An enumeration.

Cleaning = 3
Docked = 5
Idle = 1
IdleNotDocked = 0
Mopping = 7
Paused = 2
Returning = 4
Unknown = -1
VacuumingAndMopping = 6
class miio.integrations.viomi.vacuum.viomivacuum.ViomiVacuumStatus(data)[source]

Bases: DeviceStatus

descriptors() DescriptorCollection[PropertyDescriptor]

Return the dict of sensors exposed by the status container.

Use @sensor and @setting decorators to define properties.

embed(name: str, other: DeviceStatus)

Embed another status container to current one.

This makes it easy to provide a single status response for cases where responses from multiple I/O calls is wanted to provide a simple interface for downstreams.

Internally, this will prepend the name of the other class to the attribute names, and override the __getattribute__ to lookup attributes in the embedded containers.

property battery: int

Battery in percentage.

property bin_type: ViomiBinType

Type of the inserted bin.

property charging: bool

True if battery is charging.

Note: When the battery is at 100%, device reports that it is not charging.

property clean_area: float

Cleaned area in square meters.

property clean_mode: ViomiMode

Whether mopping is enabled and if so which mode.

property clean_time: timedelta

Cleaning time.

property current_map_id: float

Current map id.

property edge_state: ViomiEdgeState

Vaccum along the edges.

The settings is valid once 0: Off 1: Unknown 2: On 5: Unknown

property error: str | None

String presentation for the error code.

property error_code: int

Error code from vacuum.

property fanspeed: ViomiVacuumSpeed

Current fan speed.

property has_map: bool

True if device has map?

property has_new_map: bool

True if the device has scanned a new map (like a new floor).

property hw_info: str

Hardware info.

property is_on: bool

True if device is working.

property led_state: bool

Led state.

This seems doing nothing on STYJ02YM

property map_number: int

Number of saved maps.

property mop_attached: bool

True if the mop is attached.

property order_time: int

Unknown.

property remember_map: bool

True to remember the map.

property repeat_cleaning: bool

Secondary clean up state.

True if the cleaning is performed twice

property route_pattern: ViomiRoutePattern | None

Pattern mode.

property sound_volume: int

Voice volume level (from 0 to 10, 0 means Off).

property start_time: int

Unknown.

property state

State of the vacuum.

property vacuum_state: VacuumState

Return simplified vacuum state.

property water_grade: ViomiWaterGrade

Water grade.

property water_percent: int

FIXME: ??? int or bool.

property zone_data: int

Unknown.

class miio.integrations.viomi.vacuum.viomivacuum.ViomiWaterGrade(value)[source]

Bases: Enum

An enumeration.

High = 13
Low = 11
Medium = 12