Updated RainMachine to play better with the entity registry#12315
Updated RainMachine to play better with the entity registry#12315balloob merged 2 commits intohome-assistant:devfrom
Conversation
| @property | ||
| def unique_id(self) -> str: | ||
| """Return a unique, HASS-friendly identifier for this entity.""" | ||
| return '{0}_program_{1}'.format(self.device_mac.replace(':', ''), |
There was a problem hiding this comment.
Wouldn't just the uid be enough? (assuming that stands for "unique id". Also just the MAC would be enough.
There was a problem hiding this comment.
Would love your thoughts:
There are situations where one might have multiple sprinkler controllers (e.g., I have one and I manage one at another property, all through the same HASS interface). Let's say we have a program called "Landscaping" as the first program (UID: 1) for each controller – wouldn't there need to be some way to differentiate? I was thinking that the combination of the device MAC and the program/zone UID would cover everything. If that's overkill, let me know.
There was a problem hiding this comment.
Oh, I didn't realize that uid was unique per instance. Combining it is 👍
| except exceptions.HTTPError as exc_info: | ||
| _LOGGER.error('Unable to update info for program "%s"', | ||
| self.rainmachine_id) | ||
| self.rainmachine_entity_id) |
There was a problem hiding this comment.
It's better to refer to the entity ID, since that is how it is known inside Home Assistant
Description:
RainMachine previously gave out a rather useless entity ID; this PR updates that behavior to be more consistent with the guidelines of the entity registry.
Breaking Change: this is technically a breaking change. If RainMachine had been configured previously, new entries will be placed into the entity registry, causing there to be two of each program/zone defined. To address, simply alter the
entity_registry.yamlas desired.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:
toxrun successfully. Your PR cannot be merged unless tests pass