Some warnings were still present at startup regarding Room initialization. (#14784)
Switched to late initialization. Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
parent
9f221e550b
commit
a0f06ec051
@ -45,10 +45,12 @@ public class RoomCapability extends Capability {
|
|||||||
super(handler);
|
super(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected Optional<EnergyCapability> getEnergyCapability() {
|
||||||
public void initialize() {
|
if (energyCapability.isEmpty()) {
|
||||||
energyCapability = handler.getHomeCapability(EnergyCapability.class);
|
energyCapability = handler.getHomeCapability(EnergyCapability.class);
|
||||||
}
|
}
|
||||||
|
return energyCapability;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(String channelName, Command command) {
|
public void handleCommand(String channelName, Command command) {
|
||||||
@ -58,7 +60,7 @@ public class RoomCapability extends Capability {
|
|||||||
if (targetMode == SetpointMode.MANUAL) {
|
if (targetMode == SetpointMode.MANUAL) {
|
||||||
logger.info("Switch to 'Manual' mode is done by setting a setpoint temp, command ignored");
|
logger.info("Switch to 'Manual' mode is done by setting a setpoint temp, command ignored");
|
||||||
} else {
|
} else {
|
||||||
energyCapability.ifPresent(cap -> cap.setRoomThermMode(handler.getId(), targetMode));
|
getEnergyCapability().ifPresent(cap -> cap.setRoomThermMode(handler.getId(), targetMode));
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
logger.info("Command '{}' is not a valid setpoint mode for channel '{}'", command, channelName);
|
logger.info("Command '{}' is not a valid setpoint mode for channel '{}'", command, channelName);
|
||||||
@ -66,7 +68,7 @@ public class RoomCapability extends Capability {
|
|||||||
} else if (CHANNEL_VALUE.equals(channelName)) {
|
} else if (CHANNEL_VALUE.equals(channelName)) {
|
||||||
QuantityType<?> quantity = commandToQuantity(command, MeasureClass.INSIDE_TEMPERATURE);
|
QuantityType<?> quantity = commandToQuantity(command, MeasureClass.INSIDE_TEMPERATURE);
|
||||||
if (quantity != null) {
|
if (quantity != null) {
|
||||||
energyCapability.ifPresent(cap -> cap.setRoomThermTemp(handler.getId(), quantity.doubleValue()));
|
getEnergyCapability().ifPresent(cap -> cap.setRoomThermTemp(handler.getId(), quantity.doubleValue()));
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Incorrect command '{}' on channel '{}'", command, channelName);
|
logger.warn("Incorrect command '{}' on channel '{}'", command, channelName);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user