[Tankerkoenig] Fixes #8876 (#8940)

* [Tankerkoenig] Update StationHandler

Incooperated check for 'null' iot to prevent NullPointerExceptions.
* [Tankerkoenig] Updated WebserviceHandler

Fixed false parsing of OpeningTimes.
* Applied a spotless check   Signed-off-by: Jürgen Baginski <opus42@gmx.de>

Signed-off-by: Jürgen Baginski <opus42@gmx.de>
This commit is contained in:
Jürgen Baginski 2020-11-03 07:48:05 +01:00 committed by GitHub
parent a3d33fa60b
commit f8fd06e4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 22 deletions

View File

@ -128,25 +128,43 @@ public class StationHandler extends BaseThingHandler {
*/ */
public void updateData(LittleStation station) { public void updateData(LittleStation station) {
logger.debug("Update Tankerkoenig data '{}'", getThing().getUID()); logger.debug("Update Tankerkoenig data '{}'", getThing().getUID());
if (station.isOpen() == true) {
logger.debug("Checked Station is open! '{}'", getThing().getUID());
updateState(CHANNEL_STATION_OPEN, OpenClosedType.OPEN);
if (station.getDiesel() != null) {
if (IS_NUMERIC_PATTERN.matcher(station.getDiesel()).matches()) { if (IS_NUMERIC_PATTERN.matcher(station.getDiesel()).matches()) {
DecimalType diesel = new DecimalType(station.getDiesel()); DecimalType diesel = new DecimalType(station.getDiesel());
updateState(CHANNEL_DIESEL, diesel); updateState(CHANNEL_DIESEL, diesel);
} else { } else {
updateState(CHANNEL_DIESEL, UnDefType.UNDEF); updateState(CHANNEL_DIESEL, UnDefType.UNDEF);
} }
} else {
updateState(CHANNEL_DIESEL, UnDefType.UNDEF);
}
if (station.getE10() != null) {
if (IS_NUMERIC_PATTERN.matcher(station.getE10()).matches()) { if (IS_NUMERIC_PATTERN.matcher(station.getE10()).matches()) {
DecimalType e10 = new DecimalType(station.getE10()); DecimalType e10 = new DecimalType(station.getE10());
updateState(CHANNEL_E10, e10); updateState(CHANNEL_E10, e10);
} else { } else {
updateState(CHANNEL_E10, UnDefType.UNDEF); updateState(CHANNEL_E10, UnDefType.UNDEF);
} }
} else {
updateState(CHANNEL_E10, UnDefType.UNDEF);
}
if (station.getE10() != null) {
if (IS_NUMERIC_PATTERN.matcher(station.getE5()).matches()) { if (IS_NUMERIC_PATTERN.matcher(station.getE5()).matches()) {
DecimalType e5 = new DecimalType(station.getE5()); DecimalType e5 = new DecimalType(station.getE5());
updateState(CHANNEL_E5, e5); updateState(CHANNEL_E5, e5);
} else { } else {
updateState(CHANNEL_E5, UnDefType.UNDEF); updateState(CHANNEL_E5, UnDefType.UNDEF);
} }
updateState(CHANNEL_STATION_OPEN, (station.isOpen() ? OpenClosedType.OPEN : OpenClosedType.CLOSED)); } else {
updateState(CHANNEL_E5, UnDefType.UNDEF);
}
} else {
logger.debug("Checked Station is closed!");
updateState(CHANNEL_STATION_OPEN, OpenClosedType.CLOSED);
}
updateStatus(ThingStatus.ONLINE); updateStatus(ThingStatus.ONLINE);
} }

View File

@ -293,12 +293,12 @@ public class WebserviceHandler extends BaseBridgeHandler {
} }
break; break;
} }
}
if (foundIt) { if (foundIt) {
start = open; start = open;
ende = close; ende = close;
break; break;
} }
}
i = i + 1; i = i + 1;
} while (i < o.length); } while (i < o.length);
} }