mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
Fixed time format for timer and messages in case of longer steps
This commit is contained in:
parent
d87a578447
commit
c272d1ba2a
3 changed files with 14 additions and 6 deletions
|
@ -1 +1 @@
|
|||
__version__ = "4.0.2.0.a2"
|
||||
__version__ = "4.0.2.0.a3"
|
||||
|
|
|
@ -64,8 +64,14 @@ class Timer(object):
|
|||
|
||||
@classmethod
|
||||
def format_time(cls, time):
|
||||
pattern = '{0:02d}:{1:02d}:{2:02d}'
|
||||
pattern_h = '{0:02d}:{1:02d}:{2:02d}'
|
||||
pattern_d = '{0:02d}D {1:02d}:{2:02d}:{3:02d}'
|
||||
seconds = time % 60
|
||||
minutes = math.floor(time / 60) % 60
|
||||
hours = math.floor(time / 3600)
|
||||
return pattern.format(hours, minutes, seconds)
|
||||
hours = math.floor(time / 3600) % 24
|
||||
days = math.floor(time / 86400)
|
||||
if days != 0:
|
||||
remaining_time = pattern_d.format(days, hours, minutes, seconds)
|
||||
else:
|
||||
remaining_time = pattern_h.format(hours, minutes, seconds)
|
||||
return remaining_time
|
||||
|
|
|
@ -155,6 +155,8 @@ class FermenterStep(CBPiFermentationStep):
|
|||
self.cbpi.notify(self.name, 'Timer started', NotificationType.INFO)
|
||||
self.timer.start()
|
||||
self.timer.is_running = True
|
||||
estimated_completion_time = datetime.fromtimestamp(time.time()+ self.fermentationtime)
|
||||
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%d.%m, %H:%M")), NotificationType.INFO)
|
||||
else:
|
||||
self.cbpi.notify(self.name, 'Timer is already running', NotificationType.WARNING)
|
||||
|
||||
|
@ -227,7 +229,7 @@ class FermenterStep(CBPiFermentationStep):
|
|||
self.timer.start()
|
||||
self.timer.is_running = True
|
||||
estimated_completion_time = datetime.fromtimestamp(time.time()+ self.fermentationtime)
|
||||
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%H:%M")), NotificationType.INFO)
|
||||
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%d.%m, %H:%M")), NotificationType.INFO)
|
||||
elif self.fermenter.target_temp <= self.starttemp:
|
||||
logging.info("cooldown")
|
||||
while self.running == True:
|
||||
|
@ -237,7 +239,7 @@ class FermenterStep(CBPiFermentationStep):
|
|||
self.timer.start()
|
||||
self.timer.is_running = True
|
||||
estimated_completion_time = datetime.fromtimestamp(time.time()+ self.fermentationtime)
|
||||
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%H:%M")), NotificationType.INFO)
|
||||
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%d.%m, %H:%M")), NotificationType.INFO)
|
||||
|
||||
return StepResult.DONE
|
||||
|
||||
|
|
Loading…
Reference in a new issue