[tapocontrol] add L610, L630 Spot and L930 LightStrip (#13814)

* fix color change bug*

Signed-off-by: Christian Wild <christian@wildclan.de>
This commit is contained in:
Christian Wild
2022-12-10 16:53:30 +01:00
committed by GitHub
parent ad5facc2e5
commit 8d28085226
13 changed files with 238 additions and 63 deletions

View File

@@ -64,7 +64,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th
}
/**
* deactivate
* activate
*/
@Override
public void activate() {
@@ -178,7 +178,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th
}
}
} catch (Exception e) {
logger.debug("error handlling CloudDevices", e);
logger.debug("error handling CloudDevices", e);
}
}

View File

@@ -40,8 +40,11 @@ public class TapoThingConstants {
public static final String DEVICE_P115 = "P115";
public static final String DEVICE_L510 = "L510";
public static final String DEVICE_L530 = "L530";
public static final String DEVICE_L610 = "L610";
public static final String DEVICE_L630 = "L630";
public static final String DEVICE_L900 = "L900";
public static final String DEVICE_L920 = "L920";
public static final String DEVICE_L930 = "L930";
public static final String DEVICE_UNIVERSAL = "Test_Device";
/*** LIST OF SUPPORTED DEVICE DESCRIPTIONS ***/
@@ -59,17 +62,21 @@ public class TapoThingConstants {
public static final ThingTypeUID P115_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_P115);
public static final ThingTypeUID L510_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_L510);
public static final ThingTypeUID L530_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_L530);
public static final ThingTypeUID L610_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_L610);
public static final ThingTypeUID L630_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_L630);
public static final ThingTypeUID L900_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_L900);
public static final ThingTypeUID L920_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_L920);
public static final ThingTypeUID L930_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_L930);
public static final ThingTypeUID UNIVERSAL_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_UNIVERSAL);
/*** SET OF SUPPORTED UIDS ***/
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_UIDS = Set.of(BRIDGE_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_SMART_PLUG_UIDS = Set.of(P100_THING_TYPE, P105_THING_TYPE,
P110_THING_TYPE, P115_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_WHITE_BULB_UIDS = Set.of(L510_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_COLOR_BULB_UIDS = Set.of(L530_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_LIGHT_STRIP_UIDS = Set.of(L900_THING_TYPE, L920_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_WHITE_BULB_UIDS = Set.of(L510_THING_TYPE, L610_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_COLOR_BULB_UIDS = Set.of(L530_THING_TYPE, L630_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_LIGHT_STRIP_UIDS = Set.of(L900_THING_TYPE, L920_THING_TYPE,
L930_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.unmodifiableSet(Stream
.of(SUPPORTED_BRIDGE_UIDS, SUPPORTED_SMART_PLUG_UIDS, SUPPORTED_WHITE_BULB_UIDS,

View File

@@ -259,6 +259,8 @@ public class TapoBridgeHandler extends BaseBridgeHandler {
if (config.cloudDiscovery) {
logger.trace("{} discover devicelist from cloud", this.uid);
deviceList = getDeviceListCloud();
} else {
logger.info("{} Discovery disabled in bridge settings ", this.uid);
}
return deviceList;
}

View File

@@ -127,9 +127,9 @@ public class TapoSmartBulb extends TapoDevice {
protected void setColor(HSBType command) {
HashMap<String, Object> newState = new HashMap<>();
newState.put(DEVICE_PROPERTY_ON, true);
newState.put(DEVICE_PROPERTY_HUE, command.getHue());
newState.put(DEVICE_PROPERTY_SATURATION, command.getSaturation());
newState.put(DEVICE_PROPERTY_BRIGHTNES, command.getBrightness());
newState.put(DEVICE_PROPERTY_HUE, command.getHue().intValue());
newState.put(DEVICE_PROPERTY_SATURATION, command.getSaturation().intValue());
newState.put(DEVICE_PROPERTY_BRIGHTNES, command.getBrightness().intValue());
connector.sendDeviceCommands(newState);
}

View File

@@ -9,10 +9,16 @@ thing-type.tapocontrol.L510.label = L510 Series White-Bulb
thing-type.tapocontrol.L510.description = Tapo Smart dimmable White-Light-Bulb
thing-type.tapocontrol.L530.label = L530 Series Color-Bulb
thing-type.tapocontrol.L530.description = Tapo Smart Multicolor Light-Bulb
thing-type.tapocontrol.L610.label = L610 Series White-Spot
thing-type.tapocontrol.L610.description = Tapo Smart dimmable White-Light-Spot
thing-type.tapocontrol.L630.label = L630 Series Color-Spot
thing-type.tapocontrol.L630.description = Tapo Smart Multicolor Light-Spot
thing-type.tapocontrol.L900.label = L900 LightStrip
thing-type.tapocontrol.L900.description = Tapo Smart LED-Lightstrip
thing-type.tapocontrol.L920.label = L920 LightStrip
thing-type.tapocontrol.L920.description = Tapo Smart Multicolor LED-Lightstrip
thing-type.tapocontrol.L930.label = L930 LightStrip
thing-type.tapocontrol.L930.description = Tapo Smart Multicolor LED-Lightstrip with ZoneControl
thing-type.tapocontrol.P100.label = P100 SmartPlug
thing-type.tapocontrol.P100.description = Tapo Smart Wifi Plug
thing-type.tapocontrol.P105.label = P105 SmartPlug
@@ -44,6 +50,8 @@ channel-group-type.tapocontrol.colorBulb.label = Color Light Bulb
channel-group-type.tapocontrol.colorBulb.description = Tapo Multicolor Smart Light Bulb
channel-group-type.tapocontrol.deviceState.label = Device State
channel-group-type.tapocontrol.deviceState.description = Information about the device
channel-group-type.tapocontrol.deviceStateS.label = Device State
channel-group-type.tapocontrol.deviceStateS.description = Information about the device
channel-group-type.tapocontrol.energyMonitor.label = Energy Usage
channel-group-type.tapocontrol.energyMonitor.description = Energy and Power usage
channel-group-type.tapocontrol.lightBulb.label = Light Bulb

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="tapocontrol"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<!-- L610 THING-TYPE (WHITE-LIGHT-BULB) -->
<thing-type id="L610">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>L610 Series White-Spot</label>
<description>Tapo Smart dimmable White-Light-Spot</description>
<channel-groups>
<channel-group id="actuator" typeId="lightBulb"/>
<channel-group id="device" typeId="deviceStateS"/>
</channel-groups>
<representation-property>macAddress</representation-property>
<config-description-ref uri="thing-type:tapo:device"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="tapocontrol"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<!-- L630 THING-TYPE (COLOR-LIGHT-BULB) -->
<thing-type id="L630">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>L630 Series Color-Spot</label>
<description>Tapo Smart Multicolor Light-Spot</description>
<channel-groups>
<channel-group id="actuator" typeId="colorBulb"/>
<channel-group id="device" typeId="deviceStateS"/>
</channel-groups>
<representation-property>macAddress</representation-property>
<config-description-ref uri="thing-type:tapo:device"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="tapocontrol"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<!-- L930 THING-TYPE (Multicolor LED-Lightstrip) -->
<thing-type id="L930">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>L930 LightStrip</label>
<description>Tapo Smart Multicolor LED-Lightstrip with ZoneControl</description>
<channel-groups>
<channel-group id="actuator" typeId="lightStrip"/>
<channel-group id="device" typeId="deviceState"/>
</channel-groups>
<representation-property>macAddress</representation-property>
<config-description-ref uri="thing-type:tapo:device"/>
</thing-type>
</thing:thing-descriptions>

View File

@@ -7,7 +7,7 @@
<!-- ############################### CHANNEL-GROUPS ############################### -->
<!-- CHANNEL GROUP TYPES -->
<!--Device-Statuss Channel Type -->
<!--Device-Status Channel Type -->
<channel-group-type id="deviceState">
<label>Device State</label>
<description>Information about the device</description>
@@ -18,6 +18,16 @@
</channels>
</channel-group-type>
<!--Device-Status Channel Type (Small) -->
<channel-group-type id="deviceStateS">
<label>Device State</label>
<description>Information about the device</description>
<channels>
<channel id="wifiSignal" typeId="system.signal-strength"/>
<channel id="overheated" typeId="overheated"/>
</channels>
</channel-group-type>
<!--Actor Channel Type -->
<channel-group-type id="smartPlug">
<label>SmartPlug</label>

View File

@@ -64,7 +64,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th
}
/**
* deactivate
* activate
*/
@Override
public void activate() {

View File

@@ -0,0 +1,107 @@
/**
* Copyright (c) 2010-2022 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.tapocontrol.internal.api;
import static org.openhab.binding.tapocontrol.internal.constants.TapoThingConstants.*;
import java.util.Dictionary;
import java.util.Set;
import javax.jmdns.ServiceInfo;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryService;
import org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
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.Modified;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Handler class for TAPO Smart Home thing discovery over mDNS
*
* @author Christian Wild - Initial contribution
*/
@Component(configurationPid = "discovery.tapocontrol")
@NonNullByDefault
public class TapoMDNS implements MDNSDiscoveryParticipant {
private final Logger logger = LoggerFactory.getLogger(TapoMDNS.class);
private boolean isAutoDiscoveryEnabled = true;
@Activate
protected void activate(ComponentContext componentContext) {
activateOrModifyService(componentContext);
}
@Modified
protected void modified(ComponentContext componentContext) {
activateOrModifyService(componentContext);
}
private void activateOrModifyService(ComponentContext componentContext) {
Dictionary<String, @Nullable Object> properties = componentContext.getProperties();
String autoDiscoveryPropertyValue = (String) properties
.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY);
if (autoDiscoveryPropertyValue != null && !autoDiscoveryPropertyValue.isBlank()) {
isAutoDiscoveryEnabled = Boolean.valueOf(autoDiscoveryPropertyValue);
}
}
@Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
return SUPPORTED_THING_TYPES_UIDS;
}
@Override
public String getServiceType() {
return "NULL";
}
@Override
public @Nullable ThingUID getThingUID(ServiceInfo service) {
ThingTypeUID thingTypeUID = getThingType(service);
if (thingTypeUID != null) {
String id = service.getPropertyString(PROPERTY_FAMILY); // device id
return new ThingUID(thingTypeUID, id);
}
return null;
}
private @Nullable ThingTypeUID getThingType(final ServiceInfo service) {
String model = service.getPropertyString(PROPERTY_FAMILY); // model
logger.debug("found Type: {}", model);
if (model == null) {
return null;
}
return L510_THING_TYPE;
}
@Override
public @Nullable DiscoveryResult createResult(ServiceInfo service) {
if (isAutoDiscoveryEnabled) {
ThingUID uid = getThingUID(service);
if (uid != null) {
String host = service.getHostAddresses()[0];
int port = service.getPort();
logger.debug("device Found: {} {}", host, port);
}
}
return null;
}
}