Skip to content

Make Device.update_state and Device.push_state_update wait for a reply from the AC#108

Open
mlesniew wants to merge 2 commits intocmroche:masterfrom
mlesniew:fix_device_wait_for_param_handling
Open

Make Device.update_state and Device.push_state_update wait for a reply from the AC#108
mlesniew wants to merge 2 commits intocmroche:masterfrom
mlesniew:fix_device_wait_for_param_handling

Conversation

@mlesniew
Copy link
Contributor

The Device.update_state and Device.push_state_update methods 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_for parameter, 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.

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
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.08%. Comparing base (7122cdd) to head (5dbd56e).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@cmroche
Copy link
Owner

cmroche commented Jan 10, 2026

This doesn't have what I think should be the expected behaviour when there are rapid subsequent calls to update_state and it'll be exacerbated if any reply from the AC gets dropped since it's UDP over WIFI it's likely to happen eventually.

In these cases, the first successful response sets the event and clears all preceeding and subsequent calls.

@cmroche cmroche self-requested a review January 10, 2026 17:14
self.device_info: DeviceInfo = device_info

self._bind_timeout = bind_timeout
self._update_state_complete = asyncio.Event()
Copy link
Owner

@cmroche cmroche Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An event signal at this level will be shared across multiple calls to update_state and not behave correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants