diff --git a/packages/modules/devices/zendure/vendor.py b/packages/modules/devices/zendure/vendor.py new file mode 100644 index 0000000000..cb9ded642c --- /dev/null +++ b/packages/modules/devices/zendure/vendor.py @@ -0,0 +1,14 @@ +from pathlib import Path + +from modules.common.abstract_device import DeviceDescriptor +from modules.devices.vendors import VendorGroup + + +class Vendor: + def __init__(self): + self.type = Path(__file__).parent.name + self.vendor = "Zendure" + self.group = VendorGroup.VENDORS.value + + +vendor_descriptor = DeviceDescriptor(configuration_factory=Vendor) diff --git a/packages/modules/devices/zendure/zendure/bat.py b/packages/modules/devices/zendure/zendure/bat.py new file mode 100644 index 0000000000..8d7dabd9a9 --- /dev/null +++ b/packages/modules/devices/zendure/zendure/bat.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +from modules.common.component_type import ComponentDescriptor +from modules.devices.zendure.zendure.config import ZendureBatSetup + + +component_descriptor = ComponentDescriptor(configuration_factory=ZendureBatSetup) diff --git a/packages/modules/devices/zendure/zendure/config.py b/packages/modules/devices/zendure/zendure/config.py new file mode 100644 index 0000000000..6b0d8d956b --- /dev/null +++ b/packages/modules/devices/zendure/zendure/config.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +from typing import Optional + +from helpermodules.auto_str import auto_str +from modules.devices.generic.json.config import (Json, JsonConfiguration, JsonCounterConfiguration, + JsonInverterConfiguration, JsonBatConfiguration, + JsonCounterSetup, JsonInverterSetup, JsonBatSetup) +from ..vendor import vendor_descriptor + + +@auto_str +class ZendureConfiguration(JsonConfiguration): + def __init__(self, url: Optional[str] = None): + self.url = f"http://{url}/properties/report" + + +@auto_str +class Zendure(Json): + def __init__(self, + name: str = "Zendure", + type: str = "zendure", + id: int = 0, + configuration: ZendureConfiguration = None) -> None: + super().__init__(name, type, id, configuration) + self.vendor = vendor_descriptor.configuration_factory().type + + +@auto_str +class ZendureCounterConfiguration: + def __init__(self): + pass + + +@auto_str +class ZendureCounterSetup(JsonCounterSetup): + def __init__(self, + name: str = "Zendure Zähler", + type: str = "counter", + id: int = 0, + configuration: JsonCounterConfiguration = None) -> None: + super().__init__(name, type, id, JsonCounterConfiguration( + jq_power=".properties.gridInputPower")) + + +@auto_str +class ZendureInverterConfiguration: + def __init__(self): + pass + + +@auto_str +class ZendureInverterSetup(JsonInverterSetup): + def __init__(self, + name: str = "Zendure Wechselrichter", + type: str = "inverter", + id: int = 0, + configuration: JsonInverterConfiguration = None) -> None: + super().__init__(name, type, id, JsonInverterConfiguration( + jq_power="- .properties.solarInputPower")) + + +@auto_str +class ZendureBatConfiguration: + def __init__(self): + pass + + +@auto_str +class ZendureBatSetup(JsonBatSetup): + def __init__(self, + name: str = "Zendure Speicher", + type: str = "bat", + id: int = 0, + configuration: JsonBatConfiguration = None) -> None: + super().__init__(name, type, id, JsonBatConfiguration( + jq_power=".properties.outputPackPower - .properties.packInputPower", + jq_soc=".properties.electricLevel")) diff --git a/packages/modules/devices/zendure/zendure/counter.py b/packages/modules/devices/zendure/zendure/counter.py new file mode 100644 index 0000000000..15bb29d282 --- /dev/null +++ b/packages/modules/devices/zendure/zendure/counter.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +from modules.common.component_type import ComponentDescriptor +from modules.devices.zendure.zendure.config import ZendureCounterSetup + + +component_descriptor = ComponentDescriptor(configuration_factory=ZendureCounterSetup) diff --git a/packages/modules/devices/zendure/zendure/device.py b/packages/modules/devices/zendure/zendure/device.py new file mode 100644 index 0000000000..fc1d9ce735 --- /dev/null +++ b/packages/modules/devices/zendure/zendure/device.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import logging +from modules.common.abstract_device import DeviceDescriptor +from modules.devices.zendure.zendure.config import Zendure +from modules.devices.generic.json.device import create_device as create_device_json +log = logging.getLogger(__name__) + + +def create_device(device_config: Zendure): + return create_device_json(device_config) + + +device_descriptor = DeviceDescriptor(configuration_factory=Zendure) diff --git a/packages/modules/devices/zendure/zendure/inverter.py b/packages/modules/devices/zendure/zendure/inverter.py new file mode 100644 index 0000000000..9b3d323698 --- /dev/null +++ b/packages/modules/devices/zendure/zendure/inverter.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +from modules.common.component_type import ComponentDescriptor +from modules.devices.zendure.zendure.config import ZendureInverterSetup + + +component_descriptor = ComponentDescriptor(configuration_factory=ZendureInverterSetup)