-
-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Fix status update loop in bluesound integration #123790
Fix status update loop in bluesound integration #123790
Conversation
Hey there @thrawnarn, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
except (TimeoutError, ClientError): | ||
_LOGGER.error( | ||
"Node %s:%s is offline, retrying later", self.host, self.port | ||
) | ||
await asyncio.sleep(NODE_OFFLINE_CHECK_TIMEOUT) | ||
except CancelledError: | ||
_LOGGER.debug( | ||
"Stopping the polling of node %s:%s", self.host, self.port | ||
) | ||
return | ||
except Exception: |
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.
In the future, can the library raise more specific errors?
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.
And maybe add test coverage
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.
Maybe something like received unexpected response from player
when the response parsing fails, but nothing we can act on in home assistant. Or something like a PlayerError
, which gets raised whenever anything during the request fails.
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.
I mean more like, currently we catch 4 exceptions, it would be nice if the library could for example catch TimeoutError
and ClientError
and raise NodeOfflineError
. This example is a nice to have, but it would be nice to give that bit of context to either CancelledError
(when does it cancel? What is the state of the device?).
I am getting sidetracked lol. My original point was that we don't want to catch bare Exceptions outside of the config flow. So we'd rather catch the individual types than have a catch-all.
Proposed change
This integration has a loop which fetches the current status. There was a recursive call to
self.start_polling
, which i removed in a previous PR. This PR removes the recursion and uses the existing while loop for retries.I also added
_attr_available
and removed the use of a custom attribute_is_online
, which had the same purpose internally.Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: