Hysteresis extension: switch heater only on/off once

This commit is contained in:
avollkopf 2023-03-02 06:51:57 +01:00
parent 39bf7c8fe1
commit 6d5fd493df
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.2"
__version__ = "4.1.3"
__codename__ = "Groundhog Day"

View file

@ -13,6 +13,7 @@ class Hysteresis(CBPiKettleLogic):
self.offset_off = float(self.props.get("OffsetOff", 0))
self.kettle = self.get_kettle(self.id)
self.heater = self.kettle.heater
heater = self.cbpi.actor.find_by_id(self.heater)
logging.info("Hysteresis {} {} {} {}".format(self.offset_on, self.offset_off, self.id, self.heater))
# self.get_actor_state()
@ -22,9 +23,15 @@ class Hysteresis(CBPiKettleLogic):
sensor_value = self.get_sensor_value(self.kettle.sensor).get("value")
target_temp = self.get_kettle_target_temp(self.id)
try:
heater_state=heater.instance.state
except:
heater_state = False
if sensor_value < target_temp - self.offset_on:
if self.heater and (heater_state == False):
await self.actor_on(self.heater)
elif sensor_value >= target_temp - self.offset_off:
if self.heater and (heater_state == True):
await self.actor_off(self.heater)
await asyncio.sleep(1)