-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
Catch ClientConnectorError and TimeOutError in APSystems #132027
Conversation
Hey there @mawoka-myblock, @SonnenladenGmbH, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
try: | ||
status = await self._api.get_max_power() | ||
except ClientConnectorError: | ||
self._attr_available = False |
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.
See https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/log-when-unavailable
If internet/device/service is unavailable, log once when unavailable and once when back connected
It looks to me like you never log...
Edit: Or maybe it's because you don't want to log for each entity...
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.
This is true, the integration never logs the change. How is it supposed to be? Would it be reasonable to log for every platform (switch, number and sensor)? As each of them uses a kind of different method regarding the data fetching
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.
Standard way would be something like this:
self._attr_available = False | |
if self._attr_available: | |
_LOGGER.info(...offline) | |
self._attr_available = False | |
else: | |
if not self._attr_available: | |
_LOGGER.info(...back online) | |
self._attr_available = True |
But I don't know enough about apsystems to make a proper recommendation.
We don't want to flood, but I think we do recommend visibility for the user.
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.
But this would run on every update, wouldn't it?
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.
But this would run on every update, wouldn't it?
Yes, but we would implement a variable to remember if we have already logged the availability change.
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.
See https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/log-when-unavailable
If internet/device/service is unavailable, log once when unavailable and once when back connected
It looks to me like you never log...
Edit: Or maybe it's because you don't want to log for each entity...
This integration uses partly a DataUpdateCoordinator (https://developers.home-assistant.io/docs/integration_fetching_data?_highlight=fetching&_highlight=data#coordinated-single-api-poll-for-data-for-all-entities) and partly separate polling (https://developers.home-assistant.io/docs/integration_fetching_data?_highlight=fetching&_highlight=data#separate-polling-for-each-individual-entity).
With #131930 implemented we would log the availability for the coordinator. Which should in most cases also apply for the single entities. Maybe we can raise UpdatedFailed in #131930 for some more Exceptions, to get more cases covered?
I've run this fix today. The good thing is, after sunset, only one error message occurs and not one message every 30s, the hole night:
I will catch the TimeoutError also. |
I've tested this for a few days now. And for mee it seems good. |
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.
Thanks, @Thomas55555 👍
../Frenck
Breaking change
Proposed change
Use the same logic in the number platform, like in the switch platform:
core/homeassistant/components/apsystems/switch.py
Lines 42 to 48 in 98734eb
Benefits:
Bugfix, please include in next beta/patch release.
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: