mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-21 22:48:16 +01:00
added shutdown flag to all steps for on_timer_done
This commit is contained in:
parent
662e8b4497
commit
b84e33822b
1 changed files with 19 additions and 52 deletions
|
@ -32,8 +32,9 @@ class FermenterNotificationStep(CBPiFermentationStep):
|
||||||
|
|
||||||
if self.AutoNext == True:
|
if self.AutoNext == True:
|
||||||
self.cbpi.notify(self.name, self.props.get("Notification",""), NotificationType.INFO)
|
self.cbpi.notify(self.name, self.props.get("Notification",""), NotificationType.INFO)
|
||||||
await self.next(self.fermenter.id)
|
if self.shutdown != True:
|
||||||
return StepResult.DONE
|
await self.next(self.fermenter.id)
|
||||||
|
return StepResult.DONE
|
||||||
else:
|
else:
|
||||||
self.cbpi.notify(self.name, self.props.get("Notification",""), NotificationType.INFO, action=[NotificationAction("Next Step", self.NextStep)])
|
self.cbpi.notify(self.name, self.props.get("Notification",""), NotificationType.INFO, action=[NotificationAction("Next Step", self.NextStep)])
|
||||||
await self.push_update()
|
await self.push_update()
|
||||||
|
@ -42,6 +43,7 @@ class FermenterNotificationStep(CBPiFermentationStep):
|
||||||
await self.push_update()
|
await self.push_update()
|
||||||
|
|
||||||
async def on_start(self):
|
async def on_start(self):
|
||||||
|
self.shutdown = False
|
||||||
self.summary=""
|
self.summary=""
|
||||||
self.AutoNext = False if self.props.get("AutoNext", "No") == "No" else True
|
self.AutoNext = False if self.props.get("AutoNext", "No") == "No" else True
|
||||||
if self.timer is None:
|
if self.timer is None:
|
||||||
|
@ -69,10 +71,10 @@ class FermenterNotificationStep(CBPiFermentationStep):
|
||||||
class FermenterTargetTempStep(CBPiFermentationStep):
|
class FermenterTargetTempStep(CBPiFermentationStep):
|
||||||
|
|
||||||
async def NextStep(self, **kwargs):
|
async def NextStep(self, **kwargs):
|
||||||
await self.next(self.fermenter.id)
|
if self.shutdown != True:
|
||||||
return StepResult.DONE
|
await self.next(self.fermenter.id)
|
||||||
|
return StepResult.DONE
|
||||||
|
|
||||||
|
|
||||||
async def on_timer_done(self,timer):
|
async def on_timer_done(self,timer):
|
||||||
self.summary = ""
|
self.summary = ""
|
||||||
await self.push_update()
|
await self.push_update()
|
||||||
|
@ -87,6 +89,7 @@ class FermenterTargetTempStep(CBPiFermentationStep):
|
||||||
await self.push_update()
|
await self.push_update()
|
||||||
|
|
||||||
async def on_start(self):
|
async def on_start(self):
|
||||||
|
self.shutdown = False
|
||||||
self.AutoMode = True if self.props.get("AutoMode","No") == "Yes" else False
|
self.AutoMode = True if self.props.get("AutoMode","No") == "Yes" else False
|
||||||
self.starttemp= self.get_sensor_value(self.props.get("Sensor", None)).get("value")
|
self.starttemp= self.get_sensor_value(self.props.get("Sensor", None)).get("value")
|
||||||
if self.fermenter is not None:
|
if self.fermenter is not None:
|
||||||
|
@ -127,6 +130,7 @@ class FermenterTargetTempStep(CBPiFermentationStep):
|
||||||
|
|
||||||
async def reset(self):
|
async def reset(self):
|
||||||
self.timer = Timer(1 ,on_update=self.on_timer_update, on_done=self.on_timer_done)
|
self.timer = Timer(1 ,on_update=self.on_timer_update, on_done=self.on_timer_done)
|
||||||
|
self.timer.is_running == False
|
||||||
|
|
||||||
async def setAutoMode(self, auto_state):
|
async def setAutoMode(self, auto_state):
|
||||||
try:
|
try:
|
||||||
|
@ -161,13 +165,15 @@ class FermenterStep(CBPiFermentationStep):
|
||||||
else:
|
else:
|
||||||
self.cbpi.notify(self.name, 'Timer is already running', NotificationType.WARNING)
|
self.cbpi.notify(self.name, 'Timer is already running', NotificationType.WARNING)
|
||||||
|
|
||||||
# @action("Add 1 Day to Timer", [])
|
# @action("Add 1 Day to Timer", [])
|
||||||
# async def add_timer(self):
|
# async def add_timer(self):
|
||||||
# if self.timer.is_running == True:
|
# if self.timer.is_running == True:
|
||||||
# self.cbpi.notify(self.name, '5 Minutes added', NotificationType.INFO)
|
# self.cbpi.notify(self.name, '1 Day added', NotificationType.INFO)
|
||||||
# await self.timer.add(300)
|
# await self.timer.add(86400)
|
||||||
# else:
|
# self.endtime = self.endtime +86400
|
||||||
# self.cbpi.notify(self.name, 'Timer must be running to add time', NotificationType.WARNING)
|
# await self.update_endtime()
|
||||||
|
# else:
|
||||||
|
# self.cbpi.notify(self.name, 'Timer must be running to add time', NotificationType.WARNING)
|
||||||
|
|
||||||
|
|
||||||
async def on_timer_done(self,timer):
|
async def on_timer_done(self,timer):
|
||||||
|
@ -232,7 +238,6 @@ class FermenterStep(CBPiFermentationStep):
|
||||||
await self.push_update()
|
await self.push_update()
|
||||||
|
|
||||||
async def reset(self):
|
async def reset(self):
|
||||||
#await self.timer.stop()
|
|
||||||
timeD=int(self.props.get("TimerD", 0))
|
timeD=int(self.props.get("TimerD", 0))
|
||||||
timeH=int(self.props.get("TimerH", 0))
|
timeH=int(self.props.get("TimerH", 0))
|
||||||
timeM=int(self.props.get("TimerM", 0))
|
timeM=int(self.props.get("TimerM", 0))
|
||||||
|
@ -280,43 +285,6 @@ class FermenterStep(CBPiFermentationStep):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("Failed to switch on FermenterLogic {} {}".format(self.fermenter.id, e))
|
logging.error("Failed to switch on FermenterLogic {} {}".format(self.fermenter.id, e))
|
||||||
|
|
||||||
@parameters([Property.Number(label="TimerD", description="Timer Days", configurable=True),
|
|
||||||
Property.Number(label="TimerH", description="Timer Hours", configurable=True),
|
|
||||||
Property.Number(label="TimerM", description="Timer Minutes", configurable=True)
|
|
||||||
])
|
|
||||||
class FermenterWaitStep(CBPiFermentationStep):
|
|
||||||
|
|
||||||
async def on_timer_done(self, timer):
|
|
||||||
self.summary = ""
|
|
||||||
await self.next(self.fermenter.id)
|
|
||||||
return StepResult.DONE
|
|
||||||
|
|
||||||
async def on_timer_update(self, timer, seconds):
|
|
||||||
self.summary = Timer.format_time(seconds)
|
|
||||||
await self.push_update()
|
|
||||||
|
|
||||||
async def on_start(self):
|
|
||||||
timeD=int(self.props.get("TimerD", 0))
|
|
||||||
timeH=int(self.props.get("TimerH", 0))
|
|
||||||
timeM=int(self.props.get("TimerM", 0))
|
|
||||||
self.fermentationtime=(timeM+(60*timeH)+(1440*timeD)) *60
|
|
||||||
|
|
||||||
if self.timer is None:
|
|
||||||
self.timer = Timer(self.fermentationtime, on_update=self.on_timer_update, on_done=self.on_timer_done)
|
|
||||||
self.timer.start()
|
|
||||||
|
|
||||||
async def on_stop(self):
|
|
||||||
await self.timer.stop()
|
|
||||||
self.summary = ""
|
|
||||||
await self.push_update()
|
|
||||||
|
|
||||||
async def reset(self):
|
|
||||||
self.timer = Timer(self.fermentationtime, on_update=self.on_timer_update, on_done=self.on_timer_done)
|
|
||||||
|
|
||||||
async def run(self):
|
|
||||||
while self.running == True:
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
return StepResult.DONE
|
|
||||||
|
|
||||||
def setup(cbpi):
|
def setup(cbpi):
|
||||||
'''
|
'''
|
||||||
|
@ -329,5 +297,4 @@ def setup(cbpi):
|
||||||
|
|
||||||
cbpi.plugin.register("FermenterNotificationStep", FermenterNotificationStep)
|
cbpi.plugin.register("FermenterNotificationStep", FermenterNotificationStep)
|
||||||
cbpi.plugin.register("FermenterTargetTempStep", FermenterTargetTempStep)
|
cbpi.plugin.register("FermenterTargetTempStep", FermenterTargetTempStep)
|
||||||
cbpi.plugin.register("FermenterStep", FermenterStep)
|
cbpi.plugin.register("FermenterStep", FermenterStep)
|
||||||
#cbpi.plugin.register("FermenterWaitStep", FermenterWaitStep)
|
|
Loading…
Reference in a new issue