Handle somfy error 404 during setup#41298
Merged
balloob merged 2 commits intohome-assistant:devfrom Oct 6, 2020
Merged
Conversation
tetienne
commented
Oct 5, 2020
| data[DEVICES] = await hass.async_add_executor_job(data[API].get_devices) | ||
| except HTTPError as err: | ||
| _LOGGER.warning("Cannot update devices: %s", err.response.status_code) | ||
| data[DEVICES] = [] |
Contributor
Author
There was a problem hiding this comment.
Allow to avoid the error KeyError: 'devices' during the setup.
Member
There was a problem hiding this comment.
This also means that if fetching ever becomes an error, it will also override all devices.
Wouldn't it be better if we initialize this constant with an empty list and let errors not mess with it ?
Contributor
Author
There was a problem hiding this comment.
You are right, I think about it also and hesitate. I will make the modification.
balloob
requested changes
Oct 6, 2020
| data[DEVICES] = await hass.async_add_executor_job(data[API].get_devices) | ||
| except HTTPError as err: | ||
| _LOGGER.warning("Cannot update devices: %s", err.response.status_code) | ||
| data[DEVICES] = [] |
Member
There was a problem hiding this comment.
This also means that if fetching ever becomes an error, it will also override all devices.
Wouldn't it be better if we initialize this constant with an empty list and let errors not mess with it ?
balloob
approved these changes
Oct 6, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change
Proposed change
In some cases, for instance when the user haven't any devices supported by the Somfy API, Somfy returns an error 404. In such case, I have default the devices list to empty.
Type of change
Example entry for
configuration.yaml:# Example configuration.yamlAdditional information
Checklist
black --fast 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..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: