Skip to content

Add support for HVAC units#92

Open
wilburCforce wants to merge 5 commits into
thecynic:masterfrom
wilburCforce:HVACSupport
Open

Add support for HVAC units#92
wilburCforce wants to merge 5 commits into
thecynic:masterfrom
wilburCforce:HVACSupport

Conversation

@wilburCforce

Copy link
Copy Markdown

This PR aims to add support for basic HVAC controls.

enums are used to store friendly text instead of integers so that applications utilizing this code do not need to have a dictionary to know what is happening. Similarly, those applications will write the values as the strings.

due to the number of attributes related to this object, the handle_update function has several helper functions and an attempt was made to streamline that code.

@wilburCforce

Copy link
Copy Markdown
Author

@cdheiser I believe this is ready now. I've done extensive testing with the HA integration that is just about done as well.
At a minimum it shouldn't break anything as 99% of the new code is in the new HVAC class.

@wilburCforce

Copy link
Copy Markdown
Author

@cdheiser or @thecynic I think this is probably worthy of bumping the release to 0.3.0 since this adds a major component.
Could we see about getting any nits of yours and getting this merged in and released? I think the potential impact/risk is minimal to zero since there is very little that is outside the new class. Thoughts? As soon as this gets merged I can finalize the HA component as well and get that released.

Comment thread pylutron/__init__.py Outdated
Comment thread pylutron/__init__.py
Comment thread pylutron/__init__.py
"""Handles an event update for this object, e.g. temp level change."""
_LOGGER.debug("HVAC handle_update %d -- %s" % (self._integration_id, args))

def _u_current_temp_f(temp):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Something about this makes me uneasy enough that I'm contemplating alternative arrangements. I just don't have an excellent idea yet.

The one thing rattling around my head is what should the object model of an HVAC be?

Is it one object with a bunch of properties? Or is the fan an object, and the operating mode an object, etc...

It feels like there's a lot of repeated boilerplate below that could be factored out and make it easier to read and parse. Like an HVACTemperatire class that can deal with the current temperature and setpoints (you end up with one instance for Farenheight and one for Celcius), and an HVACModes class, etc...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not opposed to the idea at all but that might also introduce more complexity and not save much actual code in the long run. Additionally, when consuming this in HA there are crossovers between modes, fans, and presets. Having multiple objects makes it more complicated to consume and increases the code size there.

Comment thread pylutron/__init__.py Outdated
HVAC.Event.ECO_MODE: (_u_eco_mode, 1),
}
if event in handler_functions:
handler, num_args = handler_functions[event]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not just pass all remaining arguments?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm a little new to python so I'm not sure how to do that. If you could suggest an approach so I could learn that would be great.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You'd replace this all with:

handler(*args[1:])

@wilburCforce

Copy link
Copy Markdown
Author

@cdheiser Is there anything here really worth delaying this?
I'm not opposed to working on it later as well or helping change the object model, but I'd love to get this done and it does work. I think the only nits you had were pretty minor outside the logic model question.
The Home Assistant side is going to take me another month or two of debates after I put in the PR for that.

@wilburCforce

Copy link
Copy Markdown
Author

@cdheiser This is the 1 year anniversary of waiting for your review.
checking status......

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.

2 participants