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

Refactor thermostat modes & actions #143

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

adamjernst
Copy link
Contributor

@adamjernst adamjernst commented Feb 15, 2024

This makes a few changes to better match how other thermostat entities work in Home Assistant:

Whether the thermostat is heating or not is reflected via HVACAction not HVACMode. Thermostats now only have a single mode, HEAT, since OJ Microline thermostats can only heat and cannot be turned off via the API. I think this better matches the intended design, where the "action" is whatever the thermostat is choosing to do at a moment in time and the "mode" is a user-changeable item.

Presets updated. Instead of the built-in preset "Home", use a custom preset "Schedule". Instead of the built-in preset "None", use a custom preset "Manual". For all presets, use the new Icon Translations feature to give them sensible icons.

Screen Shot 2024-02-12 at 10 04 04 AM

Fix min/max temps. We wanted e.g. max_temp not target_temperature_high — the latter is for target temperature ranges, which these thermostats do not support anyway.

"frost_protection": "mdi:snowflake",
"boost": "mdi:rocket-launch",
"comfort": "mdi:sofa",
"eco": "mdi:leaf"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Built-in presets use the built-in localization for strings but not icon translations, which I think is probably a bug. That's why we have to specify icons for built-in presets here.

@@ -89,13 +88,15 @@ class OJMicrolineThermostat(
):
"""OJMicrolineThermostat climate."""

_attr_hvac_modes = MODE_LIST
_attr_hvac_modes: ClassVar[list[HVACMode]] = [HVACMode.HEAT]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ruff insists on annotating this as a ClassVar because its default value is shared among all classes (and thus mutations to one affect all). This is never mutated anyway, so it's fine.

@robbinjanssen robbinjanssen added the enhancement Enhancement of the code, not introducing new features. label Feb 16, 2024
@robbinjanssen
Copy link
Owner

Awesome! I'll add the translations for the other languages in another PR

@robbinjanssen robbinjanssen merged commit a7c5e09 into robbinjanssen:main Feb 16, 2024
8 of 9 checks passed
@adamjernst adamjernst deleted the modes branch February 17, 2024 02:41
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants