-
-
Notifications
You must be signed in to change notification settings - Fork 14
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: prefer given SimpleItem if available #502
Conversation
Awesome! I'll get back to you during the weekend, you can start by adding a test that covers this situation |
49908c8
to
c04212c
Compare
added a test! |
I'll try to fix one tomorrow, is it a property changed you want? what should the configuration be? |
c04212c
to
ebb3c10
Compare
After further thinking, I don't think we need a payload to test for backwards compatibility after this fix, this should have already been done by other test payloads (like I have corrected the formatting objected to by the workflow and pushed the branch. |
starting with Axis OS 11.11, several SimpleItem entries are sent, which means that the existing method of determining the value fails
ebb3c10
to
9cbe29a
Compare
rewrote filter to generator expression: python/mypy#12682 (comment) - item = next(filter(lambda x: x.get("@Name", "") == prefer, item), item[0])
+ item = next(
+ (item for item in item if item.get("@Name", "") == prefer), item[0]
+ ) |
if prefer is None: | ||
item = item[0] | ||
else: | ||
item = next( | ||
(item for item in item if item.get("@Name", "") == prefer), item[0] | ||
) |
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.
Sorry for not commenting earlier, I've been thinking if this would better keep the whole dict as the other information also could be interesting to expose. What do you think
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.
It might be interesting, but I didn't quite understand the interaction of all components and just wanted a minimally invasive fix for the bug.
I will try to get back to you by tomorrow night |
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!
Just a note in case it becomes relevant later, this issue resolved itself on my Axis cameras before the version with this fix was rolled out. |
If it happened once it can happen again. So its good to keep. Thanks for the update |
fixes: home-assistant/core#123617
Starting with Axis OS 11.11, several SimpleItem entries are sent, which means that the existing method of determining the value fails.
I have extended
extract_name_value
to prefer a certain SimpleItemactive
if it exists.I have tried to keep it as downward compatible as possible, but I can only test with Axis OS 11.11.109 and ObjectAnalytics.
payload example: