From 01997f741c6cdae85e896720c03af4374a732322 Mon Sep 17 00:00:00 2001 From: Carl Allen Date: Tue, 18 Jul 2017 15:06:55 -0500 Subject: [PATCH 1/3] Allow modifying chart data in plugins --- modules/core/controller.py | 15 +++++++++++++++ modules/logs/endpoints.py | 9 +++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/core/controller.py b/modules/core/controller.py index c940cdd..aef2a7e 100644 --- a/modules/core/controller.py +++ b/modules/core/controller.py @@ -74,6 +74,14 @@ class ControllerBase(object): class KettleController(ControllerBase, ActorController, SensorController): + @staticmethod + def chart(kettle): + result = [] + result.append({"name": "Temp", "data_type": "sensor", "data_id": kettle.sensor}) + result.append({"name": "Target Temp", "data_type": "kettle", "data_id": kettle.id}) + + return result + def __init__(self, *args, **kwds): ControllerBase.__init__(self, *args, **kwds) self.kettle_id = kwds.get("kettle_id") @@ -107,6 +115,13 @@ class KettleController(ControllerBase, ActorController, SensorController): class FermenterController(ControllerBase, ActorController, SensorController): + @staticmethod + def chart(fermenter): + result = [] + result.append({"name": "Temp", "data_type": "sensor", "data_id": fermenter.sensor}) + result.append({"name": "Target Temp", "data_type": "fermenter", "data_id": fermenter.id}) + return result + def __init__(self, *args, **kwds): ControllerBase.__init__(self, *args, **kwds) self.fermenter_id = kwds.get("fermenter_id") diff --git a/modules/logs/endpoints.py b/modules/logs/endpoints.py index a68d9b7..5f8b29e 100644 --- a/modules/logs/endpoints.py +++ b/modules/logs/endpoints.py @@ -65,6 +65,8 @@ class LogView(FlaskView): pass return array + def convert_chart_data_to_json(self, chart_data): + return {"name": chart_data["name"], "data": self.read_log_as_json(chart_data["data_type"], chart_data["data_id"])} @route('//', methods=["POST"]) def get_logs_as_json(self, t, id): @@ -76,13 +78,12 @@ class LogView(FlaskView): if t == "k": kettle = cbpi.cache.get("kettle").get(id) - result.append({"name": "Temp", "data": self.read_log_as_json("sensor", kettle.sensor)}) - result.append({"name": "Target Temp", "data": self.read_log_as_json("kettle", kettle.id)}) + result = map(self.convert_chart_data_to_json, cbpi.get_controller(kettle.logic).get("class").chart(kettle)) if t == "f": fermenter = cbpi.cache.get("fermenter").get(id) - result.append({"name": "Temp", "data": self.read_log_as_json("sensor", fermenter.sensor)}) - result.append({"name": "Target Temp", "data": self.read_log_as_json("fermenter", fermenter.id)}) + result = map(self.convert_chart_data_to_json, cbpi.get_fermentation_controller(fermenter.logic).get("class").chart(fermenter)) + return json.dumps(result) @route('/download/') From 1c4e16e35839ec699a431a3840d7dfda9430c4cf Mon Sep 17 00:00:00 2001 From: swimIan Date: Thu, 20 Jul 2017 16:44:57 -0700 Subject: [PATCH 2/3] Add notification at the end of a mashstep. --- modules/base_plugins/brew_steps/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/base_plugins/brew_steps/__init__.py b/modules/base_plugins/brew_steps/__init__.py index 177ff46..17e5796 100644 --- a/modules/base_plugins/brew_steps/__init__.py +++ b/modules/base_plugins/brew_steps/__init__.py @@ -21,7 +21,7 @@ class MashStep(StepBase): def init(self): ''' Initialize Step. This method is called once at the beginning of the step - :return: + :return: ''' # set target tep self.set_target_temp(self.temp, self.kettle) @@ -31,7 +31,7 @@ class MashStep(StepBase): ''' Custom Action which can be execute form the brewing dashboard. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface - :return: + :return: ''' if self.is_timer_finished() is None: self.start_timer(int(self.timer) * 60) @@ -46,7 +46,7 @@ class MashStep(StepBase): def execute(self): ''' This method is execute in an interval - :return: + :return: ''' # Check if Target Temp is reached @@ -57,6 +57,7 @@ class MashStep(StepBase): # Check if timer finished and go to next step if self.is_timer_finished() == True: + self.notify("Step Completed!", "Starting the next step", timeout=None) self.next() @@ -77,7 +78,7 @@ class MashInStep(StepBase): def init(self): ''' Initialize Step. This method is called once at the beginning of the step - :return: + :return: ''' # set target tep self.s = False @@ -88,7 +89,7 @@ class MashInStep(StepBase): def execute(self): ''' This method is execute in an interval - :return: + :return: ''' # Check if Target Temp is reached @@ -169,7 +170,7 @@ class BoilStep(StepBase): def init(self): ''' Initialize Step. This method is called once at the beginning of the step - :return: + :return: ''' # set target tep self.set_target_temp(self.temp, self.kettle) @@ -182,7 +183,7 @@ class BoilStep(StepBase): ''' Custom Action which can be execute form the brewing dashboard. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface - :return: + :return: ''' if self.is_timer_finished() is None: self.start_timer(int(self.timer) * 60) @@ -205,7 +206,7 @@ class BoilStep(StepBase): def execute(self): ''' This method is execute in an interval - :return: + :return: ''' # Check if Target Temp is reached if self.get_kettle_temp(self.kettle) >= float(self.temp): From 124a03bd0f64f0986928024a717b601cd7fddb82 Mon Sep 17 00:00:00 2001 From: swimIan Date: Thu, 20 Jul 2017 16:44:57 -0700 Subject: [PATCH 3/3] Add notification(s) at the end of a mashstep, boilstep, and upon reaching boil temperature. --- modules/base_plugins/brew_steps/__init__.py | 23 ++++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/modules/base_plugins/brew_steps/__init__.py b/modules/base_plugins/brew_steps/__init__.py index 177ff46..d55ea82 100644 --- a/modules/base_plugins/brew_steps/__init__.py +++ b/modules/base_plugins/brew_steps/__init__.py @@ -21,7 +21,7 @@ class MashStep(StepBase): def init(self): ''' Initialize Step. This method is called once at the beginning of the step - :return: + :return: ''' # set target tep self.set_target_temp(self.temp, self.kettle) @@ -31,7 +31,7 @@ class MashStep(StepBase): ''' Custom Action which can be execute form the brewing dashboard. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface - :return: + :return: ''' if self.is_timer_finished() is None: self.start_timer(int(self.timer) * 60) @@ -46,7 +46,7 @@ class MashStep(StepBase): def execute(self): ''' This method is execute in an interval - :return: + :return: ''' # Check if Target Temp is reached @@ -57,6 +57,11 @@ class MashStep(StepBase): # Check if timer finished and go to next step if self.is_timer_finished() == True: +<<<<<<< HEAD + self.notify("Mash Step Completed!", "Starting the next step", timeout=None) +======= + self.notify("Step Completed!", "Starting the next step", timeout=None) +>>>>>>> 1c4e16e35839ec699a431a3840d7dfda9430c4cf self.next() @@ -77,7 +82,7 @@ class MashInStep(StepBase): def init(self): ''' Initialize Step. This method is called once at the beginning of the step - :return: + :return: ''' # set target tep self.s = False @@ -88,7 +93,7 @@ class MashInStep(StepBase): def execute(self): ''' This method is execute in an interval - :return: + :return: ''' # Check if Target Temp is reached @@ -169,7 +174,7 @@ class BoilStep(StepBase): def init(self): ''' Initialize Step. This method is called once at the beginning of the step - :return: + :return: ''' # set target tep self.set_target_temp(self.temp, self.kettle) @@ -182,7 +187,7 @@ class BoilStep(StepBase): ''' Custom Action which can be execute form the brewing dashboard. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface - :return: + :return: ''' if self.is_timer_finished() is None: self.start_timer(int(self.timer) * 60) @@ -205,10 +210,11 @@ class BoilStep(StepBase): def execute(self): ''' This method is execute in an interval - :return: + :return: ''' # Check if Target Temp is reached if self.get_kettle_temp(self.kettle) >= float(self.temp): + self.notify("Boil Temp Reached!", "Starting the boil timer", timeout=None) # Check if Timer is Running if self.is_timer_finished() is None: self.start_timer(int(self.timer) * 60) @@ -218,4 +224,5 @@ class BoilStep(StepBase): self.check_hop_timer(3, self.hop_3) # Check if timer finished and go to next step if self.is_timer_finished() == True: + self.notify("Boil Step Completed!", "Starting the next step", timeout=None) self.next()