mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2025-03-14 04:05:13 +01:00
Merge pull request #29 from avollkopf/development
Merge 4.0.1.1 from development branch
This commit is contained in:
commit
c627c38f86
7 changed files with 28 additions and 17 deletions
|
@ -1 +1,2 @@
|
|||
__version__ = "4.0.1.0"
|
||||
__version__ = "4.0.1.1"
|
||||
|
||||
|
|
|
@ -152,12 +152,14 @@ def check_for_setup():
|
|||
if zip_content == True:
|
||||
print("Found correct content. Starting Restore process")
|
||||
output_path = pathlib.Path(os.path.join(".", 'config'))
|
||||
owner = output_path.owner()
|
||||
group = output_path.group()
|
||||
print("Removing old config folder")
|
||||
shutil.rmtree(output_path, ignore_errors=True)
|
||||
print("Extracting zip file to config folder")
|
||||
zip.extractall(output_path)
|
||||
print("Changing owner and group of config folder recursively to pi:pi")
|
||||
recursive_chown(output_path, "pi", "pi")
|
||||
print("Changing owner and group of config folder recursively to {}:{}".format(owner,group))
|
||||
recursive_chown(output_path, owner, group)
|
||||
print("Removing backup file")
|
||||
os.remove(backupfile)
|
||||
else:
|
||||
|
|
|
@ -55,9 +55,9 @@ class BasicController:
|
|||
|
||||
async def push_udpate(self):
|
||||
self.cbpi.ws.send(dict(topic=self.update_key, data=list(map(lambda item: item.to_dict(), self.data))))
|
||||
self.cbpi.push_update("cbpi/{}".format(self.update_key), list(map(lambda item: item.to_dict(), self.data)))
|
||||
#for item in self.data:
|
||||
# self.cbpi.push_update("cbpi/{}/{}".format(self.update_key,item.id), item.to_dict())
|
||||
#self.cbpi.push_update("cbpi/{}".format(self.update_key), list(map(lambda item: item.to_dict(), self.data)))
|
||||
for item in self.data:
|
||||
self.cbpi.push_update("cbpi/{}/{}".format(self.update_key,item.id), item.to_dict())
|
||||
|
||||
def find_by_id(self, id):
|
||||
return next((item for item in self.data if item.id == id), None)
|
||||
|
|
|
@ -111,10 +111,10 @@ class FermentationController:
|
|||
|
||||
def push_update(self):
|
||||
self.cbpi.ws.send(dict(topic=self.update_key, data=list(map(lambda item: item.to_dict(), self.data))))
|
||||
self.cbpi.push_update("cbpi/{}".format(self.update_key), list(map(lambda item: item.to_dict(), self.data)))
|
||||
#self.cbpi.push_update("cbpi/{}".format(self.update_key), list(map(lambda item: item.to_dict(), self.data)))
|
||||
|
||||
#for item in self.data:
|
||||
# self.cbpi.push_update("cbpi/{}/{}".format(self.update_key,item.id), item.to_dict())
|
||||
for item in self.data:
|
||||
self.cbpi.push_update("cbpi/{}/{}".format(self.update_key,item.id), item.to_dict())
|
||||
pass
|
||||
|
||||
async def shutdown(self, app=None):
|
||||
|
|
|
@ -72,7 +72,7 @@ class StepController:
|
|||
self._loop.create_task(self.start_step(active_step))
|
||||
|
||||
async def add(self, item: Step):
|
||||
logging.info("Add step")
|
||||
logging.debug("Add step")
|
||||
item.id = shortuuid.uuid()
|
||||
item.status = StepState.INITIAL
|
||||
try:
|
||||
|
@ -117,6 +117,7 @@ class StepController:
|
|||
step = self.find_by_status(StepState.STOP)
|
||||
if step is not None:
|
||||
logging.info("Resume step")
|
||||
self.cbpi.push_update(topic="cbpi/notification", data=dict(type="info", title="Resume", message="Calling resume step"))
|
||||
await self.start_step(step)
|
||||
await self.save()
|
||||
return
|
||||
|
@ -124,10 +125,13 @@ class StepController:
|
|||
step = self.find_by_status(StepState.INITIAL)
|
||||
if step is not None:
|
||||
logging.info("Start Step")
|
||||
self.cbpi.push_update(topic="cbpi/notification", data=dict(type="info", title="Start", message="Calling start step"))
|
||||
self.push_udpate(complete=True)
|
||||
await self.start_step(step)
|
||||
await self.save()
|
||||
return
|
||||
self.cbpi.notify("Brewing Complete", "Now the yeast will take over",action=[NotificationAction("OK")])
|
||||
self.cbpi.push_update(topic="cbpi/notification", data=dict(type="info", title="Brewing completed", message="Now the yeast will take over"))
|
||||
logging.info("BREWING COMPLETE")
|
||||
|
||||
async def previous(self):
|
||||
|
@ -168,7 +172,9 @@ class StepController:
|
|||
logging.info("CALLING STOP STEP")
|
||||
try:
|
||||
await step.instance.stop()
|
||||
self.cbpi.push_update(topic="cbpi/notification", data=dict(type="info", title="Pause", message="Calling paue step"))
|
||||
step.status = StepState.STOP
|
||||
|
||||
await self.save()
|
||||
except Exception as e:
|
||||
logging.error("Failed to stop step - Id: %s" % step.id)
|
||||
|
@ -183,6 +189,7 @@ class StepController:
|
|||
item.status = StepState.INITIAL
|
||||
try:
|
||||
await item.instance.reset()
|
||||
self.cbpi.push_update(topic="cbpi/notification", data=dict(type="info", title="Stop", message="Calling stop step"))
|
||||
except:
|
||||
logging.warning("No Step Instance - Id: %s", item.id)
|
||||
await self.save()
|
||||
|
@ -254,12 +261,15 @@ class StepController:
|
|||
def push_udpate(self, complete=False):
|
||||
if complete is True:
|
||||
self.cbpi.ws.send(dict(topic="mash_profile_update", data=self.get_state()))
|
||||
for item in self.profile:
|
||||
self.cbpi.push_update(topic="cbpi/stepupdate/{}".format(item.id), data=(item.to_dict()))
|
||||
else:
|
||||
self.cbpi.ws.send(dict(topic="step_update", data=list(map(lambda item: item.to_dict(), self.profile))))
|
||||
|
||||
self.cbpi.push_update(topic="cbpi/stepupdate", data=list(map(lambda item: item.to_dict(), self.profile)))
|
||||
#for item in self.profile:
|
||||
# self.cbpi.push_update(topic="cbpi/stepupdate/{}".format(item.id), data=(item.to_dict()))
|
||||
step = self.find_by_status(StepState.ACTIVE)
|
||||
if step != None:
|
||||
self.cbpi.push_update(topic="cbpi/stepupdate/{}".format(step.id), data=(step.to_dict()))
|
||||
|
||||
|
||||
async def start_step(self,step):
|
||||
try:
|
||||
|
@ -317,4 +327,3 @@ class StepController:
|
|||
with open(path, "w") as file:
|
||||
yaml.dump(data, file)
|
||||
self.push_udpate()
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ from cbpi.http_endpoints.http_fermentation import FermentationHttpEndpoints
|
|||
import shortuuid
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@web.middleware
|
||||
async def error_middleware(request, handler):
|
||||
try:
|
||||
|
|
|
@ -226,6 +226,6 @@ def setup(cbpi):
|
|||
:return:
|
||||
'''
|
||||
|
||||
cbpi.plugin.register("NotificationStep", NotificationStep)
|
||||
cbpi.plugin.register("TargetTempStep", TargetTempStep)
|
||||
cbpi.plugin.register("FermenterNotificationStep", FermenterNotificationStep)
|
||||
cbpi.plugin.register("FermenterTargetTempStep", FermenterTargetTempStep)
|
||||
cbpi.plugin.register("FermentationStep", FermentationStep)
|
||||
|
|
Loading…
Add table
Reference in a new issue