Skip to content

Commit

Permalink
Set operation mode with temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeGEINE committed Jun 14, 2024
1 parent f760e13 commit 6036aa1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion custom_components/skykettle/kettle_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,13 @@ def target_mode(self):
def target_mode_str(self):
return self.get_mode_name(self.target_mode)

async def set_target_temp(self, target_temp):
async def set_target_temp(self, target_temp, operation_mode = None):
"""Set new temperature."""
if target_temp == self.target_temp: return # already set
_LOGGER.info(f"Setting target temperature to {target_temp}")
target_mode = self.target_mode
vs = [k for k, v in SkyKettle.MODE_NAMES.items() if v == operation_mode]
if len(vs) > 0: target_mode = vs[0]
# Some checks for mode
if target_temp < SkyKettle.MIN_TEMP:
# Just turn off
Expand Down
6 changes: 4 additions & 2 deletions custom_components/skykettle/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging

from homeassistant.components.water_heater import (WaterHeaterEntity,
WaterHeaterEntityFeature)
WaterHeaterEntityFeature,
ATTR_OPERATION_MODE)
from homeassistant.const import (ATTR_SW_VERSION, ATTR_TEMPERATURE,
CONF_FRIENDLY_NAME, CONF_SCAN_INTERVAL,
STATE_OFF, UnitOfTemperature)
Expand Down Expand Up @@ -174,7 +175,8 @@ def current_operation(self):
async def async_set_temperature(self, **kwargs):
"""Set new target temperatures."""
target_temperature = kwargs.get(ATTR_TEMPERATURE)
await self.kettle.set_target_temp(target_temperature)
operation_mode = kwargs.get(ATTR_OPERATION_MODE)
await self.kettle.set_target_temp(target_temperature, operation_mode)
self.hass.async_add_executor_job(dispatcher_send, self.hass, DISPATCHER_UPDATE)

async def async_set_operation_mode(self, operation_mode):
Expand Down

0 comments on commit 6036aa1

Please sign in to comment.