Skip to content

Commit

Permalink
[tplinksmarthome] Added new devices EP10, EP40, KL125, and KL135 (ope…
Browse files Browse the repository at this point in the history
…nhab#11282)

Closes openhab#11156

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Dave J Schoepel <dave@theschoepels.com>
  • Loading branch information
Hilbrand authored and dschoepel committed Nov 9, 2021
1 parent bb4a1ef commit 3df766d
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 159 deletions.
177 changes: 106 additions & 71 deletions bundles/org.openhab.binding.tplinksmarthome/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ This binding adds support to control TP-Link Smart Home Devices from your local

The following TP-Link Smart Devices are supported:

### EP10 Kasa Smart Wi-Fi Plug Mini

* Power On/Off
* LED On/Off
* Wi-Fi signal strength (RSSI)

### EP40 Kasa Smart Wi-Fi Outdoor Plug

* Power On/Off Group
* Power On/Off 2 Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

### HS100 Smart Wi-Fi Plug

* Power On/Off
Expand All @@ -27,7 +40,7 @@ The following TP-Link Smart Devices are supported:
### HS107 Smart Wi-Fi Plug, 2-Outlets

* Power On/Off Group
* Power On/Off Outlets
* Power On/Off 2 Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

Expand Down Expand Up @@ -68,12 +81,12 @@ Switching via openHAB activates the switch directly.
### HS300 Smart Wi-Fi Power Strip

* Power On/Off Group
* Power On/Off Outlets
* Energy readings Outlets
* Power On/Off 6 Outlets
* Energy readings 6 Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KB100 Kasa Smart Light Bulb
### LB100 Smart Wi-Fi LED Bulb with Dimmable Light

* Power On/Off
* Adjust the brightness
Expand All @@ -82,86 +95,46 @@ Switching via openHAB activates the switch directly.

Switching and Brightness is done using the `brightness` channel.

### KB130 Kasa Multi-color Smart Light Bulb
### LB110 Smart Wi-Fi LED Bulb with Dimmable Light

* Power On/Off
* Fine-tune colors
* Adjust light appearance from soft white (2500k) to daylight (9000k)
* Adjust the brightness
* Actual power usage
* Wi-Fi signal strength (RSSI)

Switching, Brightness and Color is done using the `color` channel.

### KP100 Kasa Wi-Fi Smart Plug - Slim Edition

* Power On/Off
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP105 Kasa Wi-Fi Smart Plug - Slim Edition

* Power On/Off
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP115 Kasa Wi-Fi Smart Plug with Energy Monitoring - Slim Edition

* Power On/Off
* Energy readings
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP200 Smart Wi-Fi Power Outlet, 2-Sockets

* Power On/Off Group
* Power On/Off Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP303 Smart Wi-Fi Power Outlet, 3-Sockets

* Power On/Off Group
* Power On/Off Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP400 Smart Outdoor Plug

* Power On/Off Group
* Power On/Off Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)
Switching and Brightness is done using the `brightness` channel.

### LB100 Smart Wi-Fi LED Bulb with Dimmable Light
### LB120 Smart Wi-Fi LED Bulb with Tunable White Light

* Power On/Off
* Adjust light appearance from soft white (2700k) to daylight (6500k)
* Adjust the brightness
* Actual power usage
* Wi-Fi signal strength (RSSI)

Switching and Brightness is done using the `brightness` channel.

### LB110 Smart Wi-Fi LED Bulb with Dimmable Light
### LB130 Smart Wi-Fi LED Bulb with Color Changing Hue

* Power On/Off
* Fine-tune colors
* Adjust light appearance from soft white (2500k) to daylight (9000k)
* Adjust the brightness
* Actual power usage
* Wi-Fi signal strength (RSSI)

Switching and Brightness is done using the `brightness` channel.
Switching, Brightness and Color is done using the `color` channel.

### LB120 Smart Wi-Fi LED Bulb with Tunable White Light
### LB200 Smart Wi-Fi LED Bulb with Dimmable Light

* Power On/Off
* Adjust light appearance from soft white (2700k) to daylight (6500k)
* Adjust the brightness
* Actual power usage
* Wi-Fi signal strength (RSSI)

Switching and Brightness is done using the `brightness` channel.

### LB130 Smart Wi-Fi LED Bulb with Color Changing Hue
### LB230 Smart Wi-Fi LED Bulb with Color Changing Hue

* Power On/Off
* Fine-tune colors
Expand All @@ -172,7 +145,7 @@ Switching and Brightness is done using the `brightness` channel.

Switching, Brightness and Color is done using the `color` channel.

### LB200 Smart Wi-Fi LED Bulb with Dimmable Light
### KB100 Kasa Smart Light Bulb

* Power On/Off
* Adjust the brightness
Expand All @@ -181,7 +154,7 @@ Switching, Brightness and Color is done using the `color` channel.

Switching and Brightness is done using the `brightness` channel.

### LB230 Smart Wi-Fi LED Bulb with Color Changing Hue
### KB130 Kasa Multi-color Smart Light Bulb

* Power On/Off
* Fine-tune colors
Expand Down Expand Up @@ -229,6 +202,17 @@ Switching and Brightness is done using the `brightness` channel.

Switching and Brightness is done using the `brightness` channel.

### KL125 Kasa Smart Wi-Fi Bulb Multicolor

* Power On/Off
* Fine-tune colors
* Adjust light appearance from soft white (2500k) to daylight (6500k)
* Adjust the brightness
* Actual power usage
* Wi-Fi signal strength (RSSI)

Switching, Brightness and Color is done using the `color` channel.

### KL130 Smart Wi-Fi LED Bulb with Color Changing Hue

* Power On/Off
Expand All @@ -240,6 +224,57 @@ Switching and Brightness is done using the `brightness` channel.

Switching, Brightness and Color is done using the `color` channel.

### KL135 Kasa Smart Wi-Fi Bulb Multicolor

* Power On/Off
* Fine-tune colors
* Adjust light appearance from soft white (2500k) to daylight (6500k)
* Adjust the brightness
* Actual power usage
* Wi-Fi signal strength (RSSI)

Switching, Brightness and Color is done using the `color` channel.

### KP100 Kasa Wi-Fi Smart Plug - Slim Edition

* Power On/Off
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP105 Kasa Wi-Fi Smart Plug - Slim Edition

* Power On/Off
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP115 Kasa Wi-Fi Smart Plug with Energy Monitoring - Slim Edition

* Power On/Off
* Energy readings
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP200 Smart Wi-Fi Power Outlet, 2-Sockets

* Power On/Off Group
* Power On/Off 2 Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP303 Smart Wi-Fi Power Outlet, 3-Sockets

* Power On/Off Group
* Power On/Off 3 Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

### KP400 Smart Outdoor Plug

* Power On/Off Group
* Power On/Off 2 Outlets
* LED On/Off
* Wi-Fi signal strength (RSSI)

### RE270K AC750 Wi-Fi Range Extender with Smart Plug

* Power On/Off (readonly)
Expand Down Expand Up @@ -296,21 +331,21 @@ Either `deviceId` or `ipAddress` must be set.

All devices support some of the following channels:

| Channel Type ID | Item Type | Description | Thing types supporting this channel |
|---------------------|--------------------------|------------------------------------------------|----------------------------------------------------------------------------------------------------|
| switch | Switch | Power the device on or off. | HS100, HS103, HS105, HS107, HS110, HS200, HS210, HS300, KP100, KP105, KP115, KP200, KP303, KP400, RE270K, RE370K |
| brightness | Dimmer | Set the brightness of device or dimmer. | HS220, KB100, KL50, KL60, KL110, KL120, LB100, LB110, LB120, LB200 |
| colorTemperature | Dimmer | Set the color temperature in percentage. | KB130, KL120, KL130, LB120, LB130, LB230 |
| colorTemperatureAbs | Number | Set the color temperature in Kelvin. | KB130, KL120, KL130, LB120, LB130, LB230 |
| color | Color | Set the color of the light. | KB130, KL130, LB130, LB230 |
| power | Number:Power | Actual energy usage in Watt. | HS110, HS300, KLxxx, KP115, LBxxx, |
| eneryUsage | Number:Energy | Energy Usage in kWh. | HS110, HS300, KP115 |
| current | Number:ElectricCurrent | Actual current usage in Ampere. | HS110, HS300, KP115 |
| voltage | Number:ElectricPotential | Actual voltage usage in Volt. | HS110, HS300, KP115 |
| led | Switch | Switch the status LED on the device on or off. | HS100, HS103, HS105, HS107, HS110, HS200, HS210, HS220, HS300, KP100, KP105, KP115, KP303, KP200, KP400 |
| rssi | Number:Power | Wi-Fi signal strength indicator in dBm. | All |

The outlet devices (HS107, HS300, KP200, KP400) have group channels.
| Channel Type ID | Item Type | Description | Thing types supporting this channel |
|---------------------|--------------------------|------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| switch | Switch | Power the device on or off. | EP10, EP40, HS100, HS103, HS105, HS107, HS110, HS200, HS210, HS300, KP100, KP105, KP115, KP200, KP303, KP400, RE270K, RE370K |
| brightness | Dimmer | Set the brightness of device or dimmer. | HS220, KB100, KL50, KL60, KL110, KL120, LB100, LB110, LB120, LB200 |
| colorTemperature | Dimmer | Set the color temperature in percentage. | KB130, KL120, KL125, KL130, KL135, LB120, LB130, LB230 |
| colorTemperatureAbs | Number | Set the color temperature in Kelvin. | KB130, KL120, KL125, KL130, KL135, LB120, LB130, LB230 |
| color | Color | Set the color of the light. | KB130, KL125, KL130, KL135, LB130, LB230 |
| power | Number:Power | Actual energy usage in Watt. | HS110, HS300, KLxxx, KP115, LBxxx, |
| eneryUsage | Number:Energy | Energy Usage in kWh. | HS110, HS300, KP115 |
| current | Number:ElectricCurrent | Actual current usage in Ampere. | HS110, HS300, KP115 |
| voltage | Number:ElectricPotential | Actual voltage usage in Volt. | HS110, HS300, KP115 |
| led | Switch | Switch the status LED on the device on or off. | EP10, EP40, HS100, HS103, HS105, HS107, HS110, HS200, HS210, HS220, HS300, KP100, KP105, KP115, KP303, KP200, KP400 |
| rssi | Number:Power | Wi-Fi signal strength indicator in dBm. | All |

The outlet devices (EP40, HS107, HS300, KP200, KP400) have group channels.
This means the channel is prefixed with the group id.
The following group ids are available:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@
@NonNullByDefault
public final class TPLinkSmartHomeBindingConstants {

public enum ColorScales {
NOT_SUPPORTED(0, 0),
K_2500_6500(2500, 6500),
K_2700_6500(2700, 6500),
K_2500_9000(2500, 9000);

private final int warm;
private final int cool;

ColorScales(final int warm, final int cool) {
this.warm = warm;
this.cool = cool;
}

public int getWarm() {
return warm;
}

public int getCool() {
return cool;
}
}

public static final String BINDING_ID = "tplinksmarthome";

// List of all switch channel ids
Expand All @@ -40,10 +63,6 @@ public final class TPLinkSmartHomeBindingConstants {
public static final String CHANNEL_COLOR = "color";
public static final String CHANNEL_COLOR_TEMPERATURE = "colorTemperature";
public static final String CHANNEL_COLOR_TEMPERATURE_ABS = "colorTemperatureAbs";
public static final int COLOR_TEMPERATURE_1_MIN = 2700;
public static final int COLOR_TEMPERATURE_1_MAX = 6500;
public static final int COLOR_TEMPERATURE_2_MIN = 2500;
public static final int COLOR_TEMPERATURE_2_MAX = 9000;

public static final Set<String> CHANNELS_BULB_SWITCH = Stream.of(CHANNEL_BRIGHTNESS, CHANNEL_COLOR,
CHANNEL_COLOR_TEMPERATURE, CHANNEL_COLOR_TEMPERATURE_ABS, CHANNEL_SWITCH).collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
*/
package org.openhab.binding.tplinksmarthome.internal;

import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeBindingConstants.*;
import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType.*;
import static org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType.SUPPORTED_THING_TYPES;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -46,13 +45,13 @@ public class TPLinkSmartHomeHandlerFactory extends BaseThingHandlerFactory {
private @NonNullByDefault({}) TPLinkIpAddressService ipAddressService;

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
public boolean supportsThingType(final ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES.contains(thingTypeUID);
}

@Nullable
@Override
protected ThingHandler createHandler(Thing thing) {
protected ThingHandler createHandler(final Thing thing) {
final ThingTypeUID thingTypeUID = thing.getThingTypeUID();
final TPLinkSmartHomeThingType type = TPLinkSmartHomeThingType.THING_TYPE_MAP.get(thingTypeUID);

Expand All @@ -63,45 +62,38 @@ protected ThingHandler createHandler(Thing thing) {

switch (type.getDeviceType()) {
case BULB:
if (TPLinkSmartHomeThingType.isBulbDeviceWithTemperatureColor1(thingTypeUID)) {
device = new BulbDevice(thingTypeUID, COLOR_TEMPERATURE_1_MIN, COLOR_TEMPERATURE_1_MAX);
} else if (TPLinkSmartHomeThingType.isBulbDeviceWithTemperatureColor2(thingTypeUID)) {
device = new BulbDevice(thingTypeUID, COLOR_TEMPERATURE_2_MIN, COLOR_TEMPERATURE_2_MAX);
} else {
device = new BulbDevice(thingTypeUID);
}
device = new BulbDevice(type);
break;
case DIMMER:
device = new DimmerDevice();
break;
case PLUG:
if (HS110.is(thingTypeUID) || KP115.is(thingTypeUID)) {
device = new EnergySwitchDevice();
} else {
device = new SwitchDevice();
}
device = new SwitchDevice();
break;
case PLUG_WITH_ENERGY:
device = new EnergySwitchDevice();
break;
case STRIP:
device = new PowerStripDevice(type);
break;
case SWITCH:
device = new SwitchDevice();
break;
case RANGE_EXTENDER:
device = new RangeExtenderDevice();
break;
case STRIP:
device = new PowerStripDevice(type);
break;
default:
return null;
}
return new SmartHomeHandler(thing, device, type, ipAddressService);
}

@Reference
protected void setTPLinkIpAddressCache(TPLinkIpAddressService ipAddressCache) {
protected void setTPLinkIpAddressCache(final TPLinkIpAddressService ipAddressCache) {
this.ipAddressService = ipAddressCache;
}

protected void unsetTPLinkIpAddressCache(TPLinkIpAddressService ipAddressCache) {
protected void unsetTPLinkIpAddressCache(final TPLinkIpAddressService ipAddressCache) {
this.ipAddressService = null;
}
}
Loading

0 comments on commit 3df766d

Please sign in to comment.