mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-25 16:38:36 +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"
|
__codename__ = "Groundhog Day"
|
||||||
|
|
||||||
|
|
|
@ -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,9 +23,15 @@ 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:
|
||||||
|
if self.heater and (heater_state == False):
|
||||||
await self.actor_on(self.heater)
|
await self.actor_on(self.heater)
|
||||||
elif sensor_value >= target_temp - self.offset_off:
|
elif sensor_value >= target_temp - self.offset_off:
|
||||||
|
if self.heater and (heater_state == True):
|
||||||
await self.actor_off(self.heater)
|
await self.actor_off(self.heater)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue