[kostalinverter] Fix for the Kostal inverter binding to work with different firmware releases regarded to PIKO 10-20 V. 221004 (#13490)
* [kostalinverter] Fix for the Kostal inverter binding to work with different firmware releases regarded to PIKO 10-20 Version 221004 This is the next version regarded to Closed PR #13464 * [kostalinverter] Changes done 20221019 Regarded to Thread..... * Proper handling of InterruptedException Also removbe a useless call to return Signed-off-by: Örjan Backsell <orjan.backsell@gmail.com> Co-authored-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
a5823d8df0
commit
f184e4e88f
|
@ -291,7 +291,7 @@ String SolarStatus "Solar status [%s]" <energy> { channel="kostalinverter:kostal
|
||||||
demo.items:
|
demo.items:
|
||||||
|
|
||||||
```
|
```
|
||||||
Number:Power GridOutputPower "PV Output Power" <energy> { channel="kostalinverter:piko1020:mypiko1020:gridOutputPower" }
|
Number:Power GridOutputPower "Grid Output Power" <energy> { channel="kostalinverter:piko1020:mypiko1020:gridOutputPower" }
|
||||||
Number:Energy YieldDaySecondGen "PV Output Power Day" <energy> { channel="kostalinverter:piko1020:mypiko1020:yieldDaySecondGen" }
|
Number:Energy YieldDaySecondGen "PV Output Power Day" <energy> { channel="kostalinverter:piko1020:mypiko1020:yieldDaySecondGen" }
|
||||||
Number:Energy YieldTotalSecondGen "PV Output Power Total" <energy> { channel="kostalinverter:piko1020:mypiko1020:yieldTotalSecondgen" }
|
Number:Energy YieldTotalSecondGen "PV Output Power Total" <energy> { channel="kostalinverter:piko1020:mypiko1020:yieldTotalSecondgen" }
|
||||||
Number:Dimensionless OperatingStatus "Operating Status" <energy> { channel="kostalinverter:piko1020:mypiko1020:operatingStatus" }
|
Number:Dimensionless OperatingStatus "Operating Status" <energy> { channel="kostalinverter:piko1020:mypiko1020:operatingStatus" }
|
||||||
|
|
|
@ -187,7 +187,6 @@ public class SecondGenerationHandler extends BaseThingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
try {
|
|
||||||
// Build posts for dxsEntries part
|
// Build posts for dxsEntries part
|
||||||
String dxsEntriesCall = inverterConfig.url + "/api/dxs.json?dxsEntries=" + channelConfigs.get(0).dxsEntries;
|
String dxsEntriesCall = inverterConfig.url + "/api/dxs.json?dxsEntries=" + channelConfigs.get(0).dxsEntries;
|
||||||
for (int i = 1; i < channelConfigs.size(); i++) {
|
for (int i = 1; i < channelConfigs.size(); i++) {
|
||||||
|
@ -229,8 +228,8 @@ public class SecondGenerationHandler extends BaseThingHandler {
|
||||||
dxsEntriesCallExtExt += ("&dxsEntries=" + channelConfigsExtExt.get(i).dxsEntries);
|
dxsEntriesCallExtExt += ("&dxsEntries=" + channelConfigsExtExt.get(i).dxsEntries);
|
||||||
}
|
}
|
||||||
String jsonDxsEntriesResponseExtExt = callURL(dxsEntriesCallExtExt, httpClient);
|
String jsonDxsEntriesResponseExtExt = callURL(dxsEntriesCallExtExt, httpClient);
|
||||||
SecondGenerationDxsEntriesContainerDTO dxsEntriesContainerExtExt = gson
|
SecondGenerationDxsEntriesContainerDTO dxsEntriesContainerExtExt = gson.fromJson(jsonDxsEntriesResponseExtExt,
|
||||||
.fromJson(jsonDxsEntriesResponseExtExt, SecondGenerationDxsEntriesContainerDTO.class);
|
SecondGenerationDxsEntriesContainerDTO.class);
|
||||||
String[] channelPostsExtExt = new String[3];
|
String[] channelPostsExtExt = new String[3];
|
||||||
int channelPostsCounterExtExt = 0;
|
int channelPostsCounterExtExt = 0;
|
||||||
for (SecondGenerationDxsEntries dxsentriesExtExt : dxsEntriesContainerExtExt.dxsEntries) {
|
for (SecondGenerationDxsEntries dxsentriesExtExt : dxsEntriesContainerExtExt.dxsEntries) {
|
||||||
|
@ -325,10 +324,6 @@ public class SecondGenerationHandler extends BaseThingHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final RuntimeException e) {
|
|
||||||
logger.debug("Updating inverter status failed: ", e);
|
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help method of handleCommand to with SecondGenerationConfigurationHandler.executeConfigurationChanges method send
|
// Help method of handleCommand to with SecondGenerationConfigurationHandler.executeConfigurationChanges method send
|
||||||
|
@ -338,7 +333,10 @@ public class SecondGenerationHandler extends BaseThingHandler {
|
||||||
try {
|
try {
|
||||||
SecondGenerationConfigurationHandler.executeConfigurationChanges(httpClientHandleCommand, url, username,
|
SecondGenerationConfigurationHandler.executeConfigurationChanges(httpClientHandleCommand, url, username,
|
||||||
password, dxsEntriesConf, valueConfiguration);
|
password, dxsEntriesConf, valueConfiguration);
|
||||||
} catch (InterruptedException | ExecutionException | TimeoutException | NoSuchAlgorithmException e) {
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
logger.debug("Connection to inverter interrupted during configuration");
|
||||||
|
} catch (ExecutionException | TimeoutException | NoSuchAlgorithmException e) {
|
||||||
logger.debug("Connection to inverter disturbed during configuration");
|
logger.debug("Connection to inverter disturbed during configuration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,8 +345,11 @@ public class SecondGenerationHandler extends BaseThingHandler {
|
||||||
private final String callURL(String dxsEntriesCall, HttpClient httpClient) {
|
private final String callURL(String dxsEntriesCall, HttpClient httpClient) {
|
||||||
String jsonDxsResponse = "";
|
String jsonDxsResponse = "";
|
||||||
try {
|
try {
|
||||||
jsonDxsResponse = httpClient.GET(dxsEntriesCall).getContentAsString();
|
jsonDxsResponse = httpClient.GET(dxsEntriesCall).getContentAsString().replace("null", "0.000000");
|
||||||
} catch (InterruptedException | ExecutionException | TimeoutException e2) {
|
} catch (InterruptedException e2) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
logger.debug("Connection to inverter interrupted during scrape");
|
||||||
|
} catch (ExecutionException | TimeoutException e2) {
|
||||||
logger.debug("Connection to inverter disturbed during scrape");
|
logger.debug("Connection to inverter disturbed during scrape");
|
||||||
}
|
}
|
||||||
return jsonDxsResponse;
|
return jsonDxsResponse;
|
||||||
|
|
Loading…
Reference in New Issue