mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-21 22:48:16 +01:00
Merge pull request #92 from avollkopf/development
Hysteresis extension: switch heater only on/off once
This commit is contained in:
commit
54449e9881
2 changed files with 10 additions and 3 deletions
|
@ -1,3 +1,3 @@
|
|||
__version__ = "4.1.2"
|
||||
__version__ = "4.1.3"
|
||||
__codename__ = "Groundhog Day"
|
||||
|
||||
|
|
|
@ -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,10 +23,16 @@ 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:
|
||||
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:
|
||||
await self.actor_off(self.heater)
|
||||
if self.heater and (heater_state == True):
|
||||
await self.actor_off(self.heater)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
except asyncio.CancelledError as e:
|
||||
|
|
Loading…
Reference in a new issue