Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit e683c1d
Author: okaegi <72255431+okaegi@users.noreply.github.com>
Date:   Mon Jun 12 16:19:44 2023 +0200

    Smarthome... (snaptec#2739)

    * Smarthome...

    Neu wird das MQTT topic mess_only gepflegt. Wenn "kein Gerät" (also nur rein Leisungsmessung definiert ist der wert 1 sonst 0. Hier kann in Zukunft das GUI abfragen ob überhaupt  automatisch / manual Modus angezeigt wird (oder nicht einfach nur "nur Messung")
    Lambda driver wurde an python logging angepasst

    * flake8

    * Smarthome...

    topic wurde von mess_only auf meas_only umbenannt,

    * Revert "Smarthome..."

    This reverts commit 712f618.

    * Revert "flake8"

    This reverts commit f1925e8.

    * revert change

    * sleep

    Sleep aus Smartcommon in smarthomemq verlagert (braucht es nur für 1.9)

commit 274690b
Author: LKuemmel <76958050+LKuemmel@users.noreply.github.com>
Date:   Tue Jun 6 09:12:36 2023 +0200

    youless (snaptec#2715)

    * youless

    * typecast

commit 3bbfc70
Author: LKuemmel <76958050+LKuemmel@users.noreply.github.com>
Date:   Tue Jun 6 09:00:04 2023 +0200

    Solarlog (snaptec#2733)

    * add solarlog

    * n

    * fixes

    * SolarLog

    * restructure legacy code

    * flake8

commit e4f753f
Author: Maxify23 <95931708+Maxify23@users.noreply.github.com>
Date:   Mon Jun 5 09:09:58 2023 +0200

    Sungrow Bash fixes (nightly) + style improvment  (snaptec#2738)

    * Try to fix Sungrow Modul.
    -IP Address not importet
    -sungrow bash commands wrong

    * Modbus ID Reintegration

    * Update modulconfigpv.php

    * solve E128 continuation line under-indented for visual indent

    * solve E128 continuation line under-indented for visual indent

    * solve E128 continuation line under-indented for visual indent

    * remove unnecessary code

    * instert Modbus ID notification

    * remove optional
  • Loading branch information
okaegi committed Jun 13, 2023
1 parent b9d32f5 commit 635e059
Show file tree
Hide file tree
Showing 28 changed files with 393 additions and 256 deletions.
2 changes: 1 addition & 1 deletion modules/bezug_solarlog/main.sh
Expand Up @@ -13,7 +13,7 @@ fi
openwbDebugLog ${DMOD} 2 "Bezug Solarlog IP: ${bezug_solarlog_ip}"
openwbDebugLog ${DMOD} 2 "Bezug Solarlog Speicher : ${bezug_solarlog_speicherv}"

bash "$OPENWBBASEDIR/packages/legacy_run.sh" "bezug_solarlog.solarlog" "${bezug_solarlog_ip}" "${bezug_solarlog_speicherv}" >>"$MYLOGFILE" 2>&1
bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.solar_log.device" "counter" "${bezug_solarlog_ip}" "${bezug_solarlog_speicherv}" >>"$MYLOGFILE" 2>&1
ret=$?

openwbDebugLog ${DMOD} 2 "RET: ${ret}"
Expand Down
60 changes: 0 additions & 60 deletions modules/bezug_solarlog/solarlog.py

This file was deleted.

2 changes: 1 addition & 1 deletion modules/bezug_sungrow/main.sh
Expand Up @@ -13,7 +13,7 @@ fi
if [[ "$pvwattmodul" == "wr_sungrow" ]]; then
echo "value read at pv modul" >/dev/null
else
bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "counter" "$pv1_ipa" "$pv1_ida" "$sungrowsr" "0" "0" >>"$MYLOGFILE" 2>&1
bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "counter" "$pv1_ipa" "$pv1_ida" "$sungrowsr" >>"$MYLOGFILE" 2>&1
ret=$?
fi

Expand Down
2 changes: 1 addition & 1 deletion modules/speicher_sungrow/main.sh
Expand Up @@ -10,7 +10,7 @@ else
MYLOGFILE="$RAMDISKDIR/bat.log"
fi

bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "bat" "$pv1_ipa" "$pv1_ida" "0" "0" >>"$MYLOGFILE" 2>&1
bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "bat" "$pv1_ipa" "$pv1_ida" >>"$MYLOGFILE" 2>&1
ret=$?

openwbDebugLog $DMOD 2 "BAT RET: $ret"
10 changes: 4 additions & 6 deletions modules/wr_solarlog/main.sh
Expand Up @@ -7,10 +7,8 @@ MYLOGFILE="${RAMDISKDIR}/nurpv.log"
DMOD="PV"
Debug=$debug

bash "$OPENWBBASEDIR/packages/legacy_run.sh" "wr_solarlog.solarlog" "${bezug_solarlog_ip}" >> "${MYLOGFILE}" 2>&1
pvwatt=$(<"${RAMDISKDIR}/pvwatt")
pvkwh=$(<"${RAMDISKDIR}/pvkwh")
bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.solar_log.device" "inverter" "${bezug_solarlog_ip}" "0">> "${MYLOGFILE}" 2>&1
ret=$?
openwbDebugLog ${DMOD} 2 "RET: ${ret}"

openwbDebugLog ${DMOD} 2 "pvwatt: $pvwatt"
openwbDebugLog ${DMOD} 2 "pvkwh: $pvkwh"
echo $pvwatt
cat "$RAMDISKDIR/pvwatt"
33 changes: 0 additions & 33 deletions modules/wr_solarlog/solarlog.py

This file was deleted.

8 changes: 2 additions & 6 deletions modules/wr_youless120/main.sh
Expand Up @@ -16,13 +16,9 @@ else
MYLOGFILE="${RAMDISKDIR}/wr_youless120.log"
fi

openwbDebugLog ${DMOD} 2 "PV IP: ${wryoulessip}"
openwbDebugLog ${DMOD} 2 "PV Alternative: ${wryoulessalt}"

bash "$OPENWBBASEDIR/packages/legacy_run.sh" "wr_youless120.youless" "${wryoulessip}" "${wryoulessalt}" >>$MYLOGFILE 2>&1
bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.youless.device" "inverter" "${wryoulessip}" "${wryoulessalt}" "1">>$MYLOGFILE 2>&1
ret=$?

openwbDebugLog ${DMOD} 2 "RET: ${ret}"

pvwatt=$(</var/www/html/openWB/ramdisk/pvwatt)
echo $pvwatt
cat "${RAMDISKDIR}/pvwatt"
55 changes: 0 additions & 55 deletions modules/wr_youless120/youless.py

This file was deleted.

14 changes: 6 additions & 8 deletions packages/modules/devices/good_we/device.py
Expand Up @@ -15,7 +15,6 @@

log = logging.getLogger(__name__)


good_we_component_classes = Union[bat.GoodWeBat, counter.GoodWeCounter, inverter.GoodWeInverter]


Expand All @@ -33,20 +32,19 @@ def __init__(self, device_config: Union[Dict, GoodWe]) -> None:
ip_address = self.device_config.configuration.ip_address
self.client = modbus.ModbusTcpClient_(ip_address, 502)
except Exception:
log.exception("Fehler im Modul "+self.device_config.name)
log.exception("Fehler im Modul " + self.device_config.name)

def add_component(self, component_config: Union[Dict,
GoodWeBatSetup,
GoodWeCounterSetup,
GoodWeInverterSetup]) -> None:
def add_component(self,
component_config: Union[Dict, GoodWeBatSetup, GoodWeCounterSetup, GoodWeInverterSetup]) -> None:
if isinstance(component_config, Dict):
component_type = component_config["type"]
else:
component_type = component_config.type
component_config = dataclass_from_dict(COMPONENT_TYPE_TO_MODULE[
component_type].component_descriptor.configuration_factory, component_config)
component_type].component_descriptor.configuration_factory,
component_config)
if component_type in self.COMPONENT_TYPE_TO_CLASS:
self.components["component"+str(component_config.id)] = (self.COMPONENT_TYPE_TO_CLASS[component_type](
self.components["component" + str(component_config.id)] = (self.COMPONENT_TYPE_TO_CLASS[component_type](
self.device_config.configuration.modbus_id, component_config, self.client))
else:
raise Exception(
Expand Down
Empty file.
48 changes: 48 additions & 0 deletions packages/modules/devices/solar_log/config.py
@@ -0,0 +1,48 @@
from typing import Optional

from modules.common.component_setup import ComponentSetup


class SolarLogConfiguration:
def __init__(self, ip_address: Optional[str] = None):
self.ip_address = ip_address


class SolarLog:
def __init__(self,
name: str = "Solar-Log",
type: str = "solar_log",
id: int = 0,
configuration: SolarLogConfiguration = None) -> None:
self.name = name
self.type = type
self.id = id
self.configuration = configuration or SolarLogConfiguration()


class SolarLogCounterConfiguration:
def __init__(self):
pass


class SolarLogCounterSetup(ComponentSetup[SolarLogCounterConfiguration]):
def __init__(self,
name: str = "Solar-Log Zähler",
type: str = "counter",
id: int = 0,
configuration: SolarLogCounterConfiguration = None) -> None:
super().__init__(name, type, id, configuration or SolarLogCounterConfiguration())


class SolarLogInverterConfiguration:
def __init__(self):
pass


class SolarLogInverterSetup(ComponentSetup[SolarLogInverterConfiguration]):
def __init__(self,
name: str = "Solar-Log Wechselrichter",
type: str = "inverter",
id: int = 0,
configuration: SolarLogInverterConfiguration = None) -> None:
super().__init__(name, type, id, configuration or SolarLogInverterConfiguration())
42 changes: 42 additions & 0 deletions packages/modules/devices/solar_log/counter.py
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
import logging
from typing import Dict, Union


from dataclass_utils import dataclass_from_dict
from modules.common.component_state import CounterState
from modules.common.component_type import ComponentDescriptor
from modules.common.fault_state import ComponentInfo
from modules.common.simcount import SimCounter
from modules.common.store import get_counter_value_store
from modules.devices.solar_log.config import SolarLogCounterSetup

log = logging.getLogger(__name__)


class SolarLogCounter:
def __init__(self,
device_id: int,
component_config: Union[Dict, SolarLogCounterSetup]) -> None:
self.component_config = dataclass_from_dict(SolarLogCounterSetup, component_config)
self.sim_counter = SimCounter(device_id, self.component_config.id, prefix="bezug")
self.store = get_counter_value_store(self.component_config.id)
self.component_info = ComponentInfo.from_component_config(self.component_config)

def update(self, response: Dict) -> None:
self.store_values(self.get_power(response))

def store_values(self, power) -> None:
imported, exported = self.sim_counter.sim_count(power)

self.store.set(CounterState(
imported=imported,
exported=exported,
power=power
))

def get_power(self, response: Dict) -> CounterState:
return int(float(response["801"]["170"]["110"]))


component_descriptor = ComponentDescriptor(configuration_factory=SolarLogCounterSetup)

0 comments on commit 635e059

Please sign in to comment.