Skip to content

Commit 98142ee

Browse files
authored
Merge pull request #6 from yutoyazaki/feature/half_step
Support 0.5 temperature step
2 parents 921c9f7 + bfeec5c commit 98142ee

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

climate.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ def min_temp(self):
100100
"""Return the minimum temperature."""
101101
temp_range = self._current_mode_temp_range()
102102
if len(temp_range) == 0:
103-
return DEFAULT_MIN_TEMP
103+
return 0
104104
return min(temp_range)
105105

106106
@property
107107
def max_temp(self):
108108
"""Return the maximum temperature."""
109109
temp_range = self._current_mode_temp_range()
110110
if len(temp_range) == 0:
111-
return DEFAULT_MAX_TEMP
111+
return 0
112112
return max(temp_range)
113113

114114
@property
@@ -120,6 +120,12 @@ def target_temperature(self):
120120
@property
121121
def target_temperature_step(self):
122122
"""Return the supported step of target temperature."""
123+
temp_range = self._current_mode_temp_range()
124+
if len(temp_range) >= 2:
125+
# determine step from the gap of first and second temperature
126+
step = round(temp_range[1] - temp_range[0], 1)
127+
if step in [1.0, 0.5]: # valid steps
128+
return step
123129
return 1
124130

125131
@property
@@ -164,7 +170,9 @@ async def async_set_temperature(self, **kwargs):
164170
target_temp = kwargs.get(ATTR_TEMPERATURE)
165171
if target_temp is None:
166172
return
167-
target_temp = int(target_temp)
173+
if target_temp.is_integer():
174+
# has to cast to whole number otherwise API will return an error
175+
target_temp = int(target_temp)
168176
_LOGGER.debug("Set temperature: %d", target_temp)
169177
await self._post({"temperature": f"{target_temp}"})
170178

@@ -242,4 +250,4 @@ async def _post(self, data):
242250

243251
def _current_mode_temp_range(self):
244252
temp_range = self._modes[self._remo_mode]["temp"]
245-
return list(map(int, filter(None, temp_range)))
253+
return list(map(float, filter(None, temp_range)))

0 commit comments

Comments
 (0)