-
-
Notifications
You must be signed in to change notification settings - Fork 93
Add temperature unit for climate and water heater #1586
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
Changes from all commits
71f7d63
ad7ef53
f5fd81e
dba7c4c
3a81f43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -692,6 +692,12 @@ class ClimatePreset(APIIntEnum): | |||||||||||||||||||||||||||||||||||||||
| ACTIVITY = 7 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| class TemperatureUnit(APIIntEnum): | ||||||||||||||||||||||||||||||||||||||||
| CELSIUS = 0 | ||||||||||||||||||||||||||||||||||||||||
| FAHRENHEIT = 1 | ||||||||||||||||||||||||||||||||||||||||
| KELVIN = 2 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| @_frozen_dataclass_decorator | ||||||||||||||||||||||||||||||||||||||||
| class ClimateInfo(EntityInfo): | ||||||||||||||||||||||||||||||||||||||||
| feature_flags: int = 0 | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -733,6 +739,13 @@ class ClimateInfo(EntityInfo): | |||||||||||||||||||||||||||||||||||||||
| supports_target_humidity: bool = False | ||||||||||||||||||||||||||||||||||||||||
| visual_min_humidity: float = 0 | ||||||||||||||||||||||||||||||||||||||||
| visual_max_humidity: float = 0 | ||||||||||||||||||||||||||||||||||||||||
| temperature_unit: TemperatureUnit = ( | ||||||||||||||||||||||||||||||||||||||||
| converter_field( | ||||||||||||||||||||||||||||||||||||||||
| default=TemperatureUnit.CELSIUS, | ||||||||||||||||||||||||||||||||||||||||
| converter=TemperatureUnit.convert, | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
| or TemperatureUnit.CELSIUS | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+742
to
+747
|
||||||||||||||||||||||||||||||||||||||||
| temperature_unit: TemperatureUnit = ( | |
| converter_field( | |
| default=TemperatureUnit.CELSIUS, | |
| converter=TemperatureUnit.convert, | |
| ) | |
| or TemperatureUnit.CELSIUS | |
| temperature_unit: TemperatureUnit = converter_field( | |
| default=TemperatureUnit.CELSIUS, | |
| converter=lambda value: TemperatureUnit.convert(value) | |
| or TemperatureUnit.CELSIUS, |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New behavior is added (temperature_unit for climate/water_heater), but there are no targeted tests asserting correct conversion/round-tripping (e.g., from_pb / from_dict with Fahrenheit, and handling of unknown enum values). Since this repo has extensive model conversion tests, please add coverage for these new fields to prevent regressions.
| temperature_unit: TemperatureUnit = ( | |
| converter_field( | |
| default=TemperatureUnit.CELSIUS, | |
| converter=TemperatureUnit.convert, | |
| ) | |
| or TemperatureUnit.CELSIUS | |
| temperature_unit: TemperatureUnit = converter_field( | |
| default=TemperatureUnit.CELSIUS, | |
| converter=TemperatureUnit.convert, |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as ClimateInfo: converter_field(...) or TemperatureUnit.CELSIUS is redundant, and TemperatureUnit.convert may yield None for unknown values even though this field is not optional. Please align with the project’s usual enum-conversion pattern (optional type or safe fallback converter) and remove the ineffective or expression.
| temperature_unit: TemperatureUnit = ( | |
| converter_field( | |
| default=TemperatureUnit.CELSIUS, | |
| converter=TemperatureUnit.convert, | |
| ) | |
| or TemperatureUnit.CELSIUS | |
| temperature_unit: TemperatureUnit = converter_field( | |
| default=TemperatureUnit.CELSIUS, | |
| converter=lambda value: TemperatureUnit.convert(value) | |
| or TemperatureUnit.CELSIUS, |
Uh oh!
There was an error while loading. Please reload this page.