Merge pull request #58 from phylax2020/master

Add parameter in settings to slow down pipe animation in dashboard
This commit is contained in:
Alexander Vollkopf 2022-08-07 13:57:45 +02:00 committed by GitHub
commit 635ea3649c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View file

@ -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

View file

@ -49,6 +49,7 @@ 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")
@ -299,10 +300,19 @@ 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)

View file

@ -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)