-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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 KeyError from zwave_js diagnostics #74579
Conversation
Hey there @home-assistant/z-wave, mind taking a look at this pull request as it has been labeled with an integration ( |
"property_key_name": value.property_key_name, | ||
} | ||
|
||
# make the entity's primary value go missing |
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.
When does this happen normally?
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.
Reasons I can think of:
- A driver update that removes previous functionality. This happened in the past with alarm level and type values, that were removed by the driver in favor of notification values.
- A re-interview that failed. When you re-interview a device, the driver removes all of the values. If the interview fails in any way, the device still becomes ready but the previous values won't be recreated.
- A firmware upgrade or device-reconfiguration, which could disable previous functionality (I have a rely that can change exposed sensors based on configuration). Upon re-interview, the values would be lost.
Case 1 is the problem in my production system, as mentioned in the linked issue. This sensor has been included since first using Z-Wave JS, and I've never pruned the entities.
Case 2 is likely the cause for another of my Zooz water sensors as some of their devices are known to have interview failures. I'm pretty sure I was re-interviewing nodes during testing, and this happened.
Also, I'm only using the "value removed"
event to cause the problem in the test. In most real-life cases, it's just going to be the node state dump on connection is missing the value. I could also just delete the value directly from the Node instance, but manipulating these data structures directly doesn't seem to be common in the tests.
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!
Proposed change
Fixes an issue when attempting to download the Device diagnostics for a Z-Wave JS Device. If one of the Device's entities has a missing primary value, a
KeyError
is raised and the file fails to download. This change prevents the error and allows the file to be downloaded as usual.If the primary value is unknown, the "primary_value" in the diagnostic data is replaced with
None
, to signify the information is missing.Type of change
Additional information
I discovered this problem in my own production system while investigating the related issue.
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: