From c0997ff357ecfe3b0fc0c8ececd125091b207aae Mon Sep 17 00:00:00 2001 From: phylax2020 Date: Thu, 21 Jul 2022 10:27:54 +0200 Subject: [PATCH] Add setting parameter for dashboard pipe animation slow down --- cbpi/controller/dashboard_controller.py | 4 ++++ cbpi/extension/ConfigUpdate/__init__.py | 16 +++++++++++++--- cbpi/http_endpoints/http_dashboard.py | 12 ++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/cbpi/controller/dashboard_controller.py b/cbpi/controller/dashboard_controller.py index 228839c..2f39af5 100644 --- a/cbpi/controller/dashboard_controller.py +++ b/cbpi/controller/dashboard_controller.py @@ -64,3 +64,7 @@ class DashboardController: async def set_current_dashboard(self, dashboard_id=1): await self.cbpi.config.set("current_dashboard_number", dashboard_id) return {"status": "OK"} + + async def get_slow_pipe_animation(self): + slow_pipe_animation = self.cbpi.config.get("slow_pipe_animation", "Yes") + return slow_pipe_animation \ No newline at end of file diff --git a/cbpi/extension/ConfigUpdate/__init__.py b/cbpi/extension/ConfigUpdate/__init__.py index 67ac417..80808c3 100644 --- a/cbpi/extension/ConfigUpdate/__init__.py +++ b/cbpi/extension/ConfigUpdate/__init__.py @@ -49,7 +49,8 @@ class ConfigUpdate(CBPiExtension): PRESSURE_UNIT = self.cbpi.config.get("PRESSURE_UNIT", None) SENSOR_LOG_BACKUP_COUNT = self.cbpi.config.get("SENSOR_LOG_BACKUP_COUNT", None) SENSOR_LOG_MAX_BYTES = self.cbpi.config.get("SENSOR_LOG_MAX_BYTES", None) - + slow_pipe_animation = self.cbpi.config.get("slow_pipe_animation", None) + if boil_temp is None: logger.info("INIT Boil Temp Setting") try: @@ -299,11 +300,20 @@ class ConfigUpdate(CBPiExtension): if SENSOR_LOG_MAX_BYTES is None: logger.info("Init maximum size of sensor logfiles") try: - await self.cbpi.config.add("SENSOR_LOG_MAX_BYTES", 100000, ConfigType.NUMBER, "Max. number of bytes in sensor logfiles") + await self.cbpi.config.add("SENSOR_LOG_MAX_BYTES", 100000, ConfigType.NUMBER, "Max. number of bytes in sensor logs") except: logger.warning('Unable to update database') - + # Check if slow_pipe_animation is in config + if slow_pipe_animation is None: + logger.info("INIT slow_pipe_animation") + try: + await self.cbpi.config.add("slow_pipe_animation", "Yes", ConfigType.SELECT, "Slow down dashboard pipe animation taking up close to 100% of the CPU's capacity", + [{"label": "Yes", "value": "Yes"}, + {"label": "No", "value": "No"}]) + except: + logger.warning('Unable to update config') + def setup(cbpi): cbpi.plugin.register("ConfigUpdate", ConfigUpdate) pass diff --git a/cbpi/http_endpoints/http_dashboard.py b/cbpi/http_endpoints/http_dashboard.py index 53d5d8a..f24fe0c 100644 --- a/cbpi/http_endpoints/http_dashboard.py +++ b/cbpi/http_endpoints/http_dashboard.py @@ -157,3 +157,15 @@ class DashBoardHttpEndpoints: dashboard_id = int(request.match_info['id']) return web.json_response(await self.cbpi.dashboard.set_current_dashboard(dashboard_id)) + @request_mapping(path="/slowPipeAnimation", method="GET", auth_required=False) + async def get_slow_pipe_animation(self, request): + """ + --- + description: Get slow down dashboard pipe animation (Yes/No) + tags: + - Dashboard + responses: + "200": + description: successful operation + """ + return web.json_response(await self.cbpi.dashboard.get_slow_pipe_animation(), dumps=json_dumps)