-
Notifications
You must be signed in to change notification settings - Fork 115
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
2774e40
0621575
c2da757
1ba4e16
702eb43
54211b9
cc320a9
f6aea06
00f1a78
7f5b5fb
1c4400f
601194b
03e1c1a
a319535
29cd118
7ef8a4f
2d896e9
5d6afe9
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.
|
||
| 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 | ||
Uh oh!
There was an error while loading. Please reload this page.