Skip to content

Commit 8ac8cc0

Browse files
authored
mqtt inverter imported (#2841)
* mqtt inverter imported * flake8
1 parent e6a7846 commit 8ac8cc0

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

packages/helpermodules/setdata.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ def process_pv_topic(self, msg: mqtt.MQTTMessage):
610610
"/get/yearly_exported" in msg.topic or
611611
"/get/energy" in msg.topic):
612612
self._validate_value(msg, float, [(0, float("inf"))])
613-
elif "/get/exported" in msg.topic:
613+
elif ("/get/exported" in msg.topic or
614+
"/get/imported" in msg.topic):
614615
self._validate_value(msg, float, [(0, float("inf"))])
615616
elif "/get/power" in msg.topic:
616617
self._validate_value(msg, float)

packages/modules/devices/generic/mqtt/bat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def parse_received_topics(value: str):
3434
currents = parse_received_topics("currents")
3535
power = received_topics[f"{topic_prefix}power"]
3636
soc = received_topics[f"{topic_prefix}soc"]
37-
if (received_topics.get(f"{topic_prefix}imported") and
38-
received_topics.get(f"{topic_prefix}exported")):
37+
if (received_topics.get(f"{topic_prefix}imported") is not None and
38+
received_topics.get(f"{topic_prefix}exported") is not None):
3939
imported = received_topics[f"{topic_prefix}imported"]
4040
exported = received_topics[f"{topic_prefix}exported"]
4141
else:

packages/modules/devices/generic/mqtt/inverter.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,23 @@ def parse_received_topics(value: str):
3131
# [] für erforderliche Topics, .get() für optionale Topics
3232
topic_prefix = f"openWB/mqtt/pv/{self.component_config.id}/get/"
3333
power = received_topics[f"{topic_prefix}power"]
34-
if received_topics.get(f"openWB/mqtt/pv/{self.component_config.id}/get/exported"):
34+
35+
if (received_topics.get(f"{topic_prefix}exported") is None or
36+
received_topics.get(f"{topic_prefix}imported") is None):
37+
imported, exported = self.sim_counter.sim_count(power)
38+
if received_topics.get(f"{topic_prefix}exported"):
3539
exported = received_topics[f"{topic_prefix}exported"]
36-
else:
37-
exported = self.sim_counter.sim_count(power)[1]
40+
if received_topics.get(f"{topic_prefix}imported"):
41+
imported = received_topics[f"{topic_prefix}imported"]
42+
3843
currents = parse_received_topics("currents")
3944
dc_power = parse_received_topics("dc_power")
4045

4146
inverter_state = InverterState(
4247
currents=currents,
4348
power=power,
4449
exported=exported,
50+
imported=imported,
4551
dc_power=dc_power
4652
)
4753
self.store.set(inverter_state)

0 commit comments

Comments
 (0)