diff --git a/bundles/org.openhab.binding.lifx/README.md b/bundles/org.openhab.binding.lifx/README.md
index ab5d4f0c7c67f..4c249e1ea4f33 100644
--- a/bundles/org.openhab.binding.lifx/README.md
+++ b/bundles/org.openhab.binding.lifx/README.md
@@ -43,14 +43,14 @@ The following table lists the thing types of the supported LIFX devices:
The thing type determines the capability of a device and with that the possible ways of interacting with it.
The following matrix lists the capabilities (channels) for each type:
-| Thing Type | On/Off | Brightness | Color | Color Zone | Color Temperature | Color Temperature Zone | HEV Cycle | Infrared | Tile Effects |
-|---------------|:------:|:----------:|:-----:|:----------:|:-----------------:|:----------------------:|:---------:|:--------:|:------------:|
-| colorlight | X | | X | | X | | | | |
-| colorhevlight | X | | X | | X | | X | | |
-| colorirlight | X | | X | | X | | | X | |
-| colormzlight | X | | X | X | X | X | | | |
-| tilelight | X | X | X | | X | | | | X |
-| whitelight | X | X | | | X | | | | |
+| Thing Type | On/Off | Brightness | Color | Color Zone | (Abs) Color Temperature | (Abs) Color Temperature Zone | HEV Cycle | Infrared | Tile Effects |
+|---------------|:------:|:----------:|:-----:|:----------:|:-----------------------:|:----------------------------:|:---------:|:--------:|:------------:|
+| colorlight | X | | X | | X | | | | |
+| colorhevlight | X | | X | | X | | X | | |
+| colorirlight | X | | X | | X | | | X | |
+| colormzlight | X | | X | X | X | X | | | |
+| tilelight | X | X | X | | X | | | | X |
+| whitelight | X | X | | | X | | | | |
## Discovery
@@ -85,17 +85,19 @@ Thing lifx:colorirlight:porch [ host="10.120.130.4", fadetime=0 ]
All devices support some of the following channels:
-| Channel Type ID | Item Type | Description | Thing Types |
-|-----------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
-| brightness | Dimmer | This channel supports adjusting the brightness value. | whitelight |
-| color | Color | This channel supports full color control with hue, saturation and brightness values. | colorlight, colorhevlight, colorirlight, colormzlight, tilelight |
-| colorzone | Color | This channel supports full zone color control with hue, saturation and brightness values. | colormzlight |
-| effect | String | This channel represents a type of light effect (e.g. for tile light: off, morph, flame) | tilelight |
-| hevcycle | Switch | This channel supports starting and stopping the HEV clean cycle. | colorhevlight |
-| infrared | Dimmer | This channel supports adjusting the infrared value. *Note:* IR capable lights only activate their infrared LEDs when the brightness drops below a certain level. | colorirlight |
-| signalstrength | Number | This channel represents signal strength with values 0, 1, 2, 3 or 4; 0 being worst strength and 4 being best strength. | colorlight, colorhevlight, colorirlight, colormzlight, tilelight, whitelight |
-| temperature | Dimmer | This channel supports adjusting the color temperature from cold (0%) to warm (100%). | colorlight, colorhevlight, colorirlight, colormzlight, tilelight, whitelight |
-| temperaturezone | Dimmer | This channel supports adjusting the zone color temperature from cold (0%) to warm (100%). | colormzlight |
+| Channel Type ID | Item Type | Description | Thing Types |
+|--------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
+| abstemperature | Number | This channel supports adjusting the color temperature in Kelvin. | colorlight, colorhevlight, colorirlight, colormzlight, tilelight, whitelight |
+| abstemperaturezone | Number | This channel supports adjusting the zone color temperature in Kelvin. | colormzlight |
+| brightness | Dimmer | This channel supports adjusting the brightness value. | whitelight |
+| color | Color | This channel supports full color control with hue, saturation and brightness values. | colorlight, colorhevlight, colorirlight, colormzlight, tilelight |
+| colorzone | Color | This channel supports full zone color control with hue, saturation and brightness values. | colormzlight |
+| effect | String | This channel represents a type of light effect (e.g. for tile light: off, morph, flame) | tilelight |
+| hevcycle | Switch | This channel supports starting and stopping the HEV clean cycle. | colorhevlight |
+| infrared | Dimmer | This channel supports adjusting the infrared value. *Note:* IR capable lights only activate their infrared LEDs when the brightness drops below a certain level. | colorirlight |
+| signalstrength | Number | This channel represents signal strength with values 0, 1, 2, 3 or 4; 0 being worst strength and 4 being best strength. | colorlight, colorhevlight, colorirlight, colormzlight, tilelight, whitelight |
+| temperature | Dimmer | This channel supports adjusting the color temperature from cold (0%) to warm (100%). | colorlight, colorhevlight, colorirlight, colormzlight, tilelight, whitelight |
+| temperaturezone | Dimmer | This channel supports adjusting the zone color temperature from cold (0%) to warm (100%). | colormzlight |
The *color* and *brightness* channels have a "Power On Brightness" configuration option that is used to determine the brightness when a light is switched on.
When it is left empty, the brightness of a light remains unchanged when a light is switched on or off.
@@ -107,9 +109,9 @@ If both "Power on brightness" and "Power On Color" configuration options are def
The *temperature* channels have a "Power On Temperature" configuration option that is used to determine the color temperature when a light is switched on. When it is left empty, the color temperature of a light remains unchanged when a light is switched on or off.
-MultiZone lights (*colormzlight*) have several channels (e.g. *colorzone0*, *temperaturezone0*, etc.) that allow for controlling specific zones of the light.
-Changing the *color* and *temperature* channels will update the states of all zones.
-The *color* and *temperature* channels of MultiZone lights always return the same state as *colorzone0*, *temperaturezone0*.
+MultiZone lights (*colormzlight*) have several channels (e.g. *colorzone0*, *temperaturezone0*, *abstemperaturezone0*, etc.) that allow for controlling specific zones of the light.
+Changing the *color*, *temperature* and *abstemperature* channels will update the states of all zones.
+The *color*, *temperature* and *abstemperature* channels of MultiZone lights always return the same state as *colorzone0*, *temperaturezone0*, *abstemperaturezone0*.
The *hevcycle* channels have an optional "HEV Cycle Duration" configuration option that can be used to override the cycle duration configured in the light.
@@ -174,36 +176,44 @@ Thing lifx:whitelight:kitchen [ deviceId="D073D5D4D4D4", fadetime=150 ]
// Living
Color Living_Color { channel="lifx:colorlight:living:color" }
Dimmer Living_Temperature { channel="lifx:colorlight:living:temperature" }
+Number Living_Abs_Temperature { channel="lifx:colorlight:living:abstemperature" }
// Living2 (alternative approach)
Color Living2_Color { channel="lifx:colorlight:living2:color" }
Switch Living2_Switch { channel="lifx:colorlight:living2:color" }
Dimmer Living2_Dimmer { channel="lifx:colorlight:living2:color" }
Dimmer Living2_Temperature { channel="lifx:colorlight:living2:temperature" }
+Number Living2_Abs_Temperature { channel="lifx:colorlight:living2:abstemperature" }
// Desk
Color Desk_Color { channel="lifx:colorhevlight:desk:color" }
Dimmer Desk_Temperature { channel="lifx:colorhevlight:desk:temperature" }
+Number Desk_Abs_Temperature { channel="lifx:colorhevlight:desk:abstemperature" }
Switch Desk_HEV_Cycle { channel="lifx:colorhevlight:desk:hevcycle" }
// Porch
Color Porch_Color { channel="lifx:colorirlight:porch:color" }
Dimmer Porch_Infrared { channel="lifx:colorirlight:porch:infrared" }
Dimmer Porch_Temperature { channel="lifx:colorirlight:porch:temperature" }
+Number Porch_Abs_Temperature { channel="lifx:colorirlight:porch:abstemperature" }
Number Porch_Signal_Strength { channel="lifx:colorirlight:porch:signalstrength" }
// Ceiling
Color Ceiling_Color { channel="lifx:colormzlight:ceiling:color" }
Dimmer Ceiling_Temperature { channel="lifx:colormzlight:ceiling:temperature" }
+Number Ceiling_Abs_Temperature { channel="lifx:colormzlight:ceiling:abstemperature" }
Color Ceiling_Color_Zone_0 { channel="lifx:colormzlight:ceiling:colorzone0" }
Dimmer Ceiling_Temperature_Zone_0 { channel="lifx:colormzlight:ceiling:temperaturezone0" }
+Number Ceiling_Abs_Temperature_Zone_0 { channel="lifx:colormzlight:ceiling:abstemperaturezone0" }
Color Ceiling_Color_Zone_15 { channel="lifx:colormzlight:ceiling:colorzone15" }
Dimmer Ceiling_Temperature_Zone_15 { channel="lifx:colormzlight:ceiling:temperaturezone15" }
+Number Ceiling_Abs_Temperature_Zone_15 { channel="lifx:colormzlight:ceiling:abstemperaturezone15" }
// Kitchen
Switch Kitchen_Toggle { channel="lifx:whitelight:kichen:brightness" }
Dimmer Kitchen_Brightness { channel="lifx:whitelight:kitchen:brightness" }
Dimmer Kitchen_Temperature { channel="lifx:whitelight:kitchen:temperature" }
+Number Kitchen_Abs_Temperature { channel="lifx:whitelight:kitchen:abstemperature" }
```
### demo.sitemap:
@@ -216,6 +226,7 @@ sitemap demo label="Main Menu"
Slider item=Living_Color
Colorpicker item=Living_Color
Slider item=Living_Temperature
+ Slider item=Living_Abs_Temperature
}
Frame label="Living2" {
@@ -223,6 +234,7 @@ sitemap demo label="Main Menu"
Slider item=Living2_Dimmer
Colorpicker item=Living2_Color
Slider item=Living2_Temperature
+ Slider item=Living2_Abs_Temperature
}
Frame label="Desk" {
@@ -230,6 +242,7 @@ sitemap demo label="Main Menu"
Slider item=Desk_Color
Colorpicker item=Desk_Color
Slider item=Desk_Temperature
+ Slider item=Desk_Abs_Temperature
Switch item=Desk_HEV_Cycle
}
@@ -238,6 +251,7 @@ sitemap demo label="Main Menu"
Slider item=Porch_Color
Colorpicker item=Porch_Color
Slider item=Porch_Temperature
+ Slider item=Porch_Abs_Temperature
Slider item=Porch_Infrared
Text item=Porch_Signal_Strength
}
@@ -247,16 +261,20 @@ sitemap demo label="Main Menu"
Slider item=Ceiling_Color
Colorpicker item=Ceiling_Color
Slider item=Ceiling_Temperature
+ Slider item=Ceiling_Abs_Temperature
Colorpicker item=Ceiling_Color_Zone_0
Slider item=Ceiling_Temperature_Zone_0
+ Slider item=Ceiling_Abs_Temperature_Zone_0
Colorpicker item=Ceiling_Color_Zone_15
Slider item=Ceiling_Temperature_Zone_15
+ Slider item=Ceiling_Abs_Temperature_Zone_15
}
Frame label="Kitchen" {
Switch item=Kitchen_Toggle
Slider item=Kitchen_Brightness
Slider item=Kitchen_Temperature
+ Slider item=Kitchen_Abs_Temperature
}
}
```
diff --git a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxBindingConstants.java b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxBindingConstants.java
index 1274479961de9..20fda7cc0f4e3 100644
--- a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxBindingConstants.java
+++ b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxBindingConstants.java
@@ -49,6 +49,8 @@ public class LifxBindingConstants {
public static final PercentType DEFAULT_BRIGHTNESS = PercentType.HUNDRED;
// List of all Channel IDs
+ public static final String CHANNEL_ABS_TEMPERATURE = "abstemperature";
+ public static final String CHANNEL_ABS_TEMPERATURE_ZONE = "abstemperaturezone";
public static final String CHANNEL_BRIGHTNESS = "brightness";
public static final String CHANNEL_COLOR = "color";
public static final String CHANNEL_COLOR_ZONE = "colorzone";
@@ -62,12 +64,10 @@ public class LifxBindingConstants {
// List of all Channel Type UIDs
public static final ChannelTypeUID CHANNEL_TYPE_BRIGHTNESS = new ChannelTypeUID(BINDING_ID, CHANNEL_BRIGHTNESS);
public static final ChannelTypeUID CHANNEL_TYPE_COLOR = new ChannelTypeUID(BINDING_ID, CHANNEL_COLOR);
- public static final ChannelTypeUID CHANNEL_TYPE_COLOR_ZONE = new ChannelTypeUID(BINDING_ID, CHANNEL_COLOR_ZONE);
public static final ChannelTypeUID CHANNEL_TYPE_EFFECT = new ChannelTypeUID(BINDING_ID, CHANNEL_EFFECT);
+ public static final ChannelTypeUID CHANNEL_TYPE_HEV_CYCLE = new ChannelTypeUID(BINDING_ID, CHANNEL_HEV_CYCLE);
public static final ChannelTypeUID CHANNEL_TYPE_INFRARED = new ChannelTypeUID(BINDING_ID, CHANNEL_INFRARED);
public static final ChannelTypeUID CHANNEL_TYPE_TEMPERATURE = new ChannelTypeUID(BINDING_ID, CHANNEL_TEMPERATURE);
- public static final ChannelTypeUID CHANNEL_TYPE_TEMPERATURE_ZONE = new ChannelTypeUID(BINDING_ID,
- CHANNEL_TEMPERATURE_ZONE);
// List of options for effect channel
public static final String CHANNEL_TYPE_EFFECT_OPTION_OFF = "off";
diff --git a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactory.java b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactory.java
index b507648a71f7d..592aefd54120c 100644
--- a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactory.java
+++ b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactory.java
@@ -24,6 +24,8 @@
@NonNullByDefault
public interface LifxChannelFactory {
+ Channel createAbsTemperatureZoneChannel(ThingUID thingUID, int index);
+
Channel createColorZoneChannel(ThingUID thingUID, int index);
Channel createTemperatureZoneChannel(ThingUID thingUID, int index);
diff --git a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactoryImpl.java b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactoryImpl.java
index 333c610a7486f..dd1cb92a0049d 100644
--- a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactoryImpl.java
+++ b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/LifxChannelFactoryImpl.java
@@ -14,22 +14,14 @@
import static org.openhab.binding.lifx.internal.LifxBindingConstants.*;
-import java.util.Locale;
-
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.core.i18n.LocaleProvider;
-import org.openhab.core.i18n.TranslationProvider;
+import org.openhab.core.library.CoreItemFactory;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.DefaultSystemChannelTypeProvider;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.builder.ChannelBuilder;
-import org.osgi.framework.Bundle;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
/**
* The {@link LifxChannelFactoryImpl} creates dynamic LIFX channels.
@@ -40,71 +32,22 @@
@Component(service = LifxChannelFactory.class)
public class LifxChannelFactoryImpl implements LifxChannelFactory {
- private static final String COLOR_ZONE_LABEL_KEY = "channel-type.lifx.colorzone.label";
- private static final String COLOR_ZONE_DESCRIPTION_KEY = "channel-type.lifx.colorzone.description";
-
- private static final String TEMPERATURE_ZONE_LABEL_KEY = "channel-type.lifx.temperaturezone.label";
- private static final String TEMPERATURE_ZONE_DESCRIPTION_KEY = "channel-type.lifx.temperaturezone.description";
-
- private @NonNullByDefault({}) Bundle bundle;
- private @NonNullByDefault({}) TranslationProvider i18nProvider;
- private @NonNullByDefault({}) LocaleProvider localeProvider;
+ @Override
+ public Channel createAbsTemperatureZoneChannel(ThingUID thingUID, int index) {
+ return ChannelBuilder
+ .create(new ChannelUID(thingUID, CHANNEL_ABS_TEMPERATURE_ZONE + index), CoreItemFactory.NUMBER)
+ .withType(DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_TYPE_UID_COLOR_TEMPERATURE_ABS).build();
+ }
@Override
public Channel createColorZoneChannel(ThingUID thingUID, int index) {
- String label = getText(COLOR_ZONE_LABEL_KEY, index);
- String description = getText(COLOR_ZONE_DESCRIPTION_KEY, index);
- return ChannelBuilder.create(new ChannelUID(thingUID, CHANNEL_COLOR_ZONE + index), "Color")
- .withType(CHANNEL_TYPE_COLOR_ZONE).withLabel(label).withDescription(description).build();
+ return ChannelBuilder.create(new ChannelUID(thingUID, CHANNEL_COLOR_ZONE + index), CoreItemFactory.COLOR)
+ .withType(DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_TYPE_UID_COLOR).build();
}
@Override
public Channel createTemperatureZoneChannel(ThingUID thingUID, int index) {
- String label = getText(TEMPERATURE_ZONE_LABEL_KEY, index);
- String description = getText(TEMPERATURE_ZONE_DESCRIPTION_KEY, index);
- return ChannelBuilder.create(new ChannelUID(thingUID, CHANNEL_TEMPERATURE_ZONE + index), "Dimmer")
- .withType(CHANNEL_TYPE_TEMPERATURE_ZONE).withLabel(label).withDescription(description).build();
- }
-
- private @Nullable String getDefaultText(String key) {
- return i18nProvider.getText(bundle, key, key, Locale.ENGLISH);
- }
-
- private String getText(String key, Object... arguments) {
- Locale locale = localeProvider != null ? localeProvider.getLocale() : Locale.ENGLISH;
- if (i18nProvider == null) {
- return key;
- }
-
- String text = i18nProvider.getText(bundle, key, getDefaultText(key), locale, arguments);
- return text != null ? text : key;
- }
-
- @Activate
- protected void activate(ComponentContext componentContext) {
- this.bundle = componentContext.getBundleContext().getBundle();
- }
-
- @Deactivate
- protected void deactivate(ComponentContext componentContext) {
- this.bundle = null;
- }
-
- @Reference
- protected void setTranslationProvider(TranslationProvider i18nProvider) {
- this.i18nProvider = i18nProvider;
- }
-
- protected void unsetTranslationProvider(TranslationProvider i18nProvider) {
- this.i18nProvider = null;
- }
-
- @Reference
- protected void setLocaleProvider(LocaleProvider localeProvider) {
- this.localeProvider = localeProvider;
- }
-
- protected void unsetLocaleProvider(LocaleProvider localeProvider) {
- this.localeProvider = null;
+ return ChannelBuilder.create(new ChannelUID(thingUID, CHANNEL_TEMPERATURE_ZONE + index), CoreItemFactory.DIMMER)
+ .withType(DefaultSystemChannelTypeProvider.SYSTEM_CHANNEL_TYPE_UID_COLOR_TEMPERATURE).build();
}
}
diff --git a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java
index 9be4f24b4a84f..b169c3a65ff75 100644
--- a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java
+++ b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler/LifxLightHandler.java
@@ -182,6 +182,7 @@ private void updateColorChannels(@Nullable PowerState powerState, HSBK[] colors)
updateStateIfChanged(CHANNEL_BRIGHTNESS, hsb.getBrightness());
updateStateIfChanged(CHANNEL_TEMPERATURE,
kelvinToPercentType(updateColor.getKelvin(), features.getTemperatureRange()));
+ updateStateIfChanged(CHANNEL_ABS_TEMPERATURE, new DecimalType(updateColor.getKelvin()));
updateZoneChannels(powerState, colors);
}
@@ -240,6 +241,7 @@ private void updateZoneChannels(@Nullable PowerState powerState, HSBK[] colors)
updateStateIfChanged(CHANNEL_COLOR_ZONE + i, updateColor.getHSB());
updateStateIfChanged(CHANNEL_TEMPERATURE_ZONE + i,
kelvinToPercentType(updateColor.getKelvin(), features.getTemperatureRange()));
+ updateStateIfChanged(CHANNEL_ABS_TEMPERATURE_ZONE + i, new DecimalType(updateColor.getKelvin()));
}
}
}
@@ -473,7 +475,8 @@ private void addRemoveZoneChannels(int zones) {
// retain non-zone channels
for (Channel channel : getThing().getChannels()) {
String channelId = channel.getUID().getId();
- if (!channelId.startsWith(CHANNEL_COLOR_ZONE) && !channelId.startsWith(CHANNEL_TEMPERATURE_ZONE)) {
+ if (!channelId.startsWith(CHANNEL_ABS_TEMPERATURE_ZONE) && !channelId.startsWith(CHANNEL_COLOR_ZONE)
+ && !channelId.startsWith(CHANNEL_TEMPERATURE_ZONE)) {
newChannels.add(channel);
}
}
@@ -482,6 +485,7 @@ private void addRemoveZoneChannels(int zones) {
for (int i = 0; i < zones; i++) {
newChannels.add(channelFactory.createColorZoneChannel(getThing().getUID(), i));
newChannels.add(channelFactory.createTemperatureZoneChannel(getThing().getUID(), i));
+ newChannels.add(channelFactory.createAbsTemperatureZoneChannel(getThing().getUID(), i));
}
updateThing(editThing().withChannels(newChannels).build());
@@ -552,6 +556,13 @@ public void handleCommand(ChannelUID channelUID, Command command) {
private @Nullable Runnable getChannelCommandRunnable(ChannelUID channelUID, Command command) {
switch (channelUID.getId()) {
+ case CHANNEL_ABS_TEMPERATURE:
+ case CHANNEL_TEMPERATURE:
+ if (command instanceof DecimalType) {
+ return () -> handleTemperatureCommand((DecimalType) command);
+ } else if (command instanceof IncreaseDecreaseType) {
+ return () -> handleIncreaseDecreaseTemperatureCommand((IncreaseDecreaseType) command);
+ }
case CHANNEL_BRIGHTNESS:
if (command instanceof PercentType) {
return () -> handlePercentCommand((PercentType) command);
@@ -559,8 +570,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
return () -> handleOnOffCommand((OnOffType) command);
} else if (command instanceof IncreaseDecreaseType) {
return () -> handleIncreaseDecreaseCommand((IncreaseDecreaseType) command);
- } else {
- return null;
}
case CHANNEL_COLOR:
if (command instanceof HSBType) {
@@ -571,40 +580,29 @@ public void handleCommand(ChannelUID channelUID, Command command) {
return () -> handleOnOffCommand((OnOffType) command);
} else if (command instanceof IncreaseDecreaseType) {
return () -> handleIncreaseDecreaseCommand((IncreaseDecreaseType) command);
- } else {
- return null;
}
case CHANNEL_EFFECT:
if (command instanceof StringType && features.hasFeature(TILE_EFFECT)) {
return () -> handleTileEffectCommand((StringType) command);
- } else {
- return null;
}
case CHANNEL_HEV_CYCLE:
if (command instanceof OnOffType) {
return () -> handleHevCycleCommand((OnOffType) command);
- } else {
- return null;
}
case CHANNEL_INFRARED:
if (command instanceof PercentType) {
return () -> handleInfraredCommand((PercentType) command);
} else if (command instanceof IncreaseDecreaseType) {
return () -> handleIncreaseDecreaseInfraredCommand((IncreaseDecreaseType) command);
- } else {
- return null;
- }
- case CHANNEL_TEMPERATURE:
- if (command instanceof PercentType) {
- return () -> handleTemperatureCommand((PercentType) command);
- } else if (command instanceof IncreaseDecreaseType) {
- return () -> handleIncreaseDecreaseTemperatureCommand((IncreaseDecreaseType) command);
- } else {
- return null;
}
default:
try {
- if (channelUID.getId().startsWith(CHANNEL_COLOR_ZONE)) {
+ if (channelUID.getId().startsWith(CHANNEL_ABS_TEMPERATURE_ZONE)) {
+ int zoneIndex = Integer.parseInt(channelUID.getId().replace(CHANNEL_ABS_TEMPERATURE_ZONE, ""));
+ if (command instanceof DecimalType) {
+ return () -> handleTemperatureCommand((DecimalType) command, zoneIndex);
+ }
+ } else if (channelUID.getId().startsWith(CHANNEL_COLOR_ZONE)) {
int zoneIndex = Integer.parseInt(channelUID.getId().replace(CHANNEL_COLOR_ZONE, ""));
if (command instanceof HSBType) {
return () -> handleHSBCommand((HSBType) command, zoneIndex);
@@ -612,8 +610,6 @@ public void handleCommand(ChannelUID channelUID, Command command) {
return () -> handlePercentCommand((PercentType) command, zoneIndex);
} else if (command instanceof IncreaseDecreaseType) {
return () -> handleIncreaseDecreaseCommand((IncreaseDecreaseType) command, zoneIndex);
- } else {
- return null;
}
} else if (channelUID.getId().startsWith(CHANNEL_TEMPERATURE_ZONE)) {
int zoneIndex = Integer.parseInt(channelUID.getId().replace(CHANNEL_TEMPERATURE_ZONE, ""));
@@ -622,18 +618,14 @@ public void handleCommand(ChannelUID channelUID, Command command) {
} else if (command instanceof IncreaseDecreaseType) {
return () -> handleIncreaseDecreaseTemperatureCommand((IncreaseDecreaseType) command,
zoneIndex);
- } else {
- return null;
}
- } else {
- return null;
}
} catch (NumberFormatException e) {
logger.error("Failed to parse zone index for a command of a light ({}) : {}", logId,
e.getMessage());
- return null;
}
}
+ return null;
}
private LifxLightState getLightStateForCommand() {
@@ -650,6 +642,10 @@ private boolean isStateChangePending() {
private void handleRefreshCommand(ChannelUID channelUID) {
channelStates.remove(channelUID.getId());
switch (channelUID.getId()) {
+ case CHANNEL_ABS_TEMPERATURE:
+ case CHANNEL_TEMPERATURE:
+ sendPacket(new GetRequest());
+ break;
case CHANNEL_COLOR:
case CHANNEL_BRIGHTNESS:
sendPacket(new GetLightPowerRequest());
@@ -669,25 +665,22 @@ private void handleRefreshCommand(ChannelUID channelUID) {
case CHANNEL_SIGNAL_STRENGTH:
sendPacket(new GetWifiInfoRequest());
break;
- case CHANNEL_TEMPERATURE:
- sendPacket(new GetRequest());
- break;
default:
break;
}
}
- private void handleTemperatureCommand(PercentType temperature) {
+ private void handleTemperatureCommand(DecimalType temperature) {
HSBK newColor = getLightStateForCommand().getColor();
newColor.setSaturation(PercentType.ZERO);
- newColor.setKelvin(percentTypeToKelvin(temperature, features.getTemperatureRange()));
+ newColor.setKelvin(commandToKelvin(temperature, features.getTemperatureRange()));
getLightStateForCommand().setColor(newColor);
}
- private void handleTemperatureCommand(PercentType temperature, int zoneIndex) {
+ private void handleTemperatureCommand(DecimalType temperature, int zoneIndex) {
HSBK newColor = getLightStateForCommand().getColor(zoneIndex);
newColor.setSaturation(PercentType.ZERO);
- newColor.setKelvin(percentTypeToKelvin(temperature, features.getTemperatureRange()));
+ newColor.setKelvin(commandToKelvin(temperature, features.getTemperatureRange()));
getLightStateForCommand().setColor(newColor, zoneIndex);
}
diff --git a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/util/LifxMessageUtil.java b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/util/LifxMessageUtil.java
index 03c8135e2d7f3..bb5b457103a68 100644
--- a/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/util/LifxMessageUtil.java
+++ b/bundles/org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/util/LifxMessageUtil.java
@@ -102,6 +102,16 @@ public static PercentType kelvinToPercentType(int kelvin, TemperatureRange tempe
return new PercentType(value);
}
+ public static int commandToKelvin(DecimalType temperature, TemperatureRange temperatureRange) {
+ return temperature instanceof PercentType ? percentTypeToKelvin((PercentType) temperature, temperatureRange)
+ : decimalTypeToKelvin(temperature, temperatureRange);
+ }
+
+ public static int decimalTypeToKelvin(DecimalType temperature, TemperatureRange temperatureRange) {
+ return Math.round(Math.min(Math.max(temperature.intValue(), temperatureRange.getMinimum()),
+ temperatureRange.getMaximum()));
+ }
+
public static int percentTypeToKelvin(PercentType temperature, TemperatureRange temperatureRange) {
return Math.round(
temperatureRange.getMaximum() - (temperature.floatValue() * (temperatureRange.getRange() / 100)));
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx.properties b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx.properties
index c4f511d6ac937..98c629c5088d4 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx.properties
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx.properties
@@ -20,24 +20,20 @@ thing-type.config.lifx.light.fadetime.description = The time to fade to the new
# channel types
channel-type.lifx.brightness.label = Brightness
-channel-type.lifx.brightness.description = Sets the brightness of the light
+channel-type.lifx.brightness.description = Controls the brightness and switches the light on and off
channel-type.lifx.color.label = Color
-channel-type.lifx.color.description = Selects the color of the light
-channel-type.lifx.colorzone.label = Color Zone {0}
-channel-type.lifx.colorzone.description = Selects the zone {0} color of the light
+channel-type.lifx.color.description = Controls the color of the light
channel-type.lifx.effect.label = Effect
-channel-type.lifx.effect.description = Sets the effect of the light
+channel-type.lifx.effect.description = Controls the effect of the light
channel-type.lifx.effect.state.option.off = Off
channel-type.lifx.effect.state.option.morph = Morph
channel-type.lifx.effect.state.option.flame = Flame
channel-type.lifx.hevcycle.label = HEV Cycle
channel-type.lifx.hevcycle.description = Controls the HEV clean cycle of the light
channel-type.lifx.infrared.label = Infrared
-channel-type.lifx.infrared.description = Sets the infrared of the light
-channel-type.lifx.temperature.label = Temperature
-channel-type.lifx.temperature.description = Sets the temperature of the light
-channel-type.lifx.temperaturezone.label = Temperature Zone {0}
-channel-type.lifx.temperaturezone.description = Sets the zone {0} temperature of the light
+channel-type.lifx.infrared.description = Controls the infrared level of the light
+channel-type.lifx.temperature.label = Color Temperature
+channel-type.lifx.temperature.description = Controls the color temperature of the light from 0 (cold) to 100 (warm)
# channel type configuration
channel-type.config.lifx.brightness.powerOnBrightness.label = Power On Brightness
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx_nl.properties b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx_nl.properties
index c21aab2872b98..fa6e0753b369f 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx_nl.properties
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/i18n/lifx_nl.properties
@@ -20,24 +20,20 @@ thing-type.config.lifx.light.fadetime.description = De tijdsduur van het vervage
# channel types
channel-type.lifx.brightness.label = Helderheid
-channel-type.lifx.brightness.description = Bepaalt de helderheid van de lamp
+channel-type.lifx.brightness.description = Bepaalt de helderheid en schakelt het licht aan en uit
channel-type.lifx.color.label = Kleur
-channel-type.lifx.color.description = Bepaalt de kleur van de lamp
-channel-type.lifx.colorzone.label = Kleur Zone {0}
-channel-type.lifx.colorzone.description = Bepaalt de kleur van lampzone {0}
+channel-type.lifx.color.description = Bepaalt de kleur van het licht
channel-type.lifx.effect.label = Effect
channel-type.lifx.effect.description = Bepaalt het lichteffect
channel-type.lifx.effect.state.option.off = Uit
channel-type.lifx.effect.state.option.morph = Morph
channel-type.lifx.effect.state.option.flame = Vlam
channel-type.lifx.hevcycle.label = HEV Cyclus
-channel-type.lifx.hevcycle.description = Bedient de HEV schoonmaakcylcus van de lamp
+channel-type.lifx.hevcycle.description = Bedient de HEV schoonmaakcyclus van de lamp
channel-type.lifx.infrared.label = Infrarood
channel-type.lifx.infrared.description = Bepaalt het infraroodniveau van de lamp
-channel-type.lifx.temperature.label = Temperatuur
-channel-type.lifx.temperature.description = Bepaalt de kleurtemperatuur van de lamp
-channel-type.lifx.temperaturezone.label = Temperatuur Zone {0}
-channel-type.lifx.temperaturezone.description = Bepaalt de kleurtemperatuur van lampzone {0}
+channel-type.lifx.temperature.label = Kleurtemperatuur
+channel-type.lifx.temperature.description = Bepaalt de kleurtemperatuur van het licht van 0 (koud) tot 100 (warm)
# channel type configuration
channel-type.config.lifx.brightness.powerOnBrightness.label = Inschakelhelderheid
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/channel.xml b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/channel.xml
index 4e5260d4b4cea..ec5f56ebb6792 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/channel.xml
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/channel.xml
@@ -7,10 +7,11 @@
Dimmer
- Sets the brightness of the light
+ Controls the brightness and switches the light on and offDimmableLight
- Lighting
+ Control
+ Light
@@ -18,56 +19,56 @@
Color
- Selects the color of the light
+ Controls the color of the lightColorLight
- Lighting
+ Control
+ Light
-
- Color
-
- Selects the zone color of the light
- ColorLight
-
- Lighting
-
-
-
SwitchControls the HEV clean cycle of the light
+
+ Control
+ Light
+ Dimmer
- Sets the infrared of the light
+ Controls the infrared level of the light
+
+ Control
+ Light
+ Dimmer
-
- Sets the temperature of the light
+
+ Controls the color temperature of the light from 0 (cold) to 100 (warm)ColorLight
+
+ Control
+ ColorTemperature
+
-
- Dimmer
-
- Sets the zone temperature of the light
- ColorLight
-
-
String
- Sets the effect of the light
+ Controls the effect of the light
+
+ Control
+ Light
+
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorhevlight.xml b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorhevlight.xml
index 9506454f30b05..be96a80bb371d 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorhevlight.xml
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorhevlight.xml
@@ -9,6 +9,7 @@
+
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorirlight.xml b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorirlight.xml
index 9738e16e99573..eb8905484e8ce 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorirlight.xml
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorirlight.xml
@@ -9,6 +9,7 @@
+
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorlight.xml b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorlight.xml
index c4e54beabdd10..d858efc9fa870 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorlight.xml
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colorlight.xml
@@ -9,6 +9,7 @@
+ macAddress
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colormzlight.xml b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colormzlight.xml
index f7276a66b96e7..1c81f2965d0a3 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colormzlight.xml
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/colormzlight.xml
@@ -9,6 +9,7 @@
+ macAddress
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/tilelight.xml b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/tilelight.xml
index 5b60250cde7f7..af032cd335024 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/tilelight.xml
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/tilelight.xml
@@ -9,6 +9,7 @@
+
diff --git a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/whitelight.xml b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/whitelight.xml
index dc6f45d746af2..9a7299e95afaf 100644
--- a/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/whitelight.xml
+++ b/bundles/org.openhab.binding.lifx/src/main/resources/OH-INF/thing/whitelight.xml
@@ -9,6 +9,7 @@
+ macAddress