mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2025-01-09 14:22:00 +01:00
add 2nd status text option for steps
This commit is contained in:
parent
4f2f3badea
commit
839e6caf88
5 changed files with 31 additions and 5 deletions
|
@ -1,3 +1,3 @@
|
|||
__version__ = "4.4.9"
|
||||
__codename__ = "Yeast Starter"
|
||||
__version__ = "4.5.0.a1"
|
||||
__codename__ = "Cross Country"
|
||||
|
||||
|
|
|
@ -133,7 +133,8 @@ class Step:
|
|||
def to_dict(self):
|
||||
|
||||
msg = self.instance.summary if self.instance is not None else ""
|
||||
return dict(id=self.id, name=self.name, state_text=msg, type=self.type, status=self.status.value, props=self.props.to_dict())
|
||||
msg2 = self.instance.summary2 if ((self.instance is not None) and (self.instance.summary2 is not None)) else None
|
||||
return dict(id=self.id, name=self.name, state_text=msg, state_text2=msg2, type=self.type, status=self.status.value, props=self.props.to_dict())
|
||||
|
||||
@dataclass
|
||||
class Fermenter:
|
||||
|
|
|
@ -46,6 +46,7 @@ class CBPiStep(CBPiBase):
|
|||
self.props = props
|
||||
self.cancel_reason: StepResult = None
|
||||
self.summary = ""
|
||||
self.summary2 = None
|
||||
self.task = None
|
||||
self.running: bool = False
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -384,7 +384,8 @@ class BoilStep(CBPiStep):
|
|||
#self.dwelltime=int(self.props.get("DwellTime", 0))*60
|
||||
self.dwelltime=5*60 #tested with 5 minutes -> not exactly 5 min due to accuracy of asyncio.sleep
|
||||
self.deviationlimit=0.3 # derived from a test
|
||||
logging.warning(self.AutoTimer)
|
||||
#logging.warning(self.AutoTimer)
|
||||
self.summary2=None
|
||||
|
||||
self.kettle=self.get_kettle(self.props.get("Kettle", None))
|
||||
if self.kettle is not None:
|
||||
|
@ -405,6 +406,24 @@ class BoilStep(CBPiStep):
|
|||
await self.setAutoMode(True)
|
||||
await self.push_update()
|
||||
|
||||
async def next_hop_timer(self):
|
||||
hop_timers = []
|
||||
for x in range(1, 6):
|
||||
try:
|
||||
hop = int(self.props.get("Hop_%s" % x, None)) * 60
|
||||
except:
|
||||
hop = None
|
||||
if hop is not None:
|
||||
hop_left = self.remaining_seconds - hop
|
||||
if hop_left > 0:
|
||||
hop_timers.append(hop_left)
|
||||
|
||||
if len(hop_timers) != 0:
|
||||
next_hop_timer = time.strftime("%H:%M:%S", time.gmtime(min(hop_timers)))
|
||||
else:
|
||||
next_hop_timer = None
|
||||
return next_hop_timer
|
||||
|
||||
async def check_hop_timer(self, number, value, text):
|
||||
if value is not None and self.hops_added[number-1] is not True:
|
||||
if self.remaining_seconds != None and self.remaining_seconds <= (int(value) * 60 + 1):
|
||||
|
@ -417,6 +436,7 @@ class BoilStep(CBPiStep):
|
|||
async def on_stop(self):
|
||||
await self.timer.stop()
|
||||
self.summary = ""
|
||||
self.summary2 = None
|
||||
self.kettle.target_temp = 0
|
||||
if self.AutoMode == True:
|
||||
await self.setAutoMode(False)
|
||||
|
@ -456,7 +476,9 @@ class BoilStep(CBPiStep):
|
|||
estimated_completion_time = datetime.fromtimestamp(time.time()+ (int(self.props.get("Timer", 0)))*60)
|
||||
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%H:%M")), NotificationType.INFO)
|
||||
else:
|
||||
for x in range(1, 6):
|
||||
nexthoptimer=await self.next_hop_timer()
|
||||
self.summary2="Add Hop in: %s" % nexthoptimer if nexthoptimer is not None else None
|
||||
for x in range(1, 6):
|
||||
await self.check_hop_timer(x, self.props.get("Hop_%s" % x, None), self.props.get("Hop_%s_text" % x, None))
|
||||
|
||||
return StepResult.DONE
|
||||
|
|
|
@ -2,6 +2,7 @@ from cbpi.controller.step_controller import StepController
|
|||
from cbpi.api.dataclasses import Props, Step
|
||||
from aiohttp import web
|
||||
from cbpi.api import *
|
||||
import logging
|
||||
|
||||
class StepHttpEndpoints():
|
||||
|
||||
|
@ -10,6 +11,7 @@ class StepHttpEndpoints():
|
|||
self.controller : StepController = cbpi.step
|
||||
self.cbpi.register(self, "/step2")
|
||||
|
||||
# Check if this is still needed
|
||||
def create_dict(self, data):
|
||||
return dict(name=data["name"], id=data["id"], type=data.get("type"), status=data["status"],props=data["props"], state_text=data["instance"].get_state())
|
||||
|
||||
|
|
Loading…
Reference in a new issue