Ignore delayed heating valve setpoints - values set by user in the last two seconds
This commit is contained in:
parent
b181478258
commit
36884d40c1
@ -17,6 +17,7 @@ import devices
|
|||||||
from function.helpers import day_state
|
from function.helpers import day_state
|
||||||
import logging
|
import logging
|
||||||
import task
|
import task
|
||||||
|
import time
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from config import APP_NAME as ROOT_LOGGER_NAME
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
||||||
@ -152,10 +153,35 @@ class heating_function(common_base):
|
|||||||
AWAY_REDUCTION = 5
|
AWAY_REDUCTION = 5
|
||||||
SUMMER_TEMPERATURE = 5
|
SUMMER_TEMPERATURE = 5
|
||||||
|
|
||||||
|
class value_timeout_list(object):
|
||||||
|
MAX_DELAY = 3
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.__data__ = []
|
||||||
|
self.__time__ = []
|
||||||
|
|
||||||
|
def __cleanup__(self):
|
||||||
|
now = time.time()
|
||||||
|
for i, tm in enumerate(self.__time__):
|
||||||
|
if tm + self.MAX_DELAY < now:
|
||||||
|
del (self.__data__[i])
|
||||||
|
del (self.__time__[i])
|
||||||
|
|
||||||
|
def new(self, item):
|
||||||
|
self.__cleanup__()
|
||||||
|
self.__data__.append(item)
|
||||||
|
self.__time__.append(time.time())
|
||||||
|
|
||||||
|
def is_valid_value(self, data):
|
||||||
|
self.__cleanup__()
|
||||||
|
return data not in self.__data__
|
||||||
|
|
||||||
def __init__(self, heating_valve, default_temperature, **kwargs):
|
def __init__(self, heating_valve, default_temperature, **kwargs):
|
||||||
self.heating_valve = heating_valve
|
self.heating_valve = heating_valve
|
||||||
self.default_temperature = default_temperature
|
self.default_temperature = default_temperature
|
||||||
#
|
#
|
||||||
|
self.valve_value = self.value_timeout_list()
|
||||||
|
#
|
||||||
super().__init__({
|
super().__init__({
|
||||||
self.KEY_USER_TEMPERATURE_SETPOINT: kwargs.get(self.KEY_USER_TEMPERATURE_SETPOINT, self.default_temperature),
|
self.KEY_USER_TEMPERATURE_SETPOINT: kwargs.get(self.KEY_USER_TEMPERATURE_SETPOINT, self.default_temperature),
|
||||||
self.KEY_TEMPERATURE_SETPOINT: kwargs.get(self.KEY_TEMPERATURE_SETPOINT, self.default_temperature),
|
self.KEY_TEMPERATURE_SETPOINT: kwargs.get(self.KEY_TEMPERATURE_SETPOINT, self.default_temperature),
|
||||||
@ -241,11 +267,13 @@ class heating_function(common_base):
|
|||||||
self.set(self.KEY_TEMPERATURE_SETPOINT, data)
|
self.set(self.KEY_TEMPERATURE_SETPOINT, data)
|
||||||
|
|
||||||
def set_heating_setpoint(self, device, key, data):
|
def set_heating_setpoint(self, device, key, data):
|
||||||
|
self.valve_value.new(data)
|
||||||
self.heating_valve.set_heating_setpoint(data)
|
self.heating_valve.set_heating_setpoint(data)
|
||||||
|
|
||||||
def get_radiator_setpoint(self, device, key, data):
|
def get_radiator_setpoint(self, device, key, data):
|
||||||
if self[self.KEY_BOOST_TIMER] == 0 and not self[self.KEY_AWAY_MODE] and not self[self.KEY_SUMMER_MODE]:
|
if self.valve_value.is_valid_value(data):
|
||||||
self.set(self.KEY_USER_TEMPERATURE_SETPOINT, data, block_callback=[self.set_heating_setpoint])
|
if self[self.KEY_BOOST_TIMER] == 0 and not self[self.KEY_AWAY_MODE] and not self[self.KEY_SUMMER_MODE]:
|
||||||
|
self.set(self.KEY_USER_TEMPERATURE_SETPOINT, data, block_callback=[self.set_heating_setpoint])
|
||||||
|
|
||||||
def get_radiator_temperature(self, device, key, data):
|
def get_radiator_temperature(self, device, key, data):
|
||||||
self.set(self.KEY_TEMPERATURE_CURRENT, data)
|
self.set(self.KEY_TEMPERATURE_CURRENT, data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user