mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[nikohomecontrol] Fix energy meter. (#10546)
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
This commit is contained in:
parent
0e4810e651
commit
061ecda321
@ -577,7 +577,9 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
|
||||
deviceProperties.stream().map(p -> p.electricalPower).filter(Objects::nonNull).findFirst()
|
||||
.ifPresent(electricalPower -> {
|
||||
try {
|
||||
energyMeter.setPower(Integer.parseInt(electricalPower));
|
||||
// Sometimes API sends a fractional part, although API should only send whole units in W,
|
||||
// therefore drop fractional part
|
||||
energyMeter.setPower((int) Double.parseDouble(electricalPower));
|
||||
logger.trace("setting energy meter {} power to {}", energyMeter.getId(), electricalPower);
|
||||
} catch (NumberFormatException e) {
|
||||
energyMeter.setPower(null);
|
||||
|
Loading…
Reference in New Issue
Block a user