Skip to content

Commit 8119455

Browse files
authored
Merge pull request #83 from jwillemsen/jwi-settemp
Support setting hvac mode as part of async_set_temperature, fixed #79
2 parents a07b893 + 2eae704 commit 8119455

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

custom_components/daikin_onecta/climate.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import voluptuous as vol
88
from homeassistant.components.climate import ClimateEntity
99
from homeassistant.components.climate import PLATFORM_SCHEMA
10+
from homeassistant.components.climate.const import ATTR_HVAC_MODE
1011
from homeassistant.components.climate.const import ClimateEntityFeature
1112
from homeassistant.components.climate.const import FAN_AUTO
1213
from homeassistant.components.climate.const import HVACMode
@@ -354,22 +355,26 @@ def get_target_temperature_step(self):
354355

355356
async def async_set_temperature(self, **kwargs):
356357
# """Set new target temperature."""
357-
operationmode = self.operationMode()
358-
omv = operationmode["value"]
359-
value = kwargs[ATTR_TEMPERATURE]
360-
res = await self._device.set_path(
361-
self._device.getId(),
362-
self.embedded_id,
363-
"temperatureControl",
364-
f"/operationModes/{omv}/setpoints/{self._setpoint}",
365-
value,
366-
)
367-
# When updating the value to the daikin cloud worked update our local cached version
368-
if res:
369-
setpointdict = self.setpoint()
370-
if setpointdict is not None:
371-
self._attr_target_temperature = value
372-
self.async_write_ha_state()
358+
if ATTR_HVAC_MODE in kwargs:
359+
await self.async_set_hvac_mode(kwargs[ATTR_HVAC_MODE])
360+
361+
if ATTR_TEMPERATURE in kwargs:
362+
operationmode = self.operationMode()
363+
omv = operationmode["value"]
364+
value = kwargs[ATTR_TEMPERATURE]
365+
res = await self._device.set_path(
366+
self._device.getId(),
367+
self.embedded_id,
368+
"temperatureControl",
369+
f"/operationModes/{omv}/setpoints/{self._setpoint}",
370+
value,
371+
)
372+
# When updating the value to the daikin cloud worked update our local cached version
373+
if res:
374+
setpointdict = self.setpoint()
375+
if setpointdict is not None:
376+
self._attr_target_temperature = value
377+
self.async_write_ha_state()
373378

374379
def get_hvac_mode(self):
375380
"""Return current HVAC mode."""

0 commit comments

Comments
 (0)