changed "openDTU/pv/patrix/json" to "openDTU/pv/patrix/json2"
This commit is contained in:
parent
a6e1e189b3
commit
dfc374b13a
@ -18,37 +18,55 @@ import java.time.*;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class OpenDTUHandler implements IMessageHandler {
|
public class OpenDTUHandler implements IMessageHandler {
|
||||||
|
|
||||||
private static final String METER_NUMBER = "114190515175";
|
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
private final ApplicationEventPublisher applicationEventPublisher;
|
private final ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(@NonNull final Message message) throws Exception {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
final Inbound inbound = objectMapper.readValue(message.payload, Inbound.class);
|
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 VaryingInbound("power/produced", inbound.date, inbound.powerTotal.as(Unit.POWER_W)));
|
||||||
applicationEventPublisher.publishEvent(new MeterInbound("energy/produced", METER_NUMBER, inbound.date, inbound.energy));
|
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
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
public static class Inbound {
|
public static class Inbound {
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public final String inverter;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public final ZonedDateTime date;
|
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.date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.systemDefault());
|
||||||
this.energy = new Value(energyProducedKWh, Unit.ENERGY_KWH);
|
this.energyTotal = new Value(totalKWh, Unit.ENERGY_KWH);
|
||||||
this.power = new Value(powerW, Unit.POWER_W);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user