-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Handle broadband_data being other types #147589
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
base: dev
Are you sure you want to change the base?
Conversation
I don't have the full dev setup ready right now, so I'm unable to run the tests and only made the as a custom component in my regular HA system when trying the fix. |
return self.coordinator.data["broadband"]["isBroadbandConnected"] | ||
broadband_data = self.coordinator.data.get("broadband") | ||
if not broadband_data: | ||
return 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.
Should this be False or None (unknown)?
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.
Not sure since I didn't manage to log the invalid data when it did happen.
broadband_data = self.coordinator.data.get("broadband") | ||
if not broadband_data: |
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.
We can use a wallrus operator there.
return False | ||
|
||
# Handle case where broadband_data is a list | ||
if isinstance(broadband_data, list): |
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.
How does that look?
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 was a suggestion from my AI code editor, not sure, should I remove it?
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Proposed change
I got this error randomly and it made Verisure auth expire for some reason. Couldn't reproduce it later, but this fix will hopefully handle the unexpected values better.
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: