Make Device.update_state and Device.push_state_update wait for a reply from the AC#108
Make Device.update_state and Device.push_state_update wait for a reply from the AC#108mlesniew wants to merge 2 commits intocmroche:masterfrom
Conversation
This change makes the `Device.update_state` wait for the properties to actually be updated before returning. The wait time is limited by the `wait_for` parameter (which was previously present, but not used). This way, when `Device.update_state` returns, properties are guaranteed to be updated. This commit also fixes a few tests, which appear to have had some bugs.
…se from the AC This change makes the `Device.push_state_update` wait for the a response from the AC to be received before returning. The wait time is limited by the `wait_for` parameter (which was previously present, but not used). This way callers of `Device.push_state_update` can be sure that their request reached the AC when the method returns.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #108 +/- ##
==========================================
+ Coverage 95.75% 96.08% +0.32%
==========================================
Files 8 8
Lines 730 740 +10
==========================================
+ Hits 699 711 +12
+ Misses 31 29 -2 ☔ View full report in Codecov by Sentry. |
|
This doesn't have what I think should be the expected behaviour when there are rapid subsequent calls to In these cases, the first successful response sets the event and clears all preceeding and subsequent calls. |
| self.device_info: DeviceInfo = device_info | ||
|
|
||
| self._bind_timeout = bind_timeout | ||
| self._update_state_complete = asyncio.Event() |
There was a problem hiding this comment.
An event signal at this level will be shared across multiple calls to update_state and not behave correctly.
The
Device.update_stateandDevice.push_state_updatemethods previously sent requests to the remote device without awaiting a response, leaving the caller unable to verify whether the operation was successfully received and confirmed.This PR modifies that behavior. Both methods now wait for a response from the device before returning.
Additionally, although both methods already accepted a
wait_forparameter, but it was ignored. This parameter is now used as the timeout for receiving the response. If no response is received within the specified time, an exception is raised.