Skip to content

Commit ce932e6

Browse files
committed
use packages
1 parent 9f2be9c commit ce932e6

33 files changed

+182
-270
lines changed

__init__.py

Whitespace-only changes.

graph.py

-12
This file was deleted.

main.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
import threading
77
import time
88

9-
import algorithm
10-
import charge
11-
import daily_log
12-
import data
13-
import log
14-
import prepare
15-
import pub
16-
import publishvars2
17-
import setdata
18-
import subdata
9+
from packages.algorithm import algorithm
10+
from packages.algorithm import charge
11+
from packages.algorithm import daily_log
12+
from packages.algorithm import data
13+
from packages.helpermodules import log
14+
from packages.algorithm import prepare
15+
from packages.helpermodules import pub
16+
from packages.helpermodules import publishvars2
17+
from packages.helpermodules import setdata
18+
from packages.helpermodules import subdata
1919

2020
class HandlerAlgorithm():
2121
def __init__(self):

packages/__init__.py

Whitespace-only changes.

packages/algorithm/__init__.py

Whitespace-only changes.

algorithm.py packages/algorithm/algorithm.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import copy
55

6-
import data
7-
import loadmanagement
8-
import log
9-
import pub
6+
from . import data
7+
from . import loadmanagement
8+
from ..helpermodules import log
9+
from ..helpermodules import pub
1010

1111

1212
class control():

bat.py packages/algorithm/bat.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
Üblicherweise reicht es so zu regeln das rund 50 Watt Einspeisung da sind, dann "nimmt" der Speicher sich die von alleine
2626
"""
2727

28-
import data
29-
import log
30-
import pub
28+
from . import data
29+
from ..helpermodules import log
30+
from ..helpermodules import pub
3131

3232
class bat:
3333
def __init__(self):

charge.py packages/algorithm/charge.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
""" Starten des Lade-Vorgangs
22
"""
33

4-
import chargelog
5-
import data
6-
import log
7-
import pub
4+
from . import chargelog
5+
from . import data
6+
from ..helpermodules import log
7+
from ..helpermodules import pub
88

99
class charge():
1010
def __init__(self):

chargelog.py packages/algorithm/chargelog.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@
8585
"""
8686

8787
import json
88+
import math
8889
import pathlib
8990

90-
import data
91-
import log
92-
import math
93-
import pub
94-
import timecheck
91+
from . import data
92+
from ..helpermodules import log
93+
from ..helpermodules import pub
94+
from ..helpermodules import timecheck
9595

9696
# alte Daten: Startzeitpunkt der Ladung, Endzeitpunkt, Geladene Reichweite, Energie, Leistung, Ladedauer, LP-Nummer, Lademodus, RFID-Tag
9797
# json-Objekt: {"chargepoint": {"id": 1, "name": "Hof", "rfid": 1234},

chargepoint.py packages/algorithm/chargepoint.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
Liste der Tags, mit denen der Ladepunkt freigeschaltet werden kann. Ist diese leer, kann mit jedem Tag der Ladepunkt freigeschaltet werden.
2626
"""
2727

28-
from charge import charge
29-
import chargelog
30-
import data
31-
import ev
32-
import log
33-
import pub
34-
import timecheck
28+
from . import charge
29+
from . import chargelog
30+
from . import data
31+
from . import ev
32+
from ..helpermodules import log
33+
from ..helpermodules import pub
34+
from ..helpermodules import timecheck
3535

3636

3737
class allChargepoints():

counter.py packages/algorithm/counter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Zähler-Logik
22
"""
33

4-
import log
5-
import pub
4+
from ..helpermodules import log
5+
from ..helpermodules import pub
66

77
class counterAll():
88
"""

daily_log.py packages/algorithm/daily_log.py

+61-23
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import json
44
import pathlib
55

6-
import data
7-
import log
8-
import timecheck
6+
from . import data
7+
from ..helpermodules import log
8+
from ..helpermodules import timecheck
99

1010
def save_daily_log():
1111
""" erstellt für jeden Tag eine Datei, die die Daten für den Langzeitgraph enthält.
@@ -16,23 +16,42 @@ def save_daily_log():
1616
"cp1": {
1717
"counter": Zählerstand in Wh,
1818
}
19-
... (dynamsich, je nach Anzahl konfigurierter Ladepunkte)
19+
... (dynamsich, je nach konfigurierter Anzahl)
2020
}
2121
"ev": {
2222
"ev1": {
2323
"soc": int in %
2424
}
25-
... (dynamsich, je nach Anzahl konfigurierter Ladepunkte)
25+
... (dynamsich, je nach konfigurierter Anzahl)
2626
}
27-
"counter0": {
28-
"imported": Wh,
29-
"exported": Wh
27+
"counter": {
28+
"counter0": {
29+
"imported": Wh,
30+
"exported": Wh
31+
}
32+
... (dynamsich, je nach konfigurierter Anzahl)
33+
}
34+
"pv": {
35+
"all": {
36+
"counter": Wh
37+
}
38+
"pv0": {
39+
"counter": Wh
40+
}
41+
... (dynamsich, je nach konfigurierter Anzahl)
3042
}
31-
"pv_all": Wh
32-
"bat_all": {
33-
"imported": Wh,
34-
"exported": Wh,
35-
"soc": int in %
43+
"bat": {
44+
"all": {
45+
"imported": Wh,
46+
"exported": Wh,
47+
"soc": int in %
48+
}
49+
"bat0": {
50+
"imported": Wh,
51+
"exported": Wh,
52+
"soc": int in %
53+
}
54+
... (dynamsich, je nach konfigurierter Anzahl)
3655
}
3756
"smarthome_devices": {
3857
"device1": {
@@ -63,20 +82,39 @@ def save_daily_log():
6382
except Exception as e:
6483
log.exception_logging(e)
6584

85+
counter_dict = {}
86+
for counter in data.data.counter_data:
87+
try:
88+
if "counter" in counter:
89+
counter_dict.update({counter: {"imported": data.data.counter_data[counter].data["get"]["imported"],
90+
"exported": data.data.counter_data[counter].data["get"]["exported"]}})
91+
except Exception as e:
92+
log.exception_logging(e)
93+
94+
pv_dict = {}
95+
for pv in data.data.pv_data:
96+
try:
97+
pv_dict.update({pv: {"imported": data.data.pv_data[pv].data["get"]["counter"]}})
98+
except Exception as e:
99+
log.exception_logging(e)
100+
101+
bat_dict = {}
102+
for bat in data.data.bat_module_data:
103+
try:
104+
if "bat" in bat:
105+
bat_dict.update({bat: {"imported": data.data.bat_module_data[bat].data["get"]["imported"],
106+
"exported": data.data.bat_module_data[bat].data["get"]["exported"],
107+
"soc": data.data.bat_module_data[bat].data["get"]["soc"]}})
108+
except Exception as e:
109+
log.exception_logging(e)
110+
66111
new_entry = {
67112
"date": timecheck.create_timestamp_time(),
68113
"cp": cp_dict,
69114
"ev": ev_dict,
70-
"counter0": {
71-
"imported": data.data.counter_data["counter0"].data["get"]["imported"],
72-
"exported": data.data.counter_data["counter0"].data["get"]["exported"]
73-
},
74-
"pv_all": data.data.pv_data["all"].data["get"]["counter"],
75-
"bat_all": {
76-
"imported": data.data.bat_module_data["all"].data["get"]["imported"],
77-
"exported": data.data.bat_module_data["all"].data["get"]["exported"],
78-
"soc": data.data.bat_module_data["all"].data["get"]["soc"]
79-
}
115+
"counter": counter_dict,
116+
"pv": pv_dict,
117+
"bat": bat_dict
80118
}
81119

82120
# json-Objekt in Datei einfügen

data.py packages/algorithm/data.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
Dictionary: Zugriff erfolgt bei Dictionary über Keys, nicht über Indizes wie bei Listen. Das hat den Vorteil, dass Instanzen gelöscht werden können, der Zugriff aber nicht verändert werden musss.
33
"""
44

5-
import log
65
import threading
76

7+
from ..helpermodules import log
8+
89
data = None
910

1011
class Data:

ev.py packages/algorithm/ev.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
in der Regelung neu priorisiert werden und eine neue Zuteilung des Stroms erhalten.
88
"""
99

10-
import data
11-
import log
12-
import pub
13-
import timecheck
10+
from . import data
11+
from ..helpermodules import log
12+
from ..helpermodules import pub
13+
from ..helpermodules import timecheck
1414

1515

1616
def get_ev_to_rfid(rfid):

general.py packages/algorithm/general.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Allgemeine Einstellungen
22
"""
33

4-
import data
5-
import log
6-
import pub
4+
from . import data
5+
from ..helpermodules import log
6+
from ..helpermodules import pub
77

88

99
class general():

loadmanagement.py packages/algorithm/loadmanagement.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
ob genug Leistung/Stromstärke verfügbar ist.
1010
"""
1111

12-
import data
13-
import log
12+
from . import data
13+
from ..helpermodules import log
1414

1515
overloaded_counters = {} # {counter: [max_overshoot, phase_with_max_overshoot]}
1616
# phase_with_max_overshoot = -1 -> max. Lesistung wurde überschritten, es ist egal, auf welcher Phase reduziert wird.

optional.py packages/algorithm/optional.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
from math import ceil #Aufrunden
55

6-
import awattargetprices
7-
import log
8-
import tibbergetprices
6+
from ..modules.et import awattargetprices
7+
from ..helpermodules import log
8+
from ..modules.et import tibbergetprices
99

1010
class optional():
1111
"""

prepare.py packages/algorithm/prepare.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
import copy
55

6-
import chargelog
7-
import chargepoint
8-
import data
9-
import log
10-
import pub
11-
import subdata
6+
from . import chargelog
7+
from . import chargepoint
8+
from . import data
9+
from ..helpermodules import log
10+
from ..helpermodules import pub
11+
from ..helpermodules import subdata
1212

1313

1414
class prepare():

pv.py packages/algorithm/pv.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
der sonst in das Netz eingespeist werden würde.
55
"""
66

7-
import algorithm
8-
import data
9-
import log
10-
import pub
11-
import timecheck
7+
from . import algorithm
8+
from . import data
9+
from ..helpermodules import log
10+
from ..helpermodules import pub
11+
from ..helpermodules import timecheck
1212

1313

1414
class pv():

packages/helpermodules/__init__ .py

Whitespace-only changes.
File renamed without changes.

pub.py packages/helpermodules/pub.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import paho.mqtt.client as mqtt
77

8-
import log
8+
from . import log
99

1010
client = None
1111

publishvars2.py packages/helpermodules/publishvars2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pub
1+
from . import pub
22

33

44
def pub_settings():

0 commit comments

Comments
 (0)