Skip to content
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 UUIDs for OccupancyGroups #56

Merged
merged 4 commits into from
Jul 10, 2020
Merged

Fix UUIDs for OccupancyGroups #56

merged 4 commits into from
Jul 10, 2020

Conversation

cdheiser
Copy link
Collaborator

This is a bit of a hack, but Lutron currently sets the UUID
of Occupancy Groups to the same value as the Occupancy Group ID.
There's nothing in the API documentation that guarantees this will
be so, but changing it would be a breaking change, and the only
thing that's likely to use this in the near future is Home Assistant
and having any ID is better than None.

Note: This is a bit of a hack, but Lutron currently sets the UUID
of Occupancy Groups to the same value as the Occupancy Group ID.
There's nothing in the API documentation that guarantees this will
be so, but changing it would be a breaking change, and the only
thing that's likely to use this in the near future is Home Assistant
and having any ID is better than None.
@thecynic
Copy link
Owner

This is a bit of a hack, but Lutron currently sets the UUID
of Occupancy Groups to the same value as the Occupancy Group ID.
There's nothing in the API documentation that guarantees this will

Since we have the UUID as just a string, the value itself is opaque. What if we append a suffix (or prepend a prefix) to the ID? That way the clients (i know it's just HASS at this point :) ) won't be able to rely on the fact that they are the same and be forced to properly index them separately? So later when we parse it and properly map them, the clients wouldn't care.

be so, but changing it would be a breaking change, and the only

I don't think it'd be a breaking change from Lutron's perspective since they provide the mapping, or did you mean something else?

etc.

thing that's likely to use this in the near future is Home Assistant
and having any ID is better than None.

Makes sense.

@cdheiser
Copy link
Collaborator Author

cdheiser commented Jun 18, 2020 via email

@cdheiser
Copy link
Collaborator Author

cdheiser commented Jun 18, 2020 via email

@cdheiser
Copy link
Collaborator Author

FYI @JonGilmore

I have home-assistant/core#36902 queued up to overhaul the lutron hass component with unique IDs and some other goodies once this UUID snafu is resolved.

@thecynic
Copy link
Owner

Ok I take that back... If anyone indexes these, separately or not, if Lutron changes this behavior, it will break that system. It seems like appending or prepending something is just signing up pylutron to permanently prepend something but not actually gaining anything in the process.

Maybe I'm missing something (probably). What are we signing up pylutron for? The value is opaque, but unique. HASS shouldn't be doing anything with those values other than use them as some unique identifier, right? The API from pylutron is that there's a uuid present and nothing else, right. However, in your patch you are assuming that they are always the same but we know that according to what's in Lutron XML, that's not at all guaranteed hence they provide the mapping. The point of the prefix/suffix is to force the clients not to assume that the UUID is the same as Occupancy Group ID. We are exactly gaining pylutron not signing us up for maintaing that equality. The proper solution would be to parse the mapping, but it's not necessary to start with as we discussed.

I don't understand what this would be breaking exactly? Do the UUIDs get recorded somewhere and somehow associated with the object outside of the ephemeral building of the device database at runtime?

@cdheiser
Copy link
Collaborator Author

cdheiser commented Jun 22, 2020 via email

@cdheiser
Copy link
Collaborator Author

I just rewrote the code to actually parse out the occupancy groups and bind to the areas.

This will properly show the occupancy group for all areas regardless of the presence of a sensor. (My pending pull request for the home assistant component will fix that)

@thecynic
Copy link
Owner

Yes, the UUIDs get stored in config entries in home assistant. If you show up with the same device with a new UUID, it will get a new device id. So if say in version 13.0 they decide to create entirely new UUIDs, it will take all existing devices offline and create new ones in their place. Of course, you have to have actually upgraded your firmware for such an event to happen.

I think that's going to be a problem regardless though. The IDs can be renumbered based just on the configuration change, doesn't have to be a firmware update. I've definitely had things renumber when I moved stuff around and modified things in Essentials.

Based on my experience with messing with Lutron configs over the years, these numbers are not at all guaranteed to be stable between different re-generaitons of the configuration when you transfer the db from software to the master controller.

@cdheiser
Copy link
Collaborator Author

cdheiser commented Jun 24, 2020 via email

@cdheiser
Copy link
Collaborator Author

cdheiser commented Jun 24, 2020 via email

@thecynic
Copy link
Owner

thecynic commented Jun 28, 2020 via email

@cdheiser
Copy link
Collaborator Author

cdheiser commented Jun 28, 2020 via email

@cdheiser
Copy link
Collaborator Author

cdheiser commented Jun 29, 2020 via email

Copy link
Owner

@thecynic thecynic left a comment

Choose a reason for hiding this comment

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

Sorry, few more nits. Mostly good to go.

pylutron/__init__.py Show resolved Hide resolved
pylutron/__init__.py Outdated Show resolved Hide resolved
… new Area.

If for some reason we enter a future where an area references an OccupancyGroup
that we fail to parse out, we'll now get a friendly warning message.
@cdheiser
Copy link
Collaborator Author

cdheiser commented Jul 9, 2020

Bump.

Note once we get this merged, if we can push another pypi release, I have a draft PR for overhauling the Lutron integration in HA

@thecynic thecynic merged commit 8cafd7a into thecynic:master Jul 10, 2020
@thecynic
Copy link
Owner

Pushed 0.2.7 to PyPi with these last 3 PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants