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
Make sure ValueNotification includes the latest event data #156
Make sure ValueNotification includes the latest event data #156
Conversation
…ification includes latest value
@kpine can you take a look at this and see if it makes sense since you spotted this immediately? |
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 working fine for me. I took a slightly different approach, same result.
# append metadata if value metadata is available
value = self.values.get(_get_value_id_from_dict(self, event.data["args"]))
if value:
value.update(event.data["args"])
value_notification = ValueNotification(self, value.data)
else:
value_notification = ValueNotification(self, event.data["args"])
event.data["value_notification"] = value_notification
I was wondering, why is |
To test this I'd create a Value instance on the node and then create an event coming in with new data, that should trigger a ValueNotification event. The |
Yes, it doesn't sound like the Value state should be updated when reading the docs about ValueNotification event: |
Is there any pre-existing method to do this? |
ah, perhaps it does... |
value_notification.metadata.update(value.metadata.data) |
Just tested on my prod setup, this works, and resolves home-assistant/core#47432
|
So it looks like my tests are missing a value in the |
actually, the |
The problem with this approach is that
|
I think the endpoint is not included from the ValueNotification, so the endpoint shouldn't be included in the HA event? |
The notification is for a value that does have an endpoint. There's a third option, see my upcoming commit |
Looks good! FYI, my scene activation and basic set events do include endpoint from the server. |
In #154 the order of operations for creating the
ValueNotification
was wrong and led to the value that came in the notification being returned as the value that we was previously in the state (see home-assistant/core#47432). This fixes the order of operations.I could use some help writing some good test cases for this one, I don't think we have enough given all the issues that have occurred as we try to fix this