Skip to content

Commit

Permalink
Try to solves asev#52
Browse files Browse the repository at this point in the history
Try to solves asev#52
  • Loading branch information
dave-code-ruiz authored Jul 4, 2024
1 parent 37249ff commit ddd2497
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions custom_components/uponor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.storage import Store
from UponorJnap import UponorJnap
import homeassistant.util.dt as dt_util

from .const import (
DOMAIN,
Expand Down Expand Up @@ -86,6 +87,7 @@ def __init__(self, hass, host, store):
self._store = store
self._data = {}
self._storage_data = {}
self.next_sp_from_dt = None

# Thermostats config

Expand Down Expand Up @@ -280,11 +282,19 @@ def get_eco_setback(self, thermostat):
var = thermostat + '_eco_offset'
if var in self._data:
return round(int(self._data[var]) / 18, 1)

def get_last_update(self):
return self.next_sp_from_dt

# Rest

async def async_update(self):
self._data = await self._hass.async_add_executor_job(lambda: self._client.get_data())
async def async_update(self,_=None):
'# try to change update calls doing one in same second'
'TODO call self.async_write_ha_state() in climate and switch'
if self.next_sp_from_dt is None or dt_util.now() >= self.next_sp_from_dt:
self.next_sp_from_dt = dt_util.now()
self._data = await self._hass.async_add_executor_job(lambda: self._client.get_data())
else:
_LOGGER.warning("A lot of asyn_update calls at " + str(dt_util.now()))

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)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/uponor/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def async_turn_on(self):
async def async_update(self):
# Update uponor (to get HC mode) and thermostat
try:
### se ha elimininado el 0 del update
### se ha elimininado el 0 del update
await self._state_proxy.async_update()
temp = self._state_proxy.get_setpoint(self._thermostat)
is_cool = self._state_proxy.is_cool_enabled()
Expand Down

0 comments on commit ddd2497

Please sign in to comment.