Skip to content

Commit

Permalink
Add conversion for differential white report (#1657)
Browse files Browse the repository at this point in the history
Add conversion for differential white report

Signed-off-by: Tom van Wietmarschen <aaargh@gmail.com>
  • Loading branch information
Aaargh20318 committed Aug 31, 2021
1 parent 3d37d38 commit 5349cce
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ public State handleEvent(ZWaveThingChannel channel, ZWaveCommandClassValueEvent
state = new PercentType(colorMap.get(ZWaveColorType.COLD_WHITE));
} else if ("WARM_WHITE".equals(channel.getArguments().get("colorMode"))) {
state = new PercentType(colorMap.get(ZWaveColorType.WARM_WHITE));
} else if ("DIFF_WHITE".equals(channel.getArguments().get("colorMode"))) {
int warm = colorMap.get(ZWaveColorType.WARM_WHITE) != null ? colorMap.get(ZWaveColorType.WARM_WHITE) : 0;
int cold = colorMap.get(ZWaveColorType.COLD_WHITE) != null ? colorMap.get(ZWaveColorType.COLD_WHITE) : 0;
if(warm + cold > 0) {
float ratio = ((float) warm) / (float) (warm + cold);
int percentage = (int) ((ratio * 100.0f) + 0.5f);
state = new PercentType(percentage);
} else {
state = new PercentType(0);
}
} else {
state = new PercentType(0);
}
Expand Down

0 comments on commit 5349cce

Please sign in to comment.