From 347039c130802e413b99a21fdcb9c6d65a72e313 Mon Sep 17 00:00:00 2001 From: Dave Code <34915602+dave-code-ruiz@users.noreply.github.com> Date: Thu, 11 Jul 2024 08:43:26 +0200 Subject: [PATCH] trying to solves deprecated async_add_job trying to solves deprecated async_add_job --- custom_components/uponor/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/custom_components/uponor/__init__.py b/custom_components/uponor/__init__.py index c21f461..f6bbbab 100644 --- a/custom_components/uponor/__init__.py +++ b/custom_components/uponor/__init__.py @@ -225,7 +225,7 @@ async def async_switch_to_cooling(self): await self._hass.async_add_executor_job(lambda: self._client.send_data({'sys_heat_cool_mode': '1'})) self._data['sys_heat_cool_mode'] = '1' - self._hass.async_create_task(async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE)) + self._hass.async_create_task(self.call_state_update()) async def async_switch_to_heating(self): for thermostat in self._hass.data[DOMAIN]['thermostats']: @@ -234,7 +234,7 @@ async def async_switch_to_heating(self): await self._hass.async_add_executor_job(lambda: self._client.send_data({'sys_heat_cool_mode': '0'})) self._data['sys_heat_cool_mode'] = '0' - self._hass.async_create_task(async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE)) + self._hass.async_create_task(self.call_state_update()) async def async_turn_on(self, thermostat): data = await self._store.async_load() @@ -273,7 +273,7 @@ async def async_set_away(self, is_away): data = "1" if is_away else "0" await self._hass.async_add_executor_job(lambda: self._client.send_data({var: data})) self._data[var] = data - self._hass.async_create_task(async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE)) + self._hass.async_create_task(self.call_state_update()) def is_eco(self, thermostat): if self.get_eco_setback(thermostat) == 0: @@ -290,13 +290,16 @@ def get_eco_setback(self, thermostat): def get_last_update(self): return self.next_sp_from_dt + + def call_state_update(self): + async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE) # Rest async def async_update(self,_=None): try: self.next_sp_from_dt = dt_util.now() self._data = await self._hass.async_add_executor_job(lambda: self._client.get_data()) - self._hass.async_create_task(async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE)) + self._hass.async_create_task(self.call_state_update()) except Exception as ex: _LOGGER.error("Uponor thermostat was unable to update: %s", ex) @@ -304,11 +307,11 @@ def set_variable(self, var_name, var_value): _LOGGER.debug("Called set variable: name: %s, value: %s, data: %s", var_name, var_value, self._data) self._client.send_data({var_name: var_value}) self._data[var_name] = var_value - self._hass.async_create_task(async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE)) + self._hass.async_create_task(self.call_state_update()) async def set_setpoint(self, thermostat, temp): var = thermostat + '_setpoint' setpoint = int(temp * 18 + self.get_active_setback(thermostat, temp) + 320) await self._hass.async_add_executor_job(lambda: self._client.send_data({var: setpoint})) self._data[var] = setpoint - self._hass.async_create_task(async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE)) + self._hass.async_create_task(self.call_state_update())