Skip to content

Commit

Permalink
🔧 improve set temperature for climate
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Feb 10, 2025
1 parent 3627da6 commit 1be0155
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions custom_components/xiaomi_miot/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ async def async_set_temperature(self, **kwargs):

temp = kwargs.get(ATTR_TEMPERATURE)
if temp and self._conv_target_temp:
prop = self._conv_target_temp.prop
if not isinstance(prop, MiotProperty):
pass
elif prop.is_integer or prop.range_step() == 1:
temp = int(temp)
dat[self._conv_target_temp.attr] = temp
await self.device.async_write(dat)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/xiaomi_miot/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ async def async_write(self, payload: dict):
if self.cloud and cloud_params:
result = await self.cloud.async_set_props(cloud_params)
if err := MiotResults(result).has_error:
self.log.warning('Device write error: %s', err)
self.log.warning('Device write error: %s', [payload, err])

if method == 'action':
param = data.get('param', {})
Expand Down
6 changes: 6 additions & 0 deletions custom_components/xiaomi_miot/core/miot_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@ def to_json(self):
def __str__(self):
return f'{self._results}'

def __repr__(self):
return f'{self._results}'


class MiotResult:
def __init__(self, result: dict, **kwargs):
Expand Down Expand Up @@ -1225,3 +1228,6 @@ def to_json(self):

def __str__(self):
return f'{self.result}'

def __repr__(self):
return f'{self.result}'

0 comments on commit 1be0155

Please sign in to comment.