From ff103585da9b2c4609131400f2f38ba5225b4758 Mon Sep 17 00:00:00 2001 From: Andrew Fiddian-Green Date: Sun, 24 Nov 2024 00:01:35 +0000 Subject: [PATCH] [tplinksmarthome] Improve color temperature channel (#17780) * [tplinksmarthome] color temperature channel improvements Signed-off-by: AndrewFG --- .../README.md | 2 +- .../TPLinkSmartHomeHandlerFactory.java | 9 +- .../TPLinkStateDescriptionProvider.java | 83 ++++++++++++++++++ .../internal/device/BulbDevice.java | 16 ++-- .../internal/handler/SmartHomeHandler.java | 18 ++-- .../OH-INF/i18n/tplinksmarthome.properties | 6 -- .../src/main/resources/OH-INF/thing/KB130.xml | 6 +- .../src/main/resources/OH-INF/thing/KL120.xml | 6 +- .../src/main/resources/OH-INF/thing/KL125.xml | 6 +- .../src/main/resources/OH-INF/thing/KL130.xml | 6 +- .../src/main/resources/OH-INF/thing/KL135.xml | 6 +- .../src/main/resources/OH-INF/thing/KL400.xml | 6 +- .../src/main/resources/OH-INF/thing/KL430.xml | 6 +- .../src/main/resources/OH-INF/thing/LB120.xml | 6 +- .../src/main/resources/OH-INF/thing/LB130.xml | 6 +- .../src/main/resources/OH-INF/thing/LB230.xml | 6 +- .../main/resources/OH-INF/thing/channels.xml | 25 ------ .../resources/OH-INF/update/instructions.xml | 86 +++++++++++++++++++ .../TPLinkSmartHomeHandlerFactoryTest.java | 3 +- .../handler/SmartHomeHandlerTest.java | 5 +- 20 files changed, 255 insertions(+), 58 deletions(-) create mode 100644 bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkStateDescriptionProvider.java create mode 100644 bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/update/instructions.xml diff --git a/bundles/org.openhab.binding.tplinksmarthome/README.md b/bundles/org.openhab.binding.tplinksmarthome/README.md index 3e78d48bd6a..edd1066d786 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/README.md +++ b/bundles/org.openhab.binding.tplinksmarthome/README.md @@ -394,7 +394,7 @@ All devices support some of the following channels: | switch | Switch | Power the device on or off. | EP10, EP25, EP40, HS100, HS103, HS105, HS107, HS110, HS200, HS210, HS300, KP100, KP105, KP115, KP200, KP303, KP400, KP401, KS230, RE270K, RE370K | | brightness | Dimmer | Set the brightness of device or dimmer. | ES20M, HS220, KB100, KL50, KL60, KL110, KL120, KP405, LB100, LB110, LB120, LB200 | | colorTemperature | Dimmer | Set the color temperature in percentage. | KB130, KL120, KL125, KL130, KL135, KL400, KL430, LB120, LB130, LB230 | -| colorTemperatureAbs | Number | Set the color temperature in Kelvin. | KB130, KL120, KL125, KL130, KL135, KL400, KL430, LB120, LB130, LB230 | +| colorTemperatureAbs | Number:Temperature | Set the color temperature in Kelvin. | KB130, KL120, KL125, KL130, KL135, KL400, KL430, LB120, LB130, LB230 | | color | Color | Set the color of the light. | KB130, KL125, KL130, KL135, KL400, KL430, LB130, LB230 | | power | Number:Power | Actual energy usage in Watt. | EP25, HS110, HS300, KLxxx, KP115, KP125, LBxxx, | | eneryUsage | Number:Energy | Energy Usage in kWh. | EP25, HS110, HS300, KP115, KP125 | diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactory.java b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactory.java index 2dcc988714a..2d0b4d61297 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactory.java +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactory.java @@ -30,6 +30,7 @@ import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.binding.BaseThingHandlerFactory; import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandlerFactory; +import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -44,6 +45,12 @@ import org.osgi.service.component.annotations.Reference; public class TPLinkSmartHomeHandlerFactory extends BaseThingHandlerFactory { private @NonNullByDefault({}) TPLinkIpAddressService ipAddressService; + private final TPLinkStateDescriptionProvider stateDescriptionProvider; + + @Activate + public TPLinkSmartHomeHandlerFactory(final @Reference TPLinkStateDescriptionProvider stateDescriptionProvider) { + this.stateDescriptionProvider = stateDescriptionProvider; + } @Override public boolean supportsThingType(final ThingTypeUID thingTypeUID) { @@ -89,7 +96,7 @@ public class TPLinkSmartHomeHandlerFactory extends BaseThingHandlerFactory { default: return null; } - return new SmartHomeHandler(thing, device, type, ipAddressService); + return new SmartHomeHandler(thing, device, type, ipAddressService, stateDescriptionProvider); } @Reference diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkStateDescriptionProvider.java b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkStateDescriptionProvider.java new file mode 100644 index 00000000000..e4a3834c478 --- /dev/null +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/TPLinkStateDescriptionProvider.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.tplinksmarthome.internal; + +import java.math.BigDecimal; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.events.EventPublisher; +import org.openhab.core.thing.Channel; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.binding.BaseDynamicStateDescriptionProvider; +import org.openhab.core.thing.events.ThingEventFactory; +import org.openhab.core.thing.i18n.ChannelTypeI18nLocalizationService; +import org.openhab.core.thing.link.ItemChannelLinkRegistry; +import org.openhab.core.thing.type.DynamicStateDescriptionProvider; +import org.openhab.core.types.StateDescription; +import org.openhab.core.types.StateDescriptionFragment; +import org.openhab.core.types.StateDescriptionFragmentBuilder; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +/** + * The {@link TPLinkStateDescriptionProvider} provides state descriptions for different color temperature light models. + * + * @author Andrew Fiddian-Green - Initial contribution + * + */ +@NonNullByDefault +@Component(service = { DynamicStateDescriptionProvider.class, TPLinkStateDescriptionProvider.class }) +public class TPLinkStateDescriptionProvider extends BaseDynamicStateDescriptionProvider { + + private final Map stateDescriptionFragments = new ConcurrentHashMap<>(); + + @Activate + public TPLinkStateDescriptionProvider(final @Reference EventPublisher eventPublisher, + final @Reference ItemChannelLinkRegistry itemChannelLinkRegistry, + final @Reference ChannelTypeI18nLocalizationService channelTypeI18nLocalizationService) { + this.eventPublisher = eventPublisher; + this.itemChannelLinkRegistry = itemChannelLinkRegistry; + this.channelTypeI18nLocalizationService = channelTypeI18nLocalizationService; + } + + @Override + public @Nullable StateDescription getStateDescription(Channel channel, @Nullable StateDescription original, + @Nullable Locale locale) { + StateDescriptionFragment stateDescriptionFragment = stateDescriptionFragments.get(channel.getUID()); + return stateDescriptionFragment != null ? stateDescriptionFragment.toStateDescription() + : super.getStateDescription(channel, original, locale); + } + + /** + * Set the state description minimum and maximum values and pattern in Kelvin for the given channel UID + */ + public void setMinMaxKelvin(ChannelUID channelUID, long minKelvin, long maxKelvin) { + StateDescriptionFragment oldStateDescriptionFragment = stateDescriptionFragments.get(channelUID); + StateDescriptionFragment newStateDescriptionFragment = StateDescriptionFragmentBuilder.create() + .withMinimum(BigDecimal.valueOf(minKelvin)).withMaximum(BigDecimal.valueOf(maxKelvin)) + .withStep(BigDecimal.valueOf(100)).withPattern("%.0f K").build(); + if (!newStateDescriptionFragment.equals(oldStateDescriptionFragment)) { + stateDescriptionFragments.put(channelUID, newStateDescriptionFragment); + ItemChannelLinkRegistry itemChannelLinkRegistry = this.itemChannelLinkRegistry; + postEvent(ThingEventFactory.createChannelDescriptionChangedEvent(channelUID, + itemChannelLinkRegistry != null ? itemChannelLinkRegistry.getLinkedItemNames(channelUID) : Set.of(), + newStateDescriptionFragment, oldStateDescriptionFragment)); + } + } +} diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/device/BulbDevice.java b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/device/BulbDevice.java index 6482c80d92a..97643eef1b5 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/device/BulbDevice.java +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/device/BulbDevice.java @@ -12,13 +12,7 @@ */ package org.openhab.binding.tplinksmarthome.internal.device; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNELS_BULB_SWITCH; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNEL_BRIGHTNESS; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNEL_COLOR; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNEL_COLOR_TEMPERATURE; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNEL_COLOR_TEMPERATURE_ABS; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNEL_ENERGY_POWER; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNEL_SWITCH; +import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.*; import java.io.IOException; @@ -163,4 +157,12 @@ public class BulbDevice extends SmartHomeDevice { private int guardColorTemperature(final int colorTemperature) { return Math.max(colorTempMin, Math.min(colorTempMax, colorTemperature)); } + + public int getColorTempMin() { + return colorTempMin; + } + + public int getColorTempMax() { + return colorTempMax; + } } diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandler.java b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandler.java index 966d91e8c0a..ba54ffaa788 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandler.java +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandler.java @@ -12,11 +12,7 @@ */ package org.openhab.binding.tplinksmarthome.internal.handler; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CHANNEL_RSSI; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CONFIG_DEVICE_ID; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.CONFIG_IP; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.FORCED_REFRESH_BOUNDERY_SECONDS; -import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.FORCED_REFRESH_BOUNDERY_SWITCHED_SECONDS; +import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.*; import java.io.IOException; import java.time.Duration; @@ -33,6 +29,8 @@ import org.openhab.binding.tplinksmarthome.internal.TPLinkIpAddressService; import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeConfiguration; import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType; import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType.DeviceType; +import org.openhab.binding.tplinksmarthome.internal.TPLinkStateDescriptionProvider; +import org.openhab.binding.tplinksmarthome.internal.device.BulbDevice; import org.openhab.binding.tplinksmarthome.internal.device.DeviceState; import org.openhab.binding.tplinksmarthome.internal.device.SmartHomeDevice; import org.openhab.core.cache.ExpiringCache; @@ -69,6 +67,7 @@ public class SmartHomeHandler extends BaseThingHandler { private final SmartHomeDevice smartHomeDevice; private final TPLinkIpAddressService ipAddressService; private final int forceRefreshThreshold; + private final TPLinkStateDescriptionProvider stateDescriptionProvider; private @NonNullByDefault({}) TPLinkSmartHomeConfiguration configuration; private @NonNullByDefault({}) Connection connection; @@ -86,15 +85,18 @@ public class SmartHomeHandler extends BaseThingHandler { * @param smartHomeDevice Specific Smart Home device handler * @param type The device type * @param ipAddressService Cache keeping track of ip addresses of tp link devices + * @param stateDescriptionProvider */ public SmartHomeHandler(final Thing thing, final SmartHomeDevice smartHomeDevice, - final TPLinkSmartHomeThingType type, final TPLinkIpAddressService ipAddressService) { + final TPLinkSmartHomeThingType type, final TPLinkIpAddressService ipAddressService, + final TPLinkStateDescriptionProvider stateDescriptionProvider) { super(thing); this.smartHomeDevice = smartHomeDevice; this.ipAddressService = ipAddressService; this.forceRefreshThreshold = type.getDeviceType() == DeviceType.SWITCH || type.getDeviceType() == DeviceType.DIMMER ? FORCED_REFRESH_BOUNDERY_SWITCHED_SECONDS : FORCED_REFRESH_BOUNDERY_SECONDS; + this.stateDescriptionProvider = stateDescriptionProvider; } @Override @@ -148,6 +150,10 @@ public class SmartHomeHandler extends BaseThingHandler { ? new ExpiringCache<>(ONE_SECOND, this::forceCacheUpdate) : cache; updateStatus(ThingStatus.UNKNOWN); + if (smartHomeDevice instanceof BulbDevice bulb) { + stateDescriptionProvider.setMinMaxKelvin(new ChannelUID(thing.getUID(), CHANNEL_COLOR_TEMPERATURE_ABS), + bulb.getColorTempMin(), bulb.getColorTempMax()); + } // While config.xml defines refresh as min 1, this check is used to run a test that doesn't start refresh. if (configuration.refresh > 0) { startAutomaticRefresh(configuration); diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/i18n/tplinksmarthome.properties b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/i18n/tplinksmarthome.properties index f4257130a4d..9ac3cd414e5 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/i18n/tplinksmarthome.properties +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/i18n/tplinksmarthome.properties @@ -138,12 +138,6 @@ channel-group-type.tplinksmarthome.switch-outlet.label = Outlet # channel types -channel-type.tplinksmarthome.colorTemperatureAbs1.label = Color Temperature -channel-type.tplinksmarthome.colorTemperatureAbs1.description = This channel supports adjusting the color temperature from 2700K to 6500K. -channel-type.tplinksmarthome.colorTemperatureAbs2.label = Color Temperature -channel-type.tplinksmarthome.colorTemperatureAbs2.description = This channel supports adjusting the color temperature from 2500K to 9000K. -channel-type.tplinksmarthome.colorTemperatureAbs3.label = Color Temperature -channel-type.tplinksmarthome.colorTemperatureAbs3.description = This channel supports adjusting the color temperature from 2500K to 6500K. channel-type.tplinksmarthome.current.label = Current channel-type.tplinksmarthome.current.description = Actual current usage. channel-type.tplinksmarthome.energy-usage.label = Energy Usage diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KB130.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KB130.xml index 1329f544b23..b646f44456c 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KB130.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KB130.xml @@ -12,10 +12,14 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL120.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL120.xml index 9d4c1d60da7..903224e336f 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL120.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL120.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL125.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL125.xml index fff94fa871e..f3907d0a91d 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL125.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL125.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL130.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL130.xml index 6c6a8ec319f..877d48b3c58 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL130.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL130.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL135.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL135.xml index ec025384916..7f1de94d189 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL135.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL135.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL400.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL400.xml index 023b0048fd7..91946dfe2b6 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL400.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL400.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL430.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL430.xml index b96857a6268..8dc6305db9e 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL430.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/KL430.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB120.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB120.xml index e029aded792..689cd5886c4 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB120.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB120.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB130.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB130.xml index c7ca1093853..3ace673abfe 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB130.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB130.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB230.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB230.xml index f8bcdc1dfa1..17a5e496064 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB230.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/LB230.xml @@ -12,11 +12,15 @@ - + + + 1 + + deviceId diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/channels.xml index e02a37e0435..5a132e76978 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/thing/channels.xml @@ -19,31 +19,6 @@ Switch - - - Number - - This channel supports adjusting the color temperature from 2700K to 6500K. - ColorLight - - - - - Number - - This channel supports adjusting the color temperature from 2500K to 9000K. - ColorLight - - - - - Number - - This channel supports adjusting the color temperature from 2500K to 6500K. - ColorLight - - - Number:Power diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/update/instructions.xml new file mode 100644 index 00000000000..1c09845d30d --- /dev/null +++ b/bundles/org.openhab.binding.tplinksmarthome/src/main/resources/OH-INF/update/instructions.xml @@ -0,0 +1,86 @@ + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + + + + system:color-temperature-abs + + + + + diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactoryTest.java b/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactoryTest.java index b5808be5f09..937f7c84e20 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactoryTest.java +++ b/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/TPLinkSmartHomeHandlerFactoryTest.java @@ -43,8 +43,9 @@ import org.openhab.core.thing.ThingTypeUID; public class TPLinkSmartHomeHandlerFactoryTest { private static final String SMART_HOME_DEVICE_FIELD = "smartHomeDevice"; + private @Mock TPLinkStateDescriptionProvider stateDescriptionProvider; - private final TPLinkSmartHomeHandlerFactory factory = new TPLinkSmartHomeHandlerFactory(); + private final TPLinkSmartHomeHandlerFactory factory = new TPLinkSmartHomeHandlerFactory(stateDescriptionProvider); // @formatter:off private static final List TESTS = Arrays.asList(new Object[][] { diff --git a/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandlerTest.java b/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandlerTest.java index 8aef9dff73d..037d6e7e27e 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandlerTest.java +++ b/bundles/org.openhab.binding.tplinksmarthome/src/test/java/org/openhab/binding/tplinksmarthome/internal/handler/SmartHomeHandlerTest.java @@ -37,6 +37,7 @@ import org.openhab.binding.tplinksmarthome.internal.Connection; import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeConfiguration; import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeDiscoveryService; import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType; +import org.openhab.binding.tplinksmarthome.internal.TPLinkStateDescriptionProvider; import org.openhab.binding.tplinksmarthome.internal.device.SmartHomeDevice; import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil; import org.openhab.core.config.core.Configuration; @@ -67,6 +68,7 @@ public class SmartHomeHandlerTest { private @Mock @NonNullByDefault({}) Thing thing; private @Mock @NonNullByDefault({}) SmartHomeDevice smartHomeDevice; private @Mock @NonNullByDefault({}) TPLinkSmartHomeDiscoveryService discoveryService; + private @Mock @NonNullByDefault({}) TPLinkStateDescriptionProvider stateDescriptionProvider; private final Configuration configuration = new Configuration(); @@ -78,7 +80,8 @@ public class SmartHomeHandlerTest { lenient().when(smartHomeDevice.getUpdateCommand()).thenReturn(Commands.getSysinfo()); lenient().when(connection.sendCommand(Commands.getSysinfo())) .thenReturn(ModelTestUtil.readJson("plug_get_sysinfo_response")); - handler = new SmartHomeHandler(thing, smartHomeDevice, TPLinkSmartHomeThingType.HS100, discoveryService) { + handler = new SmartHomeHandler(thing, smartHomeDevice, TPLinkSmartHomeThingType.HS100, discoveryService, + stateDescriptionProvider) { @Override Connection createConnection(TPLinkSmartHomeConfiguration config) { return connection;