mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[tplinksmarthome] Improve color temperature channel (#17780)
* [tplinksmarthome] color temperature channel improvements Signed-off-by: AndrewFG <software@whitebear.ch>
This commit is contained in:
parent
8bc89612c1
commit
ff103585da
@ -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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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, |
|
| 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 |
|
| eneryUsage | Number:Energy | Energy Usage in kWh. | EP25, HS110, HS300, KP115, KP125 |
|
||||||
|
@ -30,6 +30,7 @@ import org.openhab.core.thing.ThingTypeUID;
|
|||||||
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
|
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
|
||||||
import org.openhab.core.thing.binding.ThingHandler;
|
import org.openhab.core.thing.binding.ThingHandler;
|
||||||
import org.openhab.core.thing.binding.ThingHandlerFactory;
|
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.Component;
|
||||||
import org.osgi.service.component.annotations.Reference;
|
import org.osgi.service.component.annotations.Reference;
|
||||||
|
|
||||||
@ -44,6 +45,12 @@ import org.osgi.service.component.annotations.Reference;
|
|||||||
public class TPLinkSmartHomeHandlerFactory extends BaseThingHandlerFactory {
|
public class TPLinkSmartHomeHandlerFactory extends BaseThingHandlerFactory {
|
||||||
|
|
||||||
private @NonNullByDefault({}) TPLinkIpAddressService ipAddressService;
|
private @NonNullByDefault({}) TPLinkIpAddressService ipAddressService;
|
||||||
|
private final TPLinkStateDescriptionProvider stateDescriptionProvider;
|
||||||
|
|
||||||
|
@Activate
|
||||||
|
public TPLinkSmartHomeHandlerFactory(final @Reference TPLinkStateDescriptionProvider stateDescriptionProvider) {
|
||||||
|
this.stateDescriptionProvider = stateDescriptionProvider;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsThingType(final ThingTypeUID thingTypeUID) {
|
public boolean supportsThingType(final ThingTypeUID thingTypeUID) {
|
||||||
@ -89,7 +96,7 @@ public class TPLinkSmartHomeHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new SmartHomeHandler(thing, device, type, ipAddressService);
|
return new SmartHomeHandler(thing, device, type, ipAddressService, stateDescriptionProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Reference
|
@Reference
|
||||||
|
@ -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<ChannelUID, StateDescriptionFragment> 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,13 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.tplinksmarthome.internal.device;
|
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.*;
|
||||||
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 java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -163,4 +157,12 @@ public class BulbDevice extends SmartHomeDevice {
|
|||||||
private int guardColorTemperature(final int colorTemperature) {
|
private int guardColorTemperature(final int colorTemperature) {
|
||||||
return Math.max(colorTempMin, Math.min(colorTempMax, colorTemperature));
|
return Math.max(colorTempMin, Math.min(colorTempMax, colorTemperature));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getColorTempMin() {
|
||||||
|
return colorTempMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColorTempMax() {
|
||||||
|
return colorTempMax;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.tplinksmarthome.internal.handler;
|
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.*;
|
||||||
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 java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
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.TPLinkSmartHomeConfiguration;
|
||||||
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType;
|
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType;
|
||||||
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType.DeviceType;
|
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.DeviceState;
|
||||||
import org.openhab.binding.tplinksmarthome.internal.device.SmartHomeDevice;
|
import org.openhab.binding.tplinksmarthome.internal.device.SmartHomeDevice;
|
||||||
import org.openhab.core.cache.ExpiringCache;
|
import org.openhab.core.cache.ExpiringCache;
|
||||||
@ -69,6 +67,7 @@ public class SmartHomeHandler extends BaseThingHandler {
|
|||||||
private final SmartHomeDevice smartHomeDevice;
|
private final SmartHomeDevice smartHomeDevice;
|
||||||
private final TPLinkIpAddressService ipAddressService;
|
private final TPLinkIpAddressService ipAddressService;
|
||||||
private final int forceRefreshThreshold;
|
private final int forceRefreshThreshold;
|
||||||
|
private final TPLinkStateDescriptionProvider stateDescriptionProvider;
|
||||||
|
|
||||||
private @NonNullByDefault({}) TPLinkSmartHomeConfiguration configuration;
|
private @NonNullByDefault({}) TPLinkSmartHomeConfiguration configuration;
|
||||||
private @NonNullByDefault({}) Connection connection;
|
private @NonNullByDefault({}) Connection connection;
|
||||||
@ -86,15 +85,18 @@ public class SmartHomeHandler extends BaseThingHandler {
|
|||||||
* @param smartHomeDevice Specific Smart Home device handler
|
* @param smartHomeDevice Specific Smart Home device handler
|
||||||
* @param type The device type
|
* @param type The device type
|
||||||
* @param ipAddressService Cache keeping track of ip addresses of tp link devices
|
* @param ipAddressService Cache keeping track of ip addresses of tp link devices
|
||||||
|
* @param stateDescriptionProvider
|
||||||
*/
|
*/
|
||||||
public SmartHomeHandler(final Thing thing, final SmartHomeDevice smartHomeDevice,
|
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);
|
super(thing);
|
||||||
this.smartHomeDevice = smartHomeDevice;
|
this.smartHomeDevice = smartHomeDevice;
|
||||||
this.ipAddressService = ipAddressService;
|
this.ipAddressService = ipAddressService;
|
||||||
this.forceRefreshThreshold = type.getDeviceType() == DeviceType.SWITCH
|
this.forceRefreshThreshold = type.getDeviceType() == DeviceType.SWITCH
|
||||||
|| type.getDeviceType() == DeviceType.DIMMER ? FORCED_REFRESH_BOUNDERY_SWITCHED_SECONDS
|
|| type.getDeviceType() == DeviceType.DIMMER ? FORCED_REFRESH_BOUNDERY_SWITCHED_SECONDS
|
||||||
: FORCED_REFRESH_BOUNDERY_SECONDS;
|
: FORCED_REFRESH_BOUNDERY_SECONDS;
|
||||||
|
this.stateDescriptionProvider = stateDescriptionProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -148,6 +150,10 @@ public class SmartHomeHandler extends BaseThingHandler {
|
|||||||
? new ExpiringCache<>(ONE_SECOND, this::forceCacheUpdate)
|
? new ExpiringCache<>(ONE_SECOND, this::forceCacheUpdate)
|
||||||
: cache;
|
: cache;
|
||||||
updateStatus(ThingStatus.UNKNOWN);
|
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.
|
// 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) {
|
if (configuration.refresh > 0) {
|
||||||
startAutomaticRefresh(configuration);
|
startAutomaticRefresh(configuration);
|
||||||
|
@ -138,12 +138,6 @@ channel-group-type.tplinksmarthome.switch-outlet.label = Outlet
|
|||||||
|
|
||||||
# channel types
|
# 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.label = Current
|
||||||
channel-type.tplinksmarthome.current.description = Actual current usage.
|
channel-type.tplinksmarthome.current.description = Actual current usage.
|
||||||
channel-type.tplinksmarthome.energy-usage.label = Energy Usage
|
channel-type.tplinksmarthome.energy-usage.label = Energy Usage
|
||||||
|
@ -12,10 +12,14 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="brightness" typeId="system.brightness"/>
|
<channel id="brightness" typeId="system.brightness"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs1"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs3"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs3"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="brightness" typeId="system.brightness"/>
|
<channel id="brightness" typeId="system.brightness"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs1"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="color" typeId="system.color"/>
|
<channel id="color" typeId="system.color"/>
|
||||||
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
<channel id="colorTemperature" typeId="system.color-temperature"/>
|
||||||
<channel id="colorTemperatureAbs" typeId="colorTemperatureAbs2"/>
|
<channel id="colorTemperatureAbs" typeId="system.color-temperature-abs"/>
|
||||||
<channel id="power" typeId="power"/>
|
<channel id="power" typeId="power"/>
|
||||||
<channel id="rssi" typeId="rssi"/>
|
<channel id="rssi" typeId="rssi"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<representation-property>deviceId</representation-property>
|
<representation-property>deviceId</representation-property>
|
||||||
|
|
||||||
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
<config-description-ref uri="thing-type:tplinksmarthome:device-bulb"/>
|
||||||
|
@ -19,31 +19,6 @@
|
|||||||
<category>Switch</category>
|
<category>Switch</category>
|
||||||
</channel-type>
|
</channel-type>
|
||||||
|
|
||||||
<!-- Absolute Temperature Channel -->
|
|
||||||
<channel-type id="colorTemperatureAbs1" advanced="true">
|
|
||||||
<item-type>Number</item-type>
|
|
||||||
<label>Color Temperature</label>
|
|
||||||
<description>This channel supports adjusting the color temperature from 2700K to 6500K.</description>
|
|
||||||
<category>ColorLight</category>
|
|
||||||
<state min="2700" max="6500" pattern="%d K"/>
|
|
||||||
</channel-type>
|
|
||||||
|
|
||||||
<channel-type id="colorTemperatureAbs2" advanced="true">
|
|
||||||
<item-type>Number</item-type>
|
|
||||||
<label>Color Temperature</label>
|
|
||||||
<description>This channel supports adjusting the color temperature from 2500K to 9000K.</description>
|
|
||||||
<category>ColorLight</category>
|
|
||||||
<state min="2500" max="9000" pattern="%d K"/>
|
|
||||||
</channel-type>
|
|
||||||
|
|
||||||
<channel-type id="colorTemperatureAbs3" advanced="true">
|
|
||||||
<item-type>Number</item-type>
|
|
||||||
<label>Color Temperature</label>
|
|
||||||
<description>This channel supports adjusting the color temperature from 2500K to 6500K.</description>
|
|
||||||
<category>ColorLight</category>
|
|
||||||
<state min="2500" max="6500" pattern="%d K"/>
|
|
||||||
</channel-type>
|
|
||||||
|
|
||||||
<!-- Energy Channel types -->
|
<!-- Energy Channel types -->
|
||||||
<channel-type id="power">
|
<channel-type id="power">
|
||||||
<item-type>Number:Power</item-type>
|
<item-type>Number:Power</item-type>
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
|
||||||
|
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:kb130">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:kl120">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:kl125">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:kl130">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:kl135">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:kl400">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:kl430">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:lb120">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:lb130">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<thing-type uid="tplinksmarthome:lb230">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<update-channel id="colorTemperatureAbs">
|
||||||
|
<type>system:color-temperature-abs</type>
|
||||||
|
</update-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
</update:update-descriptions>
|
@ -43,8 +43,9 @@ import org.openhab.core.thing.ThingTypeUID;
|
|||||||
public class TPLinkSmartHomeHandlerFactoryTest {
|
public class TPLinkSmartHomeHandlerFactoryTest {
|
||||||
|
|
||||||
private static final String SMART_HOME_DEVICE_FIELD = "smartHomeDevice";
|
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
|
// @formatter:off
|
||||||
private static final List<Object[]> TESTS = Arrays.asList(new Object[][] {
|
private static final List<Object[]> TESTS = Arrays.asList(new Object[][] {
|
||||||
|
@ -37,6 +37,7 @@ import org.openhab.binding.tplinksmarthome.internal.Connection;
|
|||||||
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeConfiguration;
|
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeConfiguration;
|
||||||
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeDiscoveryService;
|
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeDiscoveryService;
|
||||||
import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType;
|
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.device.SmartHomeDevice;
|
||||||
import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
|
import org.openhab.binding.tplinksmarthome.internal.model.ModelTestUtil;
|
||||||
import org.openhab.core.config.core.Configuration;
|
import org.openhab.core.config.core.Configuration;
|
||||||
@ -67,6 +68,7 @@ public class SmartHomeHandlerTest {
|
|||||||
private @Mock @NonNullByDefault({}) Thing thing;
|
private @Mock @NonNullByDefault({}) Thing thing;
|
||||||
private @Mock @NonNullByDefault({}) SmartHomeDevice smartHomeDevice;
|
private @Mock @NonNullByDefault({}) SmartHomeDevice smartHomeDevice;
|
||||||
private @Mock @NonNullByDefault({}) TPLinkSmartHomeDiscoveryService discoveryService;
|
private @Mock @NonNullByDefault({}) TPLinkSmartHomeDiscoveryService discoveryService;
|
||||||
|
private @Mock @NonNullByDefault({}) TPLinkStateDescriptionProvider stateDescriptionProvider;
|
||||||
|
|
||||||
private final Configuration configuration = new Configuration();
|
private final Configuration configuration = new Configuration();
|
||||||
|
|
||||||
@ -78,7 +80,8 @@ public class SmartHomeHandlerTest {
|
|||||||
lenient().when(smartHomeDevice.getUpdateCommand()).thenReturn(Commands.getSysinfo());
|
lenient().when(smartHomeDevice.getUpdateCommand()).thenReturn(Commands.getSysinfo());
|
||||||
lenient().when(connection.sendCommand(Commands.getSysinfo()))
|
lenient().when(connection.sendCommand(Commands.getSysinfo()))
|
||||||
.thenReturn(ModelTestUtil.readJson("plug_get_sysinfo_response"));
|
.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
|
@Override
|
||||||
Connection createConnection(TPLinkSmartHomeConfiguration config) {
|
Connection createConnection(TPLinkSmartHomeConfiguration config) {
|
||||||
return connection;
|
return connection;
|
||||||
|
Loading…
Reference in New Issue
Block a user