Skip to content

Commit

Permalink
[hue] Allow handling of QuantityType for color temperature channel (o…
Browse files Browse the repository at this point in the history
…penhab#14024)

* Allow handling of QuantityType for color temperature channel
* Fixed log messages and reduce log level.

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
cweitkamp authored and andrasU committed Jan 6, 2024
1 parent e2c320b commit ccd84d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.hue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ The devices support some of the following channels:
| color | Color | This channel supports full color control with hue, saturation and brightness values. | 0200, 0210, group |
| brightness | Dimmer | This channel supports adjusting the brightness value. Note that this is not available, if the color channel is supported. | 0100, 0110, 0220, group |
| color_temperature | Dimmer | This channel supports adjusting the color temperature from cold (0%) to warm (100%). | 0210, 0220, group |
| color_temperature_abs | Number | This channel supports adjusting the color temperature in Kelvin. **Advanced** | 0210, 0220, group |
| color_temperature_abs | Number:Temperature | This channel supports adjusting the color temperature in Kelvin. **Advanced** | 0210, 0220, group |
| alert | String | This channel supports displaying alerts by flashing the bulb either once or multiple times. Valid values are: NONE, SELECT and LSELECT. | 0000, 0100, 0200, 0210, 0220, group |
| effect | Switch | This channel supports color looping. | 0200, 0210, 0220 |
| dimmer_switch | Number | This channel shows which button was last pressed on the dimmer switch. | 0820 |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand All @@ -16,12 +16,12 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hue.internal.api.dto.clip1.ColorTemperature;
import org.openhab.binding.hue.internal.api.dto.clip1.State;
import org.openhab.binding.hue.internal.api.dto.clip1.State.AlertMode;
import org.openhab.binding.hue.internal.api.dto.clip1.State.ColorMode;
import org.openhab.binding.hue.internal.api.dto.clip1.State.Effect;
import org.openhab.binding.hue.internal.api.dto.clip1.StateUpdate;
import org.openhab.binding.hue.internal.dto.ColorTemperature;
import org.openhab.binding.hue.internal.dto.State;
import org.openhab.binding.hue.internal.dto.State.AlertMode;
import org.openhab.binding.hue.internal.dto.State.ColorMode;
import org.openhab.binding.hue.internal.dto.State.Effect;
import org.openhab.binding.hue.internal.dto.StateUpdate;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.IncreaseDecreaseType;
Expand All @@ -30,7 +30,6 @@
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.Units;
import org.openhab.core.util.ColorUtil;

/**
* The {@link LightStateConverter} is responsible for mapping to/from jue types.
Expand Down Expand Up @@ -277,7 +276,7 @@ private static HSBType fromHSBtoHSBType(State lightState) {

private static HSBType fromXYtoHSBType(State lightState) {
float[] xy = lightState.getXY();
HSBType hsb = ColorUtil.xyToHsb(new double[] { xy[0], xy[1] });
HSBType hsb = HSBType.fromXY(xy[0], xy[1]);

int brightnessInPercent = (int) Math.ceil(lightState.getBrightness() / BRIGHTNESS_FACTOR);
brightnessInPercent = restrictToBounds(brightnessInPercent);
Expand All @@ -294,7 +293,7 @@ private static HSBType fromXYtoHSBType(State lightState) {
* <li>{@value #ALERT_MODE_NONE}.
* <li>{@value #ALERT_MODE_SELECT}.
* <li>{@value #ALERT_MODE_LONG_SELECT}.
* </ul>
* <ul>
* @return light state containing the {@link AlertMode} or <b><code>null </code></b> if the provided
* {@link StringType} represents unsupported mode.
*/
Expand Down

0 comments on commit ccd84d3

Please sign in to comment.