From dfc374b13a169443eda13d8577b23354d689fbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Wed, 26 Feb 2025 10:35:40 +0100 Subject: [PATCH] changed "openDTU/pv/patrix/json" to "openDTU/pv/patrix/json2" --- .../data/message/handler/OpenDTUHandler.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/ph87/data/message/handler/OpenDTUHandler.java b/src/main/java/de/ph87/data/message/handler/OpenDTUHandler.java index f8eb379..da5b291 100644 --- a/src/main/java/de/ph87/data/message/handler/OpenDTUHandler.java +++ b/src/main/java/de/ph87/data/message/handler/OpenDTUHandler.java @@ -18,37 +18,55 @@ import java.time.*; @RequiredArgsConstructor public class OpenDTUHandler implements IMessageHandler { - private static final String METER_NUMBER = "114190515175"; - private final ObjectMapper objectMapper; private final ApplicationEventPublisher applicationEventPublisher; @Override public void handle(@NonNull final Message message) throws Exception { - if (!"openDTU/pv/patrix/json".equals(message.topic)) { + if (!"openDTU/pv/patrix/json2".equals(message.topic)) { return; } final Inbound inbound = objectMapper.readValue(message.payload, Inbound.class); - applicationEventPublisher.publishEvent(new VaryingInbound("power/produced", inbound.date, inbound.power.as(Unit.POWER_W))); - applicationEventPublisher.publishEvent(new MeterInbound("energy/produced", METER_NUMBER, inbound.date, inbound.energy)); + applicationEventPublisher.publishEvent(new VaryingInbound("power/produced", inbound.date, inbound.powerTotal.as(Unit.POWER_W))); + applicationEventPublisher.publishEvent(new MeterInbound("energy/produced", inbound.inverter, inbound.date, inbound.energyTotal.as(Unit.ENERGY_KWH))); + applicationEventPublisher.publishEvent(new VaryingInbound("power/produced/string0", inbound.date, inbound.powerString0.as(Unit.POWER_W))); + applicationEventPublisher.publishEvent(new MeterInbound("energy/produced/string0", inbound.inverter, inbound.date, inbound.energyString0.as(Unit.ENERGY_KWH))); + applicationEventPublisher.publishEvent(new VaryingInbound("power/produced/string1", inbound.date, inbound.powerString1.as(Unit.POWER_W))); + applicationEventPublisher.publishEvent(new MeterInbound("energy/produced/string1", inbound.inverter, inbound.date, inbound.energyString1.as(Unit.ENERGY_KWH))); } @Getter @ToString public static class Inbound { + @NonNull + public final String inverter; + @NonNull public final ZonedDateTime date; - public final Value energy; + public final Value energyTotal; - public final Value power; + public final Value powerTotal; - public Inbound(final long timestamp, final double energyProducedKWh, final double powerW) { + public final Value energyString0; + + public final Value powerString0; + + public final Value energyString1; + + public final Value powerString1; + + public Inbound(final long timestamp, @NonNull final String inverter, final double totalKWh, final double totalW, final double string0KWh, final double string0W, final double string1KWh, final double string1W) { + this.inverter = inverter; this.date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.systemDefault()); - this.energy = new Value(energyProducedKWh, Unit.ENERGY_KWH); - this.power = new Value(powerW, Unit.POWER_W); + this.energyTotal = new Value(totalKWh, Unit.ENERGY_KWH); + this.powerTotal = new Value(totalW, Unit.POWER_W); + this.energyString0 = new Value(string0KWh, Unit.ENERGY_KWH); + this.powerString0 = new Value(string0W, Unit.POWER_W); + this.energyString1 = new Value(string1KWh, Unit.ENERGY_KWH); + this.powerString1 = new Value(string1W, Unit.POWER_W); } }