Skip to content

Updated RainMachine to play better with the entity registry#12315

Merged
balloob merged 2 commits intohome-assistant:devfrom
bachya:rainmachine-entity-registry
Feb 12, 2018
Merged

Updated RainMachine to play better with the entity registry#12315
balloob merged 2 commits intohome-assistant:devfrom
bachya:rainmachine-entity-registry

Conversation

@bachya
Copy link
Copy Markdown
Contributor

@bachya bachya commented Feb 11, 2018

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.yaml as 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):

switch:
  platform: rainmachine
  ip_address: 192.168.1.100
  password: rainmachine_password

Checklist:

  • The code change is tested and works locally.

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass

@property
def unique_id(self) -> str:
"""Return a unique, HASS-friendly identifier for this entity."""
return '{0}_program_{1}'.format(self.device_mac.replace(':', ''),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't just the uid be enough? (assuming that stands for "unique id". Also just the MAC would be enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to refer to the entity ID, since that is how it is known inside Home Assistant

@balloob balloob merged commit c193d80 into home-assistant:dev Feb 12, 2018
@bachya bachya deleted the rainmachine-entity-registry branch February 12, 2018 03:59
@balloob balloob mentioned this pull request Feb 22, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants