Merge pull request #92 from avollkopf/development

Hysteresis extension: switch heater only on/off once
This commit is contained in:
Alexander Vollkopf 2023-03-03 17:52:34 +01:00 committed by GitHub
commit 54449e9881
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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" __codename__ = "Groundhog Day"

View file

@ -13,6 +13,7 @@ class Hysteresis(CBPiKettleLogic):
self.offset_off = float(self.props.get("OffsetOff", 0)) self.offset_off = float(self.props.get("OffsetOff", 0))
self.kettle = self.get_kettle(self.id) self.kettle = self.get_kettle(self.id)
self.heater = self.kettle.heater 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)) logging.info("Hysteresis {} {} {} {}".format(self.offset_on, self.offset_off, self.id, self.heater))
# self.get_actor_state() # self.get_actor_state()
@ -22,10 +23,16 @@ class Hysteresis(CBPiKettleLogic):
sensor_value = self.get_sensor_value(self.kettle.sensor).get("value") sensor_value = self.get_sensor_value(self.kettle.sensor).get("value")
target_temp = self.get_kettle_target_temp(self.id) 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 sensor_value < target_temp - self.offset_on:
await self.actor_on(self.heater) if self.heater and (heater_state == False):
await self.actor_on(self.heater)
elif sensor_value >= target_temp - self.offset_off: elif sensor_value >= target_temp - self.offset_off:
await self.actor_off(self.heater) if self.heater and (heater_state == True):
await self.actor_off(self.heater)
await asyncio.sleep(1) await asyncio.sleep(1)
except asyncio.CancelledError as e: except asyncio.CancelledError as e: