Skip to content

Commit 2de1748

Browse files
authored
attempt fix for crash on temperture model initialization (#73)
1 parent 4e0a1c5 commit 2de1748

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

custom_components/daikinone/utils.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,23 @@ class Temperature(BaseModel):
1414
print(temp.fahrenheit) # Prints the temperature in Fahrenheit
1515
"""
1616

17+
_temp_c: float
18+
19+
def __init__(self, temp_c: float) -> None:
20+
super().__init__()
21+
self._temp_c = round(temp_c, 1)
22+
1723
@staticmethod
1824
def from_celsius(temp_c: float) -> "Temperature":
19-
temp = Temperature()
20-
temp._init(temp_c)
21-
return temp
25+
return Temperature(temp_c)
2226

2327
@staticmethod
2428
def from_fahrenheit(temp_f: float) -> "Temperature":
25-
temp = Temperature()
26-
temp._init((temp_f - 32) * 5 / 9)
27-
return temp
29+
return Temperature((temp_f - 32) * 5 / 9)
2830

2931
@staticmethod
3032
def from_kelvin(temp_k: float) -> "Temperature":
31-
temp = Temperature()
32-
temp._init(temp_k - 273.15)
33-
return temp
34-
35-
def _init(self, temp_c: float) -> None:
36-
self._temp_c: float = round(temp_c, 1)
33+
return Temperature(temp_k - 273.15)
3734

3835
@property
3936
def celsius(self) -> float:

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)