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
Avoid removing zwave_js devices for non-ready nodes #59964
Conversation
Hey there @home-assistant/z-wave, mind taking a look at this pull request as it has been labeled with an integration ( |
@MartinHjelmare I'm still planning to complete this, just haven't had much time to do so recently. I can confirm that your comments about the Value references are correct. After replacing the node, the entity states do not change when the device does something. That's something I didn't pay attention to earlier, good catch. |
Latest commits are working, when a node is replaced all of the entities go unavailable until the node becomes ready. After ready state, the entities are all working again, including the node status sensor. When a node is replace, the driver will send "value removed" and a corresponding "metadata updated" event for each value (I'm not sure why the metadata updated event is there). I'm using that event to trigger an entity to remove itself. It might be more appropriate for the node removal event to also trigger entity removals (or instead of), in case some value was missed. I wasn't sure what the correct way is to tell all entities to remove themselves. The node status sensor is special, which no associated value Id, so I'm using the event dispatcher to send a message. It's a little awkward to send the event, as it relies on knowing how the entity's unique ID is made. Looks like I need to add some tests as well, I'll do that after I get some feedback, since I'm not so sure about this approach. |
Sounds good. I think it's ok to use the value removed event to trigger an entity remove. |
This reverts commit f900e5f.
Sorry for the rebase, I had an dev environment issue that I thought might be related to being out of date. Also resolved a merge conflict in the test code. |
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.
Great!
this issue seems to be coming up more and more often - as a result I've tagged this for a patch release |
Proposed change
If the zwave_js integration receives a
"node added"
event for a node that is not ready but matches an already created device, it will remove the device and re-create it, even if the node is the correct/original one. Removing the device loses all of the user device and entity customization (naming, etc.). Normally, this kind of event is only seen when a node has been included for the first time. It is also emitted for the following scenarios:Additionally, a third case also causes a device removal: a product name is changed in the driver config file. The device replacement logic mistakenly believes a different node has replaced the original since the labels no longer match.
To correct this, the device registration logic has two main changes:
Type of change
Additional 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: