roborock.devices.traits.v1.valley_electricity_timer

 1from roborock.data import ValleyElectricityTimer
 2from roborock.devices.traits.v1 import common
 3from roborock.roborock_typing import RoborockCommand
 4
 5_ENABLED_PARAM = "enabled"
 6
 7
 8class ValleyElectricityTimerTrait(ValleyElectricityTimer, common.V1TraitMixin, common.RoborockSwitchBase):
 9    """Trait for managing Valley Electricity Timer settings on Roborock devices."""
10
11    command = RoborockCommand.GET_VALLEY_ELECTRICITY_TIMER
12    converter = common.DefaultConverter(ValleyElectricityTimer)
13    requires_feature = "is_supported_valley_electricity"
14
15    @property
16    def is_on(self) -> bool:
17        """Return whether the Valley Electricity Timer is enabled."""
18        return self.enabled == 1
19
20    async def set_timer(self, timer: ValleyElectricityTimer) -> None:
21        """Set the Valley Electricity Timer settings of the device."""
22        await self.rpc_channel.send_command(RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER, params=timer.as_list())
23        await self.refresh()
24
25    async def clear_timer(self) -> None:
26        """Clear the Valley Electricity Timer settings of the device."""
27        await self.rpc_channel.send_command(RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER)
28        await self.refresh()
29
30    async def enable(self) -> None:
31        """Enable the Valley Electricity Timer settings of the device."""
32        await self.rpc_channel.send_command(
33            RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER,
34            params=self.as_list(),
35        )
36        # Optimistic update to avoid an extra refresh
37        self.enabled = 1
38
39    async def disable(self) -> None:
40        """Disable the Valley Electricity Timer settings of the device."""
41        await self.rpc_channel.send_command(
42            RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER,
43        )
44        # Optimistic update to avoid an extra refresh
45        self.enabled = 0
 9class ValleyElectricityTimerTrait(ValleyElectricityTimer, common.V1TraitMixin, common.RoborockSwitchBase):
10    """Trait for managing Valley Electricity Timer settings on Roborock devices."""
11
12    command = RoborockCommand.GET_VALLEY_ELECTRICITY_TIMER
13    converter = common.DefaultConverter(ValleyElectricityTimer)
14    requires_feature = "is_supported_valley_electricity"
15
16    @property
17    def is_on(self) -> bool:
18        """Return whether the Valley Electricity Timer is enabled."""
19        return self.enabled == 1
20
21    async def set_timer(self, timer: ValleyElectricityTimer) -> None:
22        """Set the Valley Electricity Timer settings of the device."""
23        await self.rpc_channel.send_command(RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER, params=timer.as_list())
24        await self.refresh()
25
26    async def clear_timer(self) -> None:
27        """Clear the Valley Electricity Timer settings of the device."""
28        await self.rpc_channel.send_command(RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER)
29        await self.refresh()
30
31    async def enable(self) -> None:
32        """Enable the Valley Electricity Timer settings of the device."""
33        await self.rpc_channel.send_command(
34            RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER,
35            params=self.as_list(),
36        )
37        # Optimistic update to avoid an extra refresh
38        self.enabled = 1
39
40    async def disable(self) -> None:
41        """Disable the Valley Electricity Timer settings of the device."""
42        await self.rpc_channel.send_command(
43            RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER,
44        )
45        # Optimistic update to avoid an extra refresh
46        self.enabled = 0

Trait for managing Valley Electricity Timer settings on Roborock devices.

command = <RoborockCommand.GET_VALLEY_ELECTRICITY_TIMER: 'get_valley_electricity_timer'>

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

converter = DefaultConverter

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

requires_feature = 'is_supported_valley_electricity'
is_on: bool
16    @property
17    def is_on(self) -> bool:
18        """Return whether the Valley Electricity Timer is enabled."""
19        return self.enabled == 1

Return whether the Valley Electricity Timer is enabled.

async def set_timer( self, timer: roborock.data.v1.v1_containers.ValleyElectricityTimer) -> None:
21    async def set_timer(self, timer: ValleyElectricityTimer) -> None:
22        """Set the Valley Electricity Timer settings of the device."""
23        await self.rpc_channel.send_command(RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER, params=timer.as_list())
24        await self.refresh()

Set the Valley Electricity Timer settings of the device.

async def clear_timer(self) -> None:
26    async def clear_timer(self) -> None:
27        """Clear the Valley Electricity Timer settings of the device."""
28        await self.rpc_channel.send_command(RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER)
29        await self.refresh()

Clear the Valley Electricity Timer settings of the device.

async def enable(self) -> None:
31    async def enable(self) -> None:
32        """Enable the Valley Electricity Timer settings of the device."""
33        await self.rpc_channel.send_command(
34            RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER,
35            params=self.as_list(),
36        )
37        # Optimistic update to avoid an extra refresh
38        self.enabled = 1

Enable the Valley Electricity Timer settings of the device.

async def disable(self) -> None:
40    async def disable(self) -> None:
41        """Disable the Valley Electricity Timer settings of the device."""
42        await self.rpc_channel.send_command(
43            RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER,
44        )
45        # Optimistic update to avoid an extra refresh
46        self.enabled = 0

Disable the Valley Electricity Timer settings of the device.