-
Notifications
You must be signed in to change notification settings - Fork 75
Ensure traits to always reflect the the status of commands #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
2368bef
4fed92b
c35bd19
27ec017
5c48f61
cc783d7
da0336e
a9e3235
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,11 @@ def is_on(self) -> bool: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def enable(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Enable the child lock.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 1}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.lock_status = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def disable(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Disable the child lock.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 0}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | |
| self.lock_status = 1 | |
| async def disable(self) -> None: | |
| """Disable the child lock.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh | |
| self.lock_status = 1 | |
| async def disable(self) -> None: | |
| """Disable the child lock.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "Optimistcally" should be "Optimistically"
| # Optimistcally update state to avoid an extra refresh | |
| self.lock_status = 1 | |
| async def disable(self) -> None: | |
| """Disable the child lock.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh | |
| self.lock_status = 1 | |
| async def disable(self) -> None: | |
| """Disable the child lock.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimistic state update occurs after the command is sent, but if the command fails with an exception, the state will remain inconsistent. Consider moving the state update before the command and reverting on exception, or wrapping in a try-except to only update on success.
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 1}) | |
| # Optimistcally update state to avoid an extra refresh | |
| self.lock_status = 1 | |
| async def disable(self) -> None: | |
| """Disable the child lock.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistcally update state to avoid an extra refresh | |
| self.lock_status = 0 | |
| try: | |
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 1}) | |
| except Exception: | |
| # Optionally, log the exception here | |
| raise | |
| else: | |
| # Optimistically update state to avoid an extra refresh | |
| self.lock_status = 1 | |
| async def disable(self) -> None: | |
| """Disable the child lock.""" | |
| try: | |
| await self.rpc_channel.send_command(RoborockCommand.SET_CHILD_LOCK_STATUS, params={_STATUS_PARAM: 0}) | |
| except Exception: | |
| # Optionally, log the exception here | |
| raise | |
| else: | |
| # Optimistically update state to avoid an extra refresh | |
| self.lock_status = 0 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,18 +18,24 @@ def is_on(self) -> bool: | |||||||||||||||||||||||||||||||||
| async def set_dnd_timer(self, dnd_timer: DnDTimer) -> None: | ||||||||||||||||||||||||||||||||||
| """Set the Do Not Disturb (DND) timer settings of the device.""" | ||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.SET_DND_TIMER, params=dnd_timer.as_list()) | ||||||||||||||||||||||||||||||||||
| await self.refresh() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| async def clear_dnd_timer(self) -> None: | ||||||||||||||||||||||||||||||||||
| """Clear the Do Not Disturb (DND) timer settings of the device.""" | ||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.CLOSE_DND_TIMER) | ||||||||||||||||||||||||||||||||||
| await self.refresh() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| async def enable(self) -> None: | ||||||||||||||||||||||||||||||||||
| """Set the Do Not Disturb (DND) timer settings of the device.""" | ||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command( | ||||||||||||||||||||||||||||||||||
| RoborockCommand.SET_DND_TIMER, | ||||||||||||||||||||||||||||||||||
| params=self.as_list(), | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||
| self.enabled = 1 | ||||||||||||||||||||||||||||||||||
|
Comment on lines
27
to
+35
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| async def disable(self) -> None: | ||||||||||||||||||||||||||||||||||
| """Disable the Do Not Disturb (DND) timer settings of the device.""" | ||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.CLOSE_DND_TIMER) | ||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "Optimistcally" should be "Optimistically"
| # Optimistcally update state to avoid an extra refresh | |
| self.enabled = 1 | |
| async def disable(self) -> None: | |
| """Disable the Do Not Disturb (DND) timer settings of the device.""" | |
| await self.rpc_channel.send_command(RoborockCommand.CLOSE_DND_TIMER) | |
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh | |
| self.enabled = 1 | |
| async def disable(self) -> None: | |
| """Disable the Do Not Disturb (DND) timer settings of the device.""" | |
| await self.rpc_channel.send_command(RoborockCommand.CLOSE_DND_TIMER) | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimistic state update occurs after the command is sent, but if the command fails with an exception, the state will remain inconsistent. Consider moving the state update before the command and reverting on exception, or wrapping in a try-except to only update on success.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,11 @@ def is_on(self) -> bool: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def enable(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Enable the Flow LED status.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 1}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.status = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def disable(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Disable the Flow LED status.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 0}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the Flow LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the Flow LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimistic state update occurs after the command is sent, but if the command fails with an exception, the state will remain inconsistent. Consider moving the state update before the command and reverting on exception, or wrapping in a try-except to only update on success.
| # Optimistcally update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the Flow LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh, but only if command succeeds | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the Flow LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistically update state to avoid an extra refresh, but only if command succeeds |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "Optimistcally" should be "Optimistically"
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimistic state update occurs after the command is sent, but if the command fails with an exception, the state will remain inconsistent. Consider moving the state update before the command and reverting on exception, or wrapping in a try-except to only update on success.
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 1}) | |
| # Optimistcally update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the Flow LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 0}) | |
| # Optimistcally update state to avoid an extra refresh | |
| self.status = 0 | |
| try: | |
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 1}) | |
| except Exception: | |
| # Optionally, log the exception here | |
| raise | |
| else: | |
| # Optimistically update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the Flow LED status.""" | |
| try: | |
| await self.rpc_channel.send_command(RoborockCommand.SET_FLOW_LED_STATUS, params={_STATUS_PARAM: 0}) | |
| except Exception: | |
| # Optionally, log the exception here | |
| raise | |
| else: | |
| # Optimistically update state to avoid an extra refresh | |
| self.status = 0 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,10 +19,14 @@ def is_on(self) -> bool: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def enable(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Enable the LED status.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.SET_LED_STATUS, params=[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.status = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
21
to
+23
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def disable(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Disable the LED status.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.rpc_channel.send_command(RoborockCommand.SET_LED_STATUS, params=[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optimistcally update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_LED_STATUS, params=[0]) | |
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_LED_STATUS, params=[0]) | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "Optimistcally" should be "Optimistically"
| # Optimistcally update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_LED_STATUS, params=[0]) | |
| # Optimistcally update state to avoid an extra refresh | |
| # Optimistically update state to avoid an extra refresh | |
| self.status = 1 | |
| async def disable(self) -> None: | |
| """Disable the LED status.""" | |
| await self.rpc_channel.send_command(RoborockCommand.SET_LED_STATUS, params=[0]) | |
| # Optimistically update state to avoid an extra refresh |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimistic state update occurs after the command is sent, but if the command fails with an exception, the state will remain inconsistent. Consider moving the state update before the command and reverting on exception, or wrapping in a try-except to only update on success.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,20 +19,26 @@ def is_on(self) -> bool: | |
| async def set_timer(self, timer: ValleyElectricityTimer) -> None: | ||
| """Set the Valley Electricity Timer settings of the device.""" | ||
| await self.rpc_channel.send_command(RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER, params=timer.as_list()) | ||
| await self.refresh() | ||
|
|
||
| async def clear_timer(self) -> None: | ||
| """Clear the Valley Electricity Timer settings of the device.""" | ||
| await self.rpc_channel.send_command(RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER) | ||
| await self.refresh() | ||
|
|
||
| async def enable(self) -> None: | ||
| """Enable the Valley Electricity Timer settings of the device.""" | ||
| await self.rpc_channel.send_command( | ||
| RoborockCommand.SET_VALLEY_ELECTRICITY_TIMER, | ||
| params=self.as_list(), | ||
| ) | ||
| # Optimistcally update state to avoid an extra refresh | ||
|
||
| self.enabled = 1 | ||
|
allenporter marked this conversation as resolved.
Comment on lines
27
to
+36
|
||
|
|
||
| async def disable(self) -> None: | ||
| """Disable the Valley Electricity Timer settings of the device.""" | ||
| await self.rpc_channel.send_command( | ||
| RoborockCommand.CLOSE_VALLEY_ELECTRICITY_TIMER, | ||
| ) | ||
| # Optimistcally update state to avoid an extra refresh | ||
|
||
| self.enabled = 0 | ||
|
allenporter marked this conversation as resolved.
Comment on lines
34
to
+44
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,3 +24,4 @@ class SoundVolumeTrait(SoundVolume, common.V1TraitMixin): | |||||
| async def set_volume(self, volume: int) -> None: | ||||||
| """Set the sound volume of the device.""" | ||||||
| await self.rpc_channel.send_command(RoborockCommand.CHANGE_SOUND_VOLUME, params=[volume]) | ||||||
| self.volume = volume | ||||||
|
||||||
| self.volume = volume | |
| await self.refresh() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimistic state update occurs after the command is sent, but if the command fails with an exception, the state will remain inconsistent. Consider moving the state update before the command and reverting on exception, or wrapping in a try-except to only update on success.