diff --git a/custom_components/daikinone/climate.py b/custom_components/daikinone/climate.py index f2a4170..d1be1e5 100644 --- a/custom_components/daikinone/climate.py +++ b/custom_components/daikinone/climate.py @@ -219,14 +219,13 @@ async def async_update(self, no_throttle: bool = False) -> None: await self._data.update(no_throttle=no_throttle) self._thermostat = self._data.daikin.get_thermostat(self._thermostat.id) - # update entity data - # + self.update_entity_attributes() + + def update_entity_attributes(self) -> None: self._attr_available = self._thermostat.online self._attr_current_temperature = self._thermostat.indoor_temperature.celsius self._attr_current_humidity = self._thermostat.indoor_humidity - # hvac mode - # match self._thermostat.mode: case DaikinThermostatMode.AUTO: self._attr_hvac_mode = HVACMode.HEAT_COOL @@ -239,8 +238,7 @@ async def async_update(self, no_throttle: bool = False) -> None: case DaikinThermostatMode.OFF: self._attr_hvac_mode = HVACMode.OFF - # hvac action - # + # hvac current action match self._thermostat.status: case DaikinThermostatStatus.HEATING: self._attr_hvac_action = HVACAction.HEATING @@ -254,18 +252,17 @@ async def async_update(self, no_throttle: bool = False) -> None: self._attr_hvac_action = HVACAction.IDLE # target temperature - # + + # reset target temperature attributes first, single target temp takes precedence and can conflict with range + self._attr_target_temperature = None + self._attr_target_temperature_low = None + self._attr_target_temperature_high = None + match self._thermostat.mode: case DaikinThermostatMode.HEAT | DaikinThermostatMode.AUX_HEAT: self._attr_target_temperature = self._thermostat.set_point_heat.celsius case DaikinThermostatMode.COOL: self._attr_target_temperature = self._thermostat.set_point_cool.celsius - case _: - pass - - # target temperature range - # - match self._thermostat.mode: case DaikinThermostatMode.AUTO: self._attr_target_temperature_low = self._thermostat.set_point_heat.celsius self._attr_target_temperature_high = self._thermostat.set_point_cool.celsius @@ -273,8 +270,6 @@ async def async_update(self, no_throttle: bool = False) -> None: pass # temperature bounds - # - # these should be the same but just in case, take the larger of the two for the min self._attr_min_temp = max( self._thermostat.set_point_heat_min.celsius, @@ -299,6 +294,7 @@ async def update_state_optimistically( # execute state update optimistically update(self._thermostat) + self.update_entity_attributes() self.async_write_ha_state() # wait for remote state to be updated diff --git a/custom_components/daikinone/daikinone.py b/custom_components/daikinone/daikinone.py index 53ed979..1dddf29 100644 --- a/custom_components/daikinone/daikinone.py +++ b/custom_components/daikinone/daikinone.py @@ -1,4 +1,5 @@ import copy +import json import logging from datetime import timedelta from enum import Enum, auto @@ -209,7 +210,7 @@ async def set_thermostat_home_set_points( if cool: payload["cspHome"] = cool.celsius if override_schedule: - payload["schedOverride"] = True + payload["schedOverride"] = 1 await self.__req( url=f"{DAIKIN_API_URL_DEVICE_DATA}/{thermostat_id}", @@ -468,7 +469,7 @@ async def __req( await self.__refresh_token() return await self.__req(url, method, body, retry=False) - raise DaikinServiceException( - f"Failed to send request to Daikin API: method={method} url={url} body={body}, response={response}", - status=response.status, - ) + raise DaikinServiceException( + f"Failed to send request to Daikin API: method={method} url={url} body={json.dumps(body)}, response_code={response.status} response_body={await response.text()}", + status=response.status, + )