-
Notifications
You must be signed in to change notification settings - Fork 111
Feature custom colors #2609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature custom colors #2609
Changes from all commits
5d55e9f
7bb1598
a0f0409
da5c994
656d50a
4b95554
5917b61
352194a
1b5f1a5
56020b4
27c9225
ab438b3
7c9bfb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,83 +14,86 @@ | |
| from helpermodules import timecheck | ||
| from helpermodules.utils.json_file_handler import write_and_check | ||
| from helpermodules.utils.topic_parser import decode_payload, get_index | ||
| from modules.common.utils.component_parser import get_component_name_by_id | ||
| from modules.common.utils.component_parser import get_component_name_by_id, get_component_color_by_id | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
| # erstellt für jeden Tag eine Datei, die die Daten für den Langzeitgraph enthält. | ||
| # Dazu werden alle 5 Min folgende Daten als json-Liste gespeichert: | ||
| # {"entries": [ | ||
| # { | ||
| # "timestamp": int, | ||
| # "date": str, | ||
| # "prices": { | ||
| # "grid": Preis für Netzbezug, | ||
| # "pv": Preis für PV-Strom, | ||
| # "bat": Preis für Speicherstrom | ||
| # } | ||
| # "cp": { | ||
| # "cp1": { | ||
| # "imported": Zählerstand in Wh, | ||
| # "exported": Zählerstand in Wh | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # "all": { | ||
| # "imported": Zählerstand in Wh, | ||
| # "exported": Zählerstand in Wh | ||
| # } | ||
| # } | ||
| # "ev": { | ||
| # "ev1": { | ||
| # "soc": int in % | ||
| # { | ||
| # "entries": [ | ||
| # { | ||
| # "timestamp": int, | ||
| # "date": str, | ||
| # "prices": { | ||
| # "grid": Preis für Netzbezug, | ||
| # "pv": Preis für PV-Strom, | ||
| # "bat": Preis für Speicherstrom | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # "counter": { | ||
| # "counter0": { | ||
| # "grid": bool, | ||
| # "imported": Wh, | ||
| # "exported": Wh | ||
| # "cp": { | ||
| # "cp1": { | ||
| # "imported": Zählerstand in Wh, | ||
| # "exported": Zählerstand in Wh | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # "all": { | ||
| # "imported": Zählerstand in Wh, | ||
| # "exported": Zählerstand in Wh | ||
| # } | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # "pv": { | ||
| # "all": { | ||
| # "exported": Wh | ||
| # "ev": { | ||
| # "ev1": { | ||
| # "soc": int in % | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # "pv0": { | ||
| # "exported": Wh | ||
| # "counter": { | ||
| # "counter0": { | ||
| # "grid": bool, | ||
| # "imported": Wh, | ||
| # "exported": Wh | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # "bat": { | ||
| # "all": { | ||
| # "imported": Wh, | ||
| # "exported": Wh, | ||
| # "soc": int in % | ||
| # "pv": { | ||
| # "all": { | ||
| # "exported": Wh | ||
| # } | ||
| # "pv0": { | ||
| # "exported": Wh | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # "bat0": { | ||
| # "imported": Wh, | ||
| # "exported": Wh, | ||
| # "soc": int in % | ||
| # "bat": { | ||
| # "all": { | ||
| # "imported": Wh, | ||
| # "exported": Wh, | ||
| # "soc": int in % | ||
| # } | ||
| # "bat0": { | ||
| # "imported": Wh, | ||
| # "exported": Wh, | ||
| # "soc": int in % | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # ... (dynamisch, je nach konfigurierter Anzahl) | ||
| # } | ||
| # "sh": { | ||
| # "sh1": { | ||
| # "exported": Wh, | ||
| # "imported": Wh, | ||
| # wenn konfiguriert: | ||
| # "temp1": int in °C, | ||
| # "temp2": int in °C, | ||
| # "temp3": int in °C | ||
| # "sh": { | ||
| # "sh1": { | ||
| # "exported": Wh, | ||
| # "imported": Wh, | ||
| # wenn konfiguriert: | ||
| # "temp1": int in °C, | ||
| # "temp2": int in °C, | ||
| # "temp3": int in °C | ||
| # }, | ||
| # ... (dynamisch, je nach Anzahl konfigurierter Geräte) | ||
| # }, | ||
| # ... (dynamisch, je nach Anzahl konfigurierter Geräte) | ||
| # }, | ||
| # "hc": {"all": {"imported": Wh # Hausverbrauch}} | ||
| # }], | ||
| # "names": "names": {"sh1": "", "cp1": "", "counter2": "", "pv3": ""} | ||
| # } | ||
| # "hc": {"all": {"imported": Wh # Hausverbrauch}} | ||
| # } | ||
| # ], | ||
| # "names": {"cp1": "", "counter2": "", "pv3": ""}, | ||
| # "colors": {"cp1": "", "counter2": "", "pv3": ""}, | ||
| # } | ||
|
|
||
|
|
||
| class LogType(Enum): | ||
|
|
@@ -165,6 +168,7 @@ def save_log(log_type: LogType): | |
| entries = content["entries"] | ||
| entries.append(new_entry) | ||
| content["names"] = get_names(content["entries"][-1], sh_log_data.sh_names) | ||
| content["colors"] = get_colors(content["entries"][-1]) | ||
| write_and_check(filepath, content) | ||
| return content["entries"] | ||
| except Exception: | ||
|
|
@@ -357,3 +361,30 @@ def get_names(elements: Dict, sh_names: Dict, valid_names: Optional[Dict] = None | |
| except (ValueError, KeyError, AttributeError): | ||
| names.update({entry: entry}) | ||
| return names | ||
|
|
||
|
|
||
| def get_colors(elements: Dict) -> Dict: | ||
| """ Ermittelt die Farben der Fahrzeuge, Ladepunkte und Komponenten, welche | ||
| in elements vorhanden sind und gibt diese als Dictionary zurück. | ||
| Parameter | ||
| --------- | ||
| elements: dict | ||
| Dictionary, das die Messwerte enthält. | ||
| """ | ||
|
Comment on lines
+366
to
+373
|
||
| colors = {} | ||
| for group in elements.items(): | ||
| if group[0] not in ("ev", "cp", "counter", "pv", "bat"): | ||
| continue | ||
| for entry in group[1]: | ||
benderl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if "all" != entry: | ||
| try: | ||
| if "ev" in entry: | ||
| colors.update({entry: data.data.ev_data[entry].data.color}) | ||
| elif "cp" in entry: | ||
| colors.update({entry: data.data.cp_data[entry].data.config.color}) | ||
| else: | ||
| id = entry.strip(string.ascii_letters) | ||
| colors.update({entry: get_component_color_by_id(int(id))}) | ||
| except (ValueError, KeyError, AttributeError): | ||
| colors.update({entry: "#000000"}) | ||
| return colors | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from concurrent.futures import ProcessPoolExecutor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from dataclasses import asdict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import datetime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -57,7 +58,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class UpdateConfig: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DATASTORE_VERSION = 116 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DATASTORE_VERSION = 117 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| valid_topic = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/bat/config/bat_control_permitted$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -370,6 +371,7 @@ class UpdateConfig: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/vehicle/[0-9]+/charge_template$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/vehicle/[0-9]+/ev_template$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/vehicle/[0-9]+/name$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/vehicle/[0-9]+/color$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/vehicle/[0-9]+/info$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/vehicle/[0-9]+/soc_module/calculated_soc_state$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "^openWB/vehicle/[0-9]+/soc_module/config$", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -571,6 +573,7 @@ class UpdateConfig: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("openWB/counter/config/consider_less_charging", counter_all.Config().consider_less_charging), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("openWB/counter/config/home_consumption_source_id", counter_all.Config().home_consumption_source_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("openWB/vehicle/0/name", "Standard-Fahrzeug"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("openWB/vehicle/0/color", "#17a2b8"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("openWB/vehicle/0/info", {"manufacturer": None, "model": None}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("openWB/vehicle/0/charge_template", ev.Ev(0).charge_template.data.id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ("openWB/vehicle/0/soc_module/config", NO_MODULE), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -3004,3 +3007,84 @@ def upgrade(topic: str, payload) -> Optional[dict]: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return {topic: payload} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._loop_all_received_topics(upgrade) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._append_datastore_version(116) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def upgrade_datastore_117(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEFAULT_COLORS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "CHARGEPOINT": "#007bff", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "VEHICLE": "#17a2b8", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "INVERTER": "#28a745", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "COUNTER": "#dc3545", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3011
to
+3016
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "BATTERY": "#ffc107", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "UNKNOWN": "#000000" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _add_colors_to_log(file): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with open(file, "r+") as jsonFile: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content_raw = jsonFile.read() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content = json.loads(content_raw) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "colors" in content: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for key in content["names"].keys(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "bat" in key: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors[key] = DEFAULT_COLORS["BATTERY"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif "counter" in key: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors[key] = DEFAULT_COLORS["COUNTER"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif "cp" in key: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors[key] = DEFAULT_COLORS["CHARGEPOINT"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif "ev" in key: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors[key] = DEFAULT_COLORS["VEHICLE"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif "pv" in key: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors[key] = DEFAULT_COLORS["INVERTER"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors[key] = DEFAULT_COLORS["UNKNOWN"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content["colors"] = colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jsonFile.seek(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jsonFile.write(json.dumps(content)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jsonFile.truncate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3023
to
+3045
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with open(file, "r+") as jsonFile: | |
| content_raw = jsonFile.read() | |
| content = json.loads(content_raw) | |
| if "colors" in content: | |
| return | |
| for key in content["names"].keys(): | |
| if "bat" in key: | |
| colors[key] = DEFAULT_COLORS["BATTERY"] | |
| elif "counter" in key: | |
| colors[key] = DEFAULT_COLORS["COUNTER"] | |
| elif "cp" in key: | |
| colors[key] = DEFAULT_COLORS["CHARGEPOINT"] | |
| elif "ev" in key: | |
| colors[key] = DEFAULT_COLORS["VEHICLE"] | |
| elif "inverter" in key: | |
| colors[key] = DEFAULT_COLORS["INVERTER"] | |
| else: | |
| colors[key] = DEFAULT_COLORS["UNKNOWN"] | |
| content["colors"] = colors | |
| jsonFile.seek(0) | |
| jsonFile.write(json.dumps(content)) | |
| jsonFile.truncate() | |
| try: | |
| with open(file, "r+") as jsonFile: | |
| content_raw = jsonFile.read() | |
| try: | |
| content = json.loads(content_raw) | |
| except json.JSONDecodeError: | |
| log.warning("Skipping invalid log file (JSON decode failed): %s", file) | |
| return | |
| if "colors" in content: | |
| return | |
| names = content.get("names", {}) | |
| if not isinstance(names, dict): | |
| log.warning("Skipping log file without valid 'names' mapping: %s", file) | |
| return | |
| for key in names.keys(): | |
| if "bat" in key: | |
| colors[key] = DEFAULT_COLORS["BATTERY"] | |
| elif "counter" in key: | |
| colors[key] = DEFAULT_COLORS["COUNTER"] | |
| elif "cp" in key: | |
| colors[key] = DEFAULT_COLORS["CHARGEPOINT"] | |
| elif "ev" in key: | |
| colors[key] = DEFAULT_COLORS["VEHICLE"] | |
| elif "inverter" in key: | |
| colors[key] = DEFAULT_COLORS["INVERTER"] | |
| else: | |
| colors[key] = DEFAULT_COLORS["UNKNOWN"] | |
| content["colors"] = colors | |
| jsonFile.seek(0) | |
| jsonFile.write(json.dumps(content)) | |
| jsonFile.truncate() | |
| except OSError: | |
| # If the file cannot be opened or written, skip it without aborting the upgrade. | |
| log.warning("Skipping log file due to I/O error: %s", file) |
Copilot
AI
Mar 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ProcessPoolExecutor here has a few operational risks: the worker function is nested (can’t be pickled under the spawn start method), and exceptions from executor.map(...) won’t be surfaced unless the returned iterator is consumed. Consider switching to ThreadPoolExecutor (I/O-bound work) or moving the worker to module scope and explicitly consuming the results (e.g., for _ in executor.map(...): pass) so failures aren’t silently ignored.
Uh oh!
There was an error while loading. Please reload this page.