-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
Pollen.com: Entity Registry updates and cleanup #12361
Conversation
What does this mean? We don't duplicate entities with the registry. We only make sure that they get the same entity ID each time |
datas[data_key], | ||
params, | ||
name, | ||
icon | ||
icon, | ||
adler32(str(config[CONF_ZIP_CODE]).encode('utf-8')) |
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.
Why would you do this? Why not just pass the zip ?
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.
Fighting a cold and my brain was locked on what I did for AirVisual. Will simplify.
@property | ||
def unique_id(self): | ||
"""Return a unique, HASS-friendly identifier for this entity.""" | ||
return '{0}_{1}'.format(self._entity_id, slugify(self._name)) |
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.
Names are configurable and thus not unique.
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.
"Name" is a misnomer here: those are defined within CONDITIONS
(example: Allergy Index: Forecasted Average
). The user cannot change them.
"""Initialize the sensor.""" | ||
self._attrs = {} | ||
self._icon = icon | ||
self._name = name | ||
self._data_params = data_params | ||
self._state = None | ||
self._unit = None | ||
self._entity_id = entity_id |
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 not an entity id. Do you mean unique id?
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.
You're overthinking this. Just pass zip code as unique id. Don't use zlib, don't use name.
@balloob RE: my breaking change note, I was stating that this PR changes the unique ID for these sensors (thus creating the possibility that duplicates of each sensor – with different unique IDs – was possible). That said, in review, I didn't have unique IDs before, so perhaps it's a moot point. Let me know and I can remove the breaking change warning. |
If there were no unique IDs before, they were not added to the entity registry. |
Description:
Related issue (if applicable): N/A
Pull request in home-assistant.github.io with documentation (if applicable): N/A
Example entry for
configuration.yaml
(if applicable):Checklist:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass