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    requires_feature = "is_supported_valley_electricity"
13
14    @property
15    def is_on(self) -> bool:
16        """Return whether the Valley Electricity Timer is enabled."""
17        return self.enabled == 1
18
19    async def set_timer(self, timer: ValleyElectricityTimer) -> None:
20        """Set the Valley Electricity Timer settings of the device."""
21        await self.rpc_channel.send_command(RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER, params=timer.as_list())
22        await self.refresh()
23
24    async def clear_timer(self) -> None:
25        """Clear the Valley Electricity Timer settings of the device."""
26        await self.rpc_channel.send_command(RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER)
27        await self.refresh()
28
29    async def enable(self) -> None:
30        """Enable the Valley Electricity Timer settings of the device."""
31        await self.rpc_channel.send_command(
32            RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER,
33            params=self.as_list(),
34        )
35        # Optimistic update to avoid an extra refresh
36        self.enabled = 1
37
38    async def disable(self) -> None:
39        """Disable the Valley Electricity Timer settings of the device."""
40        await self.rpc_channel.send_command(
41            RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER,
42        )
43        # Optimistic update to avoid an extra refresh
44        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    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

Trait for managing Valley Electricity Timer settings on Roborock devices.

command = <RoborockCommand.GET_VALLEY_ELECTRICITY_TIMER: 'get_valley_electricity_timer'>
requires_feature = 'is_supported_valley_electricity'
is_on: bool
15    @property
16    def is_on(self) -> bool:
17        """Return whether the Valley Electricity Timer is enabled."""
18        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:
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()

Set the Valley Electricity Timer settings of the device.

async def clear_timer(self) -> None:
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()

Clear the Valley Electricity Timer settings of the device.

async def enable(self) -> None:
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

Enable the Valley Electricity Timer settings of the device.

async def disable(self) -> None:
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

Disable the Valley Electricity Timer settings of the device.