roborock.devices.traits.v1.consumeable

Trait for managing consumable attributes.

A consumable attribute is one that is expected to be replaced or refilled periodically, such as filters, brushes, etc.

 1"""Trait for managing consumable attributes.
 2
 3A consumable attribute is one that is expected to be replaced or refilled
 4periodically, such as filters, brushes, etc.
 5"""
 6
 7from enum import StrEnum
 8from typing import Self
 9
10from roborock.data import Consumable
11from roborock.devices.traits.v1 import common
12from roborock.roborock_typing import RoborockCommand
13
14__all__ = [
15    "ConsumableTrait",
16]
17
18
19class ConsumableAttribute(StrEnum):
20    """Enum for consumable attributes."""
21
22    SENSOR_DIRTY_TIME = "sensor_dirty_time"
23    FILTER_WORK_TIME = "filter_work_time"
24    SIDE_BRUSH_WORK_TIME = "side_brush_work_time"
25    MAIN_BRUSH_WORK_TIME = "main_brush_work_time"
26
27    @classmethod
28    def from_str(cls, value: str) -> Self:
29        """Create a ConsumableAttribute from a string value."""
30        for member in cls:
31            if member.value == value:
32                return member
33        raise ValueError(f"Unknown ConsumableAttribute: {value}")
34
35
36class ConsumableTrait(Consumable, common.V1TraitMixin):
37    """Trait for managing consumable attributes on Roborock devices.
38
39    After the first refresh, you can tell what consumables are supported by
40    checking which attributes are not None.
41    """
42
43    command = RoborockCommand.GET_CONSUMABLE
44
45    async def reset_consumable(self, consumable: ConsumableAttribute) -> None:
46        """Reset a specific consumable attribute on the device."""
47        await self.rpc_channel.send_command(RoborockCommand.RESET_CONSUMABLE, params=[consumable.value])
48        await self.refresh()
37class ConsumableTrait(Consumable, common.V1TraitMixin):
38    """Trait for managing consumable attributes on Roborock devices.
39
40    After the first refresh, you can tell what consumables are supported by
41    checking which attributes are not None.
42    """
43
44    command = RoborockCommand.GET_CONSUMABLE
45
46    async def reset_consumable(self, consumable: ConsumableAttribute) -> None:
47        """Reset a specific consumable attribute on the device."""
48        await self.rpc_channel.send_command(RoborockCommand.RESET_CONSUMABLE, params=[consumable.value])
49        await self.refresh()

Trait for managing consumable attributes on Roborock devices.

After the first refresh, you can tell what consumables are supported by checking which attributes are not None.

command = <RoborockCommand.GET_CONSUMABLE: 'get_consumable'>
async def reset_consumable( self, consumable: roborock.devices.traits.v1.consumeable.ConsumableAttribute) -> None:
46    async def reset_consumable(self, consumable: ConsumableAttribute) -> None:
47        """Reset a specific consumable attribute on the device."""
48        await self.rpc_channel.send_command(RoborockCommand.RESET_CONSUMABLE, params=[consumable.value])
49        await self.refresh()

Reset a specific consumable attribute on the device.