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

Return target_temperature value for zimi.waterheater.h03 #1446

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions custom_components/xiaomi_miot/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,15 @@ def __init__(self, config, miot_service: MiotService):
self._prop_target_temp = miot_service.get_property('target_temperature')
self._prev_target_temp = None

self._target_temperature_list = None
if self._prop_target_temp:
self._supported_features |= WaterHeaterEntityFeature.TARGET_TEMPERATURE
if self._prop_modes:
self._supported_features |= WaterHeaterEntityFeature.OPERATION_MODE
if "zimi.waterheater.h03" == self._model:
# https://home.mi.com/views/introduction.html?region=cn&pdid=10164&model=zimi.waterheater.h03
# 1-Low(40°C), 2-Medium(60°C), 3-High(75°C)
self._target_temperature_list = [None, 40, 60, 75]

async def async_update(self):
await super().async_update()
Expand Down Expand Up @@ -127,6 +132,12 @@ def set_operation_mode(self, mode):
return self.set_property(p, val)
raise NotImplementedError()

def get_operation_mode_value(self, mode):
for p in self._prop_modes:
val = p.list_value(mode)
return val
raise NotImplementedError()

@property
def current_temperature(self):
"""Return the current temperature."""
Expand Down Expand Up @@ -175,6 +186,9 @@ def target_temperature(self):
elif self._prev_target_temp:
val = self._prev_target_temp
return val
elif self._prop_modes:
if self._target_temperature_list:
return self._target_temperature_list[self.get_operation_mode_value(self.current_operation)]
return None

@property
Expand Down