Skip to content

Commit

Permalink
benning (#1371)
Browse files Browse the repository at this point in the history
* benning

* add OpenDTU module
  • Loading branch information
ndrsnhs committed Mar 26, 2024
1 parent dbe798f commit 4d08723
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 0 deletions.
Empty file.
37 changes: 37 additions & 0 deletions packages/modules/devices/benning/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
from typing import Optional
from helpermodules.auto_str import auto_str
from modules.devices.json.config import Json, JsonConfiguration, JsonInverterConfiguration, JsonInverterSetup


@auto_str
class BenningConfiguration(JsonConfiguration):
def __init__(self, url: Optional[str] = None):
self.url = "http://" + url + "/getentries.cgi?oids=11369,19000"


@auto_str
class Benning(Json):
def __init__(self,
name: str = "Benning",
type: str = "benning",
id: int = 0,
configuration: BenningConfiguration = None) -> None:
super().__init__(name, type, id, configuration)


@auto_str
class BenningInverterConfiguration:
def __init__(self):
pass


@auto_str
class BenningInverterSetup(JsonInverterSetup):
def __init__(self,
name: str = "Benning Wechselrichter",
type: str = "inverter",
id: int = 0,
configuration: JsonInverterConfiguration = None) -> None:
super().__init__(name, type, id, JsonInverterConfiguration(
jq_power=".[]|select(.oid==11365)|.val|tonumber", jq_exported=".[]|select(.oid==19000)|.val|tonumber"))
13 changes: 13 additions & 0 deletions packages/modules/devices/benning/device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3
import logging
from modules.common.abstract_device import DeviceDescriptor
from modules.devices.benning.config import Benning
from modules.devices.json.device import create_device as create_device_json
log = logging.getLogger(__name__)


def create_device(device_config: Benning):
return create_device_json(device_config)


device_descriptor = DeviceDescriptor(configuration_factory=Benning)
6 changes: 6 additions & 0 deletions packages/modules/devices/benning/inverter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python3
from modules.common.component_type import ComponentDescriptor
from modules.devices.benning.config import BenningInverterSetup


component_descriptor = ComponentDescriptor(configuration_factory=BenningInverterSetup)
Empty file.
37 changes: 37 additions & 0 deletions packages/modules/devices/opendtu/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
from typing import Optional
from helpermodules.auto_str import auto_str
from modules.devices.json.config import Json, JsonConfiguration, JsonInverterConfiguration, JsonInverterSetup


@auto_str
class OpenDTUConfiguration(JsonConfiguration):
def __init__(self, url: Optional[str] = None):
self.url = "http://" + url + "/api/livedata/status"


@auto_str
class OpenDTU(Json):
def __init__(self,
name: str = "OpenDTU",
type: str = "opendtu",
id: int = 0,
configuration: OpenDTUConfiguration = None) -> None:
super().__init__(name, type, id, configuration)


@auto_str
class OpenDTUInverterConfiguration:
def __init__(self):
pass


@auto_str
class OpenDTUInverterSetup(JsonInverterSetup):
def __init__(self,
name: str = "Hoymiles Wechselrichter",
type: str = "inverter",
id: int = 0,
configuration: JsonInverterConfiguration = None) -> None:
super().__init__(name, type, id, JsonInverterConfiguration(
jq_power=".total.Power.v", jq_exported=".total.YieldTotal.v*1000"))
13 changes: 13 additions & 0 deletions packages/modules/devices/opendtu/device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3
import logging
from modules.common.abstract_device import DeviceDescriptor
from modules.devices.opendtu.config import OpenDTU
from modules.devices.json.device import create_device as create_device_json
log = logging.getLogger(__name__)


def create_device(device_config: OpenDTU):
return create_device_json(device_config)


device_descriptor = DeviceDescriptor(configuration_factory=OpenDTU)
6 changes: 6 additions & 0 deletions packages/modules/devices/opendtu/inverter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python3
from modules.common.component_type import ComponentDescriptor
from modules.devices.opendtu.config import OpenDTUInverterSetup


component_descriptor = ComponentDescriptor(configuration_factory=OpenDTUInverterSetup)

0 comments on commit 4d08723

Please sign in to comment.