From 59be57fd75961ca8556cd9dd8f193160441d26ac Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:27:59 +0200 Subject: [PATCH] changes for UI 0.3.14.a8 (CustomSVG properties will be changed automatically) --- cbpi/__init__.py | 2 +- cbpi/extension/ConfigUpdate/__init__.py | 33 ++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 61bc3b4..1d83bc6 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.4.1.a16" +__version__ = "4.4.1.a17" __codename__ = "Yeast Starter" diff --git a/cbpi/extension/ConfigUpdate/__init__.py b/cbpi/extension/ConfigUpdate/__init__.py index cecb22f..19c3434 100644 --- a/cbpi/extension/ConfigUpdate/__init__.py +++ b/cbpi/extension/ConfigUpdate/__init__.py @@ -8,6 +8,7 @@ import json from cbpi.api import * from cbpi.api.config import ConfigType from cbpi.api.base import CBPiBase +import glob from cbpi import __version__ logger = logging.getLogger(__name__) @@ -502,7 +503,37 @@ class ConfigUpdate(CBPiExtension): else: if CONFIG_STATUS is None or CONFIG_STATUS != self.version: await self.cbpi.config.add("current_grid", current_grid, type=ConfigType.NUMBER, description="Dashboard Grid Width",source="hidden") - + + # Check if CustomSVG props are correct for latest functionality (Widget dependent on acxtor state -> UI >= 0.3.14.a8) + try: + dashboard_files=glob.glob(self.cbpi.config_folder.get_dashboard_path('cbpi_dashboard*.json')) + write=False + + for dashboard_file in dashboard_files: + with open(dashboard_file, 'r') as file: + data = json.load(file) + + for id in data['elements']: + if id['type'] == 'CustomSVG': + try: + testoff = (id['props']['WidgetOff']) + except: + id['props']['WidgetOff'] = id['props']['name'] + write=True + try: + teston = (id['props']['WidgetOn']) + except: + try: + id['props']['WidgetOn'] = id['props']['nameon'] + write=True + except: + pass + + if write: + with open(dashboard_file, 'w') as outfile: + json.dump(data, outfile, indent=4, sort_keys=True) + except Exception as e: + logging.error(e) ## Check if influxdbname is in config