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
Use feed name as entity name in GeoJSON #108753
Conversation
Hey there @exxamalte, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
514d1bb
to
8e66a72
Compare
8e66a72
to
3af7aa5
Compare
Looks like the tests need updating to support this. I have no idea how to do that, sorry. |
Hm, I'm not sure if we're heading into the right direction here. Picking a random property and making it into the entity's name might look like a good idea, but there could be hundreds of feeds out there that don't define that particular property. The GeoJSON specification provides absolutely no schema for the properties. |
We aren't picking a random property - we're picking one specifically, called name. The official GeoJSON website uses it in their minimalist example. LeafletJS, which HA uses for Maps, also endorses this usage. This is also how ArcGIS uses the properties. In fact, I've only ever seen GeoJSON used in the way I've described. If we didn't find a name, we fallback to the previous case (the config_entry id). So, the change should not "break" for most people. |
The tests appear to fail because the
I think if you fix the linter error, this might just go away. Nevertheless it would be nice to add a test case to see if fetching the "name" property actually works. |
The linter warning is saying that the code looks pointless where we check if we can use the entity name or need to fall back to the config entry id or not. |
90951a4
to
92bcf27
Compare
Looks like I broke the CI - it's just sitting on |
I'm wondering now if we should actually make this a config parameter somewhere. Still default it to |
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.
Tests are failing, can you take a look
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Sorry, as above, I don't know how to fix that. The changes themselves work, simply the tests need to be updated. |
92bcf27
to
18a8e76
Compare
Sorry, I did try that and thought that it was failing. I must have tested it with a wrong feed (one that doesn't have a name propety). Can confirm it is working and the tests passed now :) Thank you very much for your help. |
I will update the documentation before we push this. |
Previously GeoJSON names were just the config entry ID. This is not very user friendly. Particularly so when there are many config entries and many, many entities from those same many config entries.
18a8e76
to
9c2a5d5
Compare
be4881d
to
cb8afbb
Compare
cb8afbb
to
39a1c27
Compare
I have added added tests to cover the new scenarios too. All tests passed. |
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 looks good to me. Thanks for adding the test case.
Oh btw, a name change isn't a breaking change |
Thanks. I wasn't sure, so went conservative. |
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.
Please address the comment in a new PR, if needed. Thanks
Breaking change
Previously GeoJSON names were just the config entry ID. This was not very user friendly. Particularly so when there are many config entries and many, many entities from those same many config entries. This is how they look today.
Proposed change
The proposal is to add support for entity name in GeoJSON. If unavailable in the data source, falls back to the config entry (same as today). This is how they look after.
Type of change
Checklist
ruff format homeassistant tests
)