roborock.devices.traits.v1.volume

 1from dataclasses import dataclass
 2
 3from roborock.data.containers import RoborockBase
 4from roborock.devices.traits.v1 import common
 5from roborock.roborock_typing import RoborockCommand
 6
 7
 8@dataclass
 9class SoundVolume(RoborockBase):
10    """Dataclass for sound volume."""
11
12    volume: int | None = None
13    """Sound volume level (0-100)."""
14
15
16class SoundVolumeTrait(SoundVolume, common.V1TraitMixin):
17    """Trait for controlling the sound volume of a Roborock device."""
18
19    command = RoborockCommand.GET_SOUND_VOLUME
20    converter = common.SingleValueConverter(SoundVolume, "volume")
21
22    async def set_volume(self, volume: int) -> None:
23        """Set the sound volume of the device."""
24        await self.rpc_channel.send_command(RoborockCommand.CHANGE_SOUND_VOLUME, params=[volume])
25        self.volume = volume
@dataclass
class SoundVolume(roborock.data.containers.RoborockBase):
 9@dataclass
10class SoundVolume(RoborockBase):
11    """Dataclass for sound volume."""
12
13    volume: int | None = None
14    """Sound volume level (0-100)."""

Dataclass for sound volume.

SoundVolume(volume: int | None = None)
volume: int | None = None

Sound volume level (0-100).

class SoundVolumeTrait(SoundVolume, roborock.devices.traits.v1.common.V1TraitMixin):
17class SoundVolumeTrait(SoundVolume, common.V1TraitMixin):
18    """Trait for controlling the sound volume of a Roborock device."""
19
20    command = RoborockCommand.GET_SOUND_VOLUME
21    converter = common.SingleValueConverter(SoundVolume, "volume")
22
23    async def set_volume(self, volume: int) -> None:
24        """Set the sound volume of the device."""
25        await self.rpc_channel.send_command(RoborockCommand.CHANGE_SOUND_VOLUME, params=[volume])
26        self.volume = volume

Trait for controlling the sound volume of a Roborock device.

command = <RoborockCommand.GET_SOUND_VOLUME: 'get_sound_volume'>

The RoborockCommand used to fetch the trait data from the device (internal only).

converter = SingleValueConverter

The converter used to parse the response from the device (internal only).

async def set_volume(self, volume: int) -> None:
23    async def set_volume(self, volume: int) -> None:
24        """Set the sound volume of the device."""
25        await self.rpc_channel.send_command(RoborockCommand.CHANGE_SOUND_VOLUME, params=[volume])
26        self.volume = volume

Set the sound volume of the device.