[daikin] Fix NPE when setting zones on startup (#12165)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
parent
36ab0cdc87
commit
de6de1a22d
@ -72,7 +72,6 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ControlInfo controlInfo = webTargets.getControlInfo();
|
ControlInfo controlInfo = webTargets.getControlInfo();
|
||||||
updateStatus(ThingStatus.ONLINE);
|
|
||||||
updateState(DaikinBindingConstants.CHANNEL_AC_POWER, controlInfo.power ? OnOffType.ON : OnOffType.OFF);
|
updateState(DaikinBindingConstants.CHANNEL_AC_POWER, controlInfo.power ? OnOffType.ON : OnOffType.OFF);
|
||||||
updateTemperatureChannel(DaikinBindingConstants.CHANNEL_AC_TEMP, controlInfo.temp);
|
updateTemperatureChannel(DaikinBindingConstants.CHANNEL_AC_TEMP, controlInfo.temp);
|
||||||
|
|
||||||
@ -153,6 +152,7 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
|
|||||||
// Suppress any error if energy info is not supported.
|
// Suppress any error if energy info is not supported.
|
||||||
logger.debug("getEnergyInfoDayAndWeek() error: {}", e.getMessage());
|
logger.debug("getEnergyInfoDayAndWeek() error: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -77,7 +77,6 @@ public class DaikinAirbaseUnitHandler extends DaikinBaseHandler {
|
|||||||
@Override
|
@Override
|
||||||
protected void pollStatus() throws IOException {
|
protected void pollStatus() throws IOException {
|
||||||
AirbaseControlInfo controlInfo = webTargets.getAirbaseControlInfo();
|
AirbaseControlInfo controlInfo = webTargets.getAirbaseControlInfo();
|
||||||
updateStatus(ThingStatus.ONLINE);
|
|
||||||
|
|
||||||
if (airbaseModelInfo == null || !"OK".equals(airbaseModelInfo.ret)) {
|
if (airbaseModelInfo == null || !"OK".equals(airbaseModelInfo.ret)) {
|
||||||
airbaseModelInfo = webTargets.getAirbaseModelInfo();
|
airbaseModelInfo = webTargets.getAirbaseModelInfo();
|
||||||
@ -115,6 +114,7 @@ public class DaikinAirbaseUnitHandler extends DaikinBaseHandler {
|
|||||||
.forEach(idx -> updateState(DaikinBindingConstants.CHANNEL_AIRBASE_AC_ZONE + idx,
|
.forEach(idx -> updateState(DaikinBindingConstants.CHANNEL_AIRBASE_AC_ZONE + idx,
|
||||||
OnOffType.from(zoneInfo.zone[idx])));
|
OnOffType.from(zoneInfo.zone[idx])));
|
||||||
}
|
}
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -178,18 +178,25 @@ public class DaikinAirbaseUnitHandler extends DaikinBaseHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void changeZone(int zone, boolean command) throws DaikinCommunicationException {
|
protected void changeZone(int zone, boolean command) throws DaikinCommunicationException {
|
||||||
if (zone <= 0 || zone > airbaseModelInfo.zonespresent) {
|
AirbaseZoneInfo zoneInfo = webTargets.getAirbaseZoneInfo();
|
||||||
|
long commonZones = 0;
|
||||||
|
long maxZones = zoneInfo.zone.length;
|
||||||
|
|
||||||
|
if (airbaseModelInfo != null) {
|
||||||
|
maxZones = Math.min(maxZones - 1, airbaseModelInfo.zonespresent);
|
||||||
|
commonZones = airbaseModelInfo.commonzone;
|
||||||
|
}
|
||||||
|
if (zone <= 0 || zone > maxZones) {
|
||||||
logger.warn("The given zone number ({}) is outside the number of zones supported by the controller ({})",
|
logger.warn("The given zone number ({}) is outside the number of zones supported by the controller ({})",
|
||||||
zone, airbaseModelInfo.zonespresent);
|
zone, maxZones);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AirbaseZoneInfo zoneInfo = webTargets.getAirbaseZoneInfo();
|
long openZones = IntStream.range(0, zoneInfo.zone.length).filter(idx -> zoneInfo.zone[idx]).count()
|
||||||
long count = IntStream.range(0, zoneInfo.zone.length).filter(idx -> zoneInfo.zone[idx]).count()
|
+ commonZones;
|
||||||
+ airbaseModelInfo.commonzone;
|
logger.debug("Number of open zones: \"{}\"", openZones);
|
||||||
logger.debug("Number of open zones: \"{}\"", count);
|
|
||||||
|
|
||||||
if (count >= 1) {
|
if (openZones >= 1) {
|
||||||
zoneInfo.zone[zone] = command;
|
zoneInfo.zone[zone] = command;
|
||||||
webTargets.setAirbaseZoneInfo(zoneInfo);
|
webTargets.setAirbaseZoneInfo(zoneInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user