...
This commit is contained in:
parent
c34a9fd911
commit
af2f10bde8
@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.client.api.ContentResponse;
|
import org.eclipse.jetty.client.api.ContentResponse;
|
||||||
import org.eclipse.jetty.client.api.Request;
|
import org.eclipse.jetty.client.api.Request;
|
||||||
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.http.HttpVersion;
|
import org.eclipse.jetty.http.HttpVersion;
|
||||||
import org.openhab.binding.mediolaaiogateway.internal.config.MediolaAioBridgeConfig;
|
import org.openhab.binding.mediolaaiogateway.internal.config.MediolaAioBridgeConfig;
|
||||||
import org.openhab.binding.mediolaaiogateway.internal.discovery.MediolaAioDeviceDiscoveryService;
|
import org.openhab.binding.mediolaaiogateway.internal.discovery.MediolaAioDeviceDiscoveryService;
|
||||||
@ -100,24 +101,30 @@ public class MediolaAioGatewayBridgeHandler extends BaseBridgeHandler {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
try {
|
try {
|
||||||
response = request.send();
|
response = request.send();
|
||||||
|
|
||||||
|
if(!HttpStatus.isSuccess(response.getStatus())) {
|
||||||
|
throw new MediolaAioCommunicationError("invalid http result code");
|
||||||
|
}
|
||||||
content = response.getContent();
|
content = response.getContent();
|
||||||
} catch (InterruptedException | TimeoutException | ExecutionException e) {
|
} catch (InterruptedException | TimeoutException | ExecutionException e) {
|
||||||
throw new MediolaAioCommunicationError("communication error", e);
|
throw new MediolaAioCommunicationError("communication error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject convertedObject = new Gson().fromJson(new String(content), JsonObject.class);
|
try {
|
||||||
if (!convertedObject.has("XC_SUC")) {
|
JsonObject convertedObject = new Gson().fromJson(new String(content), JsonObject.class);
|
||||||
if (convertedObject.has("XC_ERR")) {
|
if (!convertedObject.has("XC_SUC")) {
|
||||||
throw new MediolaAioCommandError(convertedObject.get("XC_ERR").getAsString());
|
if (convertedObject.has("XC_ERR")) {
|
||||||
} else {
|
throw new MediolaAioCommandError(convertedObject.get("XC_ERR").getAsString());
|
||||||
throw new MediolaAioCommandError("unknown reason.");
|
} else {
|
||||||
|
throw new MediolaAioCommandError("unknown reason.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return convertedObject.get("XC_SUC");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new MediolaAioCommandError("json decode of response failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertedObject.get("XC_SUC");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.smartmeter.internal.sml;
|
package org.openhab.binding.smartmeter.internal.sml;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.temporal.WeekFields;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@ -32,6 +35,7 @@ import org.openmuc.jsml.structures.SmlStatus;
|
|||||||
import org.openmuc.jsml.structures.responses.SmlGetListRes;
|
import org.openmuc.jsml.structures.responses.SmlGetListRes;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import java.time.temporal.ChronoUnit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a SML capable device.
|
* Represents a SML capable device.
|
||||||
@ -44,6 +48,8 @@ public final class SmlMeterReader extends MeterDevice<SmlFile> {
|
|||||||
|
|
||||||
protected final Logger logger = LoggerFactory.getLogger(SmlMeterReader.class);
|
protected final Logger logger = LoggerFactory.getLogger(SmlMeterReader.class);
|
||||||
|
|
||||||
|
Locale.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static factory method to create a SmlDevice object with a serial connector member.
|
* Static factory method to create a SmlDevice object with a serial connector member.
|
||||||
*
|
*
|
||||||
@ -59,7 +65,13 @@ public final class SmlMeterReader extends MeterDevice<SmlFile> {
|
|||||||
SmlMeterReader device = new SmlMeterReader(serialPortManagerSupplier, deviceId, serialPort, initMessage,
|
SmlMeterReader device = new SmlMeterReader(serialPortManagerSupplier, deviceId, serialPort, initMessage,
|
||||||
baudrate, baudrateChangeDelay, ProtocolMode.SML);
|
baudrate, baudrateChangeDelay, ProtocolMode.SML);
|
||||||
|
|
||||||
|
ZonedDateTime t = ZonedDateTime.now();
|
||||||
|
WeekFields
|
||||||
|
t.with()
|
||||||
return device;
|
return device;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,6 +134,8 @@ public final class SmlMeterReader extends MeterDevice<SmlFile> {
|
|||||||
smlValue = valueExtractor.getSmlValue();
|
smlValue = valueExtractor.getSmlValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZonedDateTime t = ZonedDateTime.now().toLocalDateTime().toLocalDate().atStartOfDay()
|
||||||
|
|
||||||
SmlStatus status = entry.getStatus();
|
SmlStatus status = entry.getStatus();
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
String statusValue = readStatus(status, obis);
|
String statusValue = readStatus(status, obis);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user