...
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.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.openhab.binding.mediolaaiogateway.internal.config.MediolaAioBridgeConfig;
|
||||
import org.openhab.binding.mediolaaiogateway.internal.discovery.MediolaAioDeviceDiscoveryService;
|
||||
@ -100,24 +101,30 @@ public class MediolaAioGatewayBridgeHandler extends BaseBridgeHandler {
|
||||
synchronized (this) {
|
||||
try {
|
||||
response = request.send();
|
||||
|
||||
if(!HttpStatus.isSuccess(response.getStatus())) {
|
||||
throw new MediolaAioCommunicationError("invalid http result code");
|
||||
}
|
||||
content = response.getContent();
|
||||
} catch (InterruptedException | TimeoutException | ExecutionException e) {
|
||||
throw new MediolaAioCommunicationError("communication error", e);
|
||||
}
|
||||
}
|
||||
|
||||
JsonObject convertedObject = new Gson().fromJson(new String(content), JsonObject.class);
|
||||
if (!convertedObject.has("XC_SUC")) {
|
||||
if (convertedObject.has("XC_ERR")) {
|
||||
throw new MediolaAioCommandError(convertedObject.get("XC_ERR").getAsString());
|
||||
} else {
|
||||
throw new MediolaAioCommandError("unknown reason.");
|
||||
try {
|
||||
JsonObject convertedObject = new Gson().fromJson(new String(content), JsonObject.class);
|
||||
if (!convertedObject.has("XC_SUC")) {
|
||||
if (convertedObject.has("XC_ERR")) {
|
||||
throw new MediolaAioCommandError(convertedObject.get("XC_ERR").getAsString());
|
||||
} 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;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.time.temporal.ChronoUnit
|
||||
|
||||
/**
|
||||
* Represents a SML capable device.
|
||||
@ -44,6 +48,8 @@ public final class SmlMeterReader extends MeterDevice<SmlFile> {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(SmlMeterReader.class);
|
||||
|
||||
Locale.
|
||||
|
||||
/**
|
||||
* 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,
|
||||
baudrate, baudrateChangeDelay, ProtocolMode.SML);
|
||||
|
||||
ZonedDateTime t = ZonedDateTime.now();
|
||||
WeekFields
|
||||
t.with()
|
||||
return device;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,6 +134,8 @@ public final class SmlMeterReader extends MeterDevice<SmlFile> {
|
||||
smlValue = valueExtractor.getSmlValue();
|
||||
}
|
||||
|
||||
ZonedDateTime t = ZonedDateTime.now().toLocalDateTime().toLocalDate().atStartOfDay()
|
||||
|
||||
SmlStatus status = entry.getStatus();
|
||||
if (status != null) {
|
||||
String statusValue = readStatus(status, obis);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user