Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/helpermodules/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class DEFAULT_COLORS(Enum):
CHARGEPOINT = "#007bff"
CONSUMER = "#9C65FF"
VEHICLE = "#17a2b8"
INVERTER = "#28a745"
COUNTER = "#dc3545"
Expand Down
6 changes: 6 additions & 0 deletions packages/helpermodules/measurement_logging/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
from control.chargepoint.chargepoint_all import AllChargepoints
from control import bat_all, counter, pv_all, pv
from control import data
from control.consumer.consumer import Consumer
from control.consumer.consumer_all import AllConsumers
from modules.consumers.generic.mqtt.config import Mqtt


@pytest.fixture(autouse=True)
def data_module() -> None:
data.data_init(Event())
data.data.bat_data.update({"all": bat_all.BatAll(), "bat2": Bat(2)})
data.data.consumer_all_data = AllConsumers()
data.data.consumer_data.update({"consumer6": Consumer(6)})
data.data.consumer_data["consumer6"].data.module = Mqtt()
data.data.counter_data.update({"counter0": counter.Counter(0)})
data.data.cp_all_data = AllChargepoints()
data.data.cp_data.update({"cp4": chargepoint.Chargepoint(
Expand Down
8 changes: 6 additions & 2 deletions packages/helpermodules/measurement_logging/write_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def get_names(elements: Dict, sh_names: Dict, valid_names: Optional[Dict] = None
"""
names = sh_names
for group in elements.items():
if group[0] not in ("bat", "counter", "cp", "pv", "ev", "sh"):
if group[0] not in ("bat", "consumer", "counter", "cp", "pv", "ev", "sh"):
continue
for entry in group[1]:
# valid_names wird aus update_config übergeben, da dort noch kein Zugriff auf data möglich ist
Expand All @@ -396,6 +396,8 @@ def get_names(elements: Dict, sh_names: Dict, valid_names: Optional[Dict] = None
try:
if "ev" in entry:
names.update({entry: data.data.ev_data[entry].data.name})
elif "consumer" in entry:
names.update({entry: data.data.consumer_data[entry].data.module.name})
elif "cp" in entry:
names.update({entry: data.data.cp_data[entry].data.config.name})
elif "all" != entry:
Expand All @@ -416,13 +418,15 @@ def get_colors(elements: Dict) -> Dict:
"""
colors = {}
for group in elements.items():
if group[0] not in ("ev", "cp", "counter", "pv", "bat"):
if group[0] not in ("ev", "cp", "counter", "consumer", "pv", "bat"):
continue
for entry in group[1]:
if "all" != entry:
try:
if "ev" in entry:
colors.update({entry: data.data.ev_data[entry].data.color})
elif "consumer" in entry:
colors.update({entry: data.data.consumer_data[entry].data.module.color})
elif "cp" in entry:
colors.update({entry: data.data.cp_data[entry].data.config.color})
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_get_names(daily_log_totals, monkeypatch):

# evaluation
assert names == {'bat2': "Speicher",
"consumer6": "MQTT-Verbraucher",
'counter0': "Zähler",
'cp3': "cp3",
Comment on lines 14 to 18
'cp4': "neuer Ladepunkt",
Expand Down
10 changes: 8 additions & 2 deletions packages/modules/common/consumer_setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Generic, List, TypeVar
from typing import Generic, Optional, TypeVar, Tuple

from control.consumer.usage import ConsumerUsage
from helpermodules.constants import DEFAULT_COLORS


T = TypeVar("T")
Expand All @@ -13,11 +14,16 @@ def __init__(self,
id: int,
vendor: str,
configuration: T,
usage: List[ConsumerUsage]) -> None:
usage: Tuple[ConsumerUsage, ...],
color: Optional[str] = None) -> None:
self.name = name
self.info = {"manufacturer": None, "model": None}
self.type = type
self.id = id
self.configuration = configuration
self.vendor = vendor
self.usage = usage
if color:
self.color = color
else:
self.color = DEFAULT_COLORS.CONSUMER.value
9 changes: 5 additions & 4 deletions packages/modules/consumers/askoma/askoheat/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand All @@ -24,7 +24,8 @@ def __init__(self,
type: str = "askoheat",
id: int = 0,
configuration: AskoheatConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or AskoheatConfiguration(), usage=usage)
).type, configuration=configuration or AskoheatConfiguration(), usage=usage, **kwargs)
9 changes: 5 additions & 4 deletions packages/modules/consumers/avm/avm/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -30,7 +30,8 @@ def __init__(self,
type: str = "avm",
id: int = 0,
configuration: AvmConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or AvmConfiguration(), usage=usage)
).type, configuration=configuration or AvmConfiguration(), usage=usage, **kwargs)
7 changes: 4 additions & 3 deletions packages/modules/consumers/generic/dac/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -27,6 +27,7 @@ def __init__(self,
type: str = "dac",
id: int = 0,
configuration: DacConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or DacConfiguration(), usage=usage)
).type, configuration=configuration or DacConfiguration(), usage=usage, **kwargs)
13 changes: 7 additions & 6 deletions packages/modules/consumers/generic/http/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -40,9 +40,10 @@ def __init__(self,
type: str = "http",
id: int = 0,
configuration: HttpConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.METER_ONLY,
ConsumerUsage.CONTINUOUS,
ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.SUSPENDABLE_TUNABLE]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.METER_ONLY,
ConsumerUsage.CONTINUOUS,
ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.SUSPENDABLE_TUNABLE),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or HttpConfiguration(), usage=usage)
).type, configuration=configuration or HttpConfiguration(), usage=usage, **kwargs)
13 changes: 7 additions & 6 deletions packages/modules/consumers/generic/json/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -40,9 +40,10 @@ def __init__(self,
type: str = "json",
id: int = 0,
configuration: JsonConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.METER_ONLY,
ConsumerUsage.CONTINUOUS,
ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.SUSPENDABLE_TUNABLE]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.METER_ONLY,
ConsumerUsage.CONTINUOUS,
ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.SUSPENDABLE_TUNABLE),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or JsonConfiguration(), usage=usage)
).type, configuration=configuration or JsonConfiguration(), usage=usage, **kwargs)
13 changes: 7 additions & 6 deletions packages/modules/consumers/generic/mqtt/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand All @@ -19,9 +19,10 @@ def __init__(self,
type: str = "mqtt",
id: int = 0,
configuration: MqttConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.METER_ONLY,
ConsumerUsage.CONTINUOUS,
ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.SUSPENDABLE_TUNABLE]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.METER_ONLY,
ConsumerUsage.CONTINUOUS,
ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.SUSPENDABLE_TUNABLE),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or MqttConfiguration(), usage=usage)
).type, configuration=configuration or MqttConfiguration(), usage=usage, **kwargs)
9 changes: 5 additions & 4 deletions packages/modules/consumers/idm/idm/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -26,7 +26,8 @@ def __init__(self,
type: str = "idm",
id: int = 0,
configuration: IdmConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or IdmConfiguration(), usage=usage)
).type, configuration=configuration or IdmConfiguration(), usage=usage, **kwargs)
9 changes: 5 additions & 4 deletions packages/modules/consumers/lambda_/lambda_/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -26,7 +26,8 @@ def __init__(self,
type: str = "lambda",
id: int = 0,
configuration: LambdaConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or LambdaConfiguration(), usage=usage)
).type, configuration=configuration or LambdaConfiguration(), usage=usage, **kwargs)
9 changes: 5 additions & 4 deletions packages/modules/consumers/my_pv/acthor/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -28,7 +28,8 @@ def __init__(self,
type: str = "acthor",
id: int = 0,
configuration: ActhorConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or ActhorConfiguration(), usage=usage)
).type, configuration=configuration or ActhorConfiguration(), usage=usage, **kwargs)
9 changes: 5 additions & 4 deletions packages/modules/consumers/my_pv/elwa_e/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand All @@ -24,7 +24,8 @@ def __init__(self,
type: str = "elwa_e",
id: int = 0,
configuration: ElwaConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,
ConsumerUsage.METER_ONLY),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or ElwaConfiguration(), usage=usage)
).type, configuration=configuration or ElwaConfiguration(), usage=usage, **kwargs)
9 changes: 5 additions & 4 deletions packages/modules/consumers/mystrom/mystrom/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand All @@ -19,7 +19,8 @@ def __init__(self,
type: str = "mystrom",
id: int = 0,
configuration: MyStromConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_ONOFF,
ConsumerUsage.METER_ONLY),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or MyStromConfiguration(), usage=usage)
).type, configuration=configuration or MyStromConfiguration(), usage=usage, **kwargs)
7 changes: 4 additions & 3 deletions packages/modules/consumers/nibe/nibe_s_series/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand All @@ -22,6 +22,7 @@ def __init__(self,
type: str = "nibe_s_series",
id: int = 0,
configuration: NibeConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.METER_ONLY,),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or NibeConfiguration(), usage=usage)
).type, configuration=configuration or NibeConfiguration(), usage=usage, **kwargs)
7 changes: 4 additions & 3 deletions packages/modules/consumers/ratiotherm/ratiotherm/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand All @@ -24,6 +24,7 @@ def __init__(self,
type: str = "ratiotherm",
id: int = 0,
configuration: RatiothermConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.SUSPENDABLE_TUNABLE]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.SUSPENDABLE_TUNABLE,),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or RatiothermConfiguration(), usage=usage)
).type, configuration=configuration or RatiothermConfiguration(), usage=usage, **kwargs)
7 changes: 4 additions & 3 deletions packages/modules/consumers/shelly/shelly_em/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -28,6 +28,7 @@ def __init__(self,
type: str = "shelly_em",
id: int = 0,
configuration: ShellyConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.METER_ONLY,),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or ShellyConfiguration(), usage=usage)
).type, configuration=configuration or ShellyConfiguration(), usage=usage, **kwargs)
9 changes: 5 additions & 4 deletions packages/modules/consumers/shelly/shelly_pm/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand Down Expand Up @@ -30,7 +30,8 @@ def __init__(self,
type: str = "shelly_pm",
id: int = 0,
configuration: ShellyConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.METER_ONLY,
ConsumerUsage.SUSPENDABLE_ONOFF]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.METER_ONLY,
ConsumerUsage.SUSPENDABLE_ONOFF),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or ShellyConfiguration(), usage=usage)
).type, configuration=configuration or ShellyConfiguration(), usage=usage, **kwargs)
7 changes: 4 additions & 3 deletions packages/modules/consumers/solvis/solvis/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional, Tuple

from control.consumer.consumer_data import ConsumerUsage
from helpermodules.auto_str import auto_str
Expand All @@ -21,6 +21,7 @@ def __init__(self,
type: str = "solvis",
id: int = 0,
configuration: SolvisConfiguration = None,
usage: List[ConsumerUsage] = [ConsumerUsage.METER_ONLY]) -> None:
usage: Tuple[ConsumerUsage, ...] = (ConsumerUsage.METER_ONLY,),
**kwargs) -> None:
super().__init__(name, type, id, vendor=vendor_descriptor.configuration_factory(
).type, configuration=configuration or SolvisConfiguration(), usage=usage)
).type, configuration=configuration or SolvisConfiguration(), usage=usage, **kwargs)
Loading