Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tapocontrol] Add Smart Switches S210 and S220 #17927

Merged
merged 98 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
ce07972
Tapo Smart Switches S210 and S220 added
mkmannmanny Dec 19, 2024
f920f74
Correct version of binding in POM
mkmannmanny Dec 19, 2024
bd0a0f6
Clean Format errors
mkmannmanny Dec 19, 2024
b139ac9
Logger in TapoSmartSwitchHandler wrong
mkmannmanny Dec 19, 2024
5a6f1b9
Simplify DateTimeType handling for aha Waste Collection
jlaur Dec 10, 2024
fdd4799
Simplify DateTimeType handling for Air Quality
jlaur Dec 10, 2024
1c5940f
Simplify DateTimeType handling for Automower
jlaur Nov 9, 2024
495c168
Simplify DateTimeType handling for AVM FRITZ!
jlaur Dec 10, 2024
1872165
Simplify DateTimeType handling for aWATTar
jlaur Nov 11, 2024
50bb6ca
Simplify DateTimeType handling for BigAssFan
jlaur Nov 30, 2024
3efbe50
Simplify DateTimeType handling for Bosch Indego
jlaur Nov 27, 2024
cd52c03
Simplify DateTimeType handling for Bosch Smart Home
jlaur Nov 28, 2024
72f396a
Simplify DateTimeType handling for Broadlink
jlaur Nov 16, 2024
93ae3f4
Simplify DateTimeType handling for DBQuery
jlaur Dec 9, 2024
77ee6cb
Simplify DateTimeType handling for deCONZ
jlaur Nov 9, 2024
85f5675
Simplify DateTimeType handling for Deutsche Bahn
jlaur Dec 10, 2024
771a8c2
Simplify DateTimeType handling for Digiplex/EVO
jlaur Dec 9, 2024
714e269
Simplify DateTimeType handling for Doorbird
jlaur Dec 9, 2024
51ba4cd
Simplify DateTimeType handling for DWD Pollenflug
jlaur Dec 10, 2024
6e2b757
Simplify DateTimeType handling for DWD Unwetter
jlaur Nov 14, 2024
5502390
Simplify DateTimeType handling for Ecobee
jlaur Nov 27, 2024
dc3f3ba
Simplify DateTimeType handling for Ecovacs
jlaur Nov 10, 2024
a389d7e
Simplify DateTimeType handling for Enphase
jlaur Dec 9, 2024
4f20223
Simplify DateTimeType handling for EVCC
jlaur Nov 19, 2024
e3e1606
Simplify DateTimeType handling for Exec
jlaur Nov 25, 2024
98db641
Simplify DateTimeType handling for Feed
jlaur Dec 10, 2024
488133d
Simplify DateTimeType handling for Fine Offset Weather Station
jlaur Nov 17, 2024
46297bf
Simplify DateTimeType handling for Flume
jlaur Nov 9, 2024
84a37b9
Simplify DateTimeType handling for FMI Weather
jlaur Nov 25, 2024
ba76d38
Simplify DateTimeType handling for Foobot
jlaur Dec 10, 2024
766eaee
Simplify DateTimeType handling for FreeboxOS
jlaur Nov 25, 2024
dde77fd
Simplify DateTimeType handling for Freecurrency
jlaur Dec 17, 2024
b8ff957
Simplify DateTimeType handling for Gardena
jlaur Dec 10, 2024
7090c7f
Simplify DateTimeType handling for Groupe PSA
jlaur Nov 9, 2024
05719ed
Simplify DateTimeType handling for Helios easyControls
jlaur Nov 17, 2024
992b951
Simplify DateTimeType handling for Philips Hue
jlaur Nov 27, 2024
2662545
Simplify DateTimeType handling for Hydrawise
jlaur Nov 17, 2024
85eb3dc
Simplify DateTimeType handling for IHC
jlaur Nov 9, 2024
741c8bb
Simplify DateTimeType handling for Insteon
jlaur Nov 15, 2024
17330fb
Simplify DateTimeType handling for JuiceNet
jlaur Nov 9, 2024
6775932
Simplify DateTimeType handling for KM200
jlaur Nov 17, 2024
65b99e1
Simplify DateTimeType handling for LaMetric
jlaur Nov 17, 2024
7a1f6c6
Simplify DateTimeType handling for Lutron
jlaur Nov 17, 2024
7261f56
Simplify DateTimeType handling for LuxtronikHeatpump
jlaur Nov 28, 2024
ea53ec3
Simplify DateTimeType handling for Meater
jlaur Nov 25, 2024
4d20f1d
Simplify DateTimeType handling for Mercedes Me
jlaur Nov 19, 2024
5922edb
Simplify DateTimeType handling for Met Office DataHub
jlaur Nov 25, 2024
ec9809d
Simplify DateTimeType handling for Meteo France
jlaur Dec 16, 2024
e75f387
Simplify DateTimeType handling for Mi IO
jlaur Nov 9, 2024
43f6580
Simplify DateTimeType handling for Millheat
jlaur Nov 15, 2024
ea3356c
Simplify DateTimeType handling for MQTT
jlaur Nov 19, 2024
c409e34
Simplify DateTimeType handling for Ruuvi Gateway MQTT
jlaur Nov 24, 2024
20c3103
Simplify DateTimeType handling for Network
jlaur Nov 9, 2024
502f8a7
Simplify DateTimeType handling for Nest
jlaur Nov 16, 2024
bbc8bb3
Simplify DateTimeType handling for OJElectronics
jlaur Nov 17, 2024
f9ed34a
Simplify DateTimeType handling for OneBusAway
jlaur Nov 28, 2024
2efa8d4
Simplify DateTimeType handling for OpenUV
jlaur Nov 18, 2024
d619f47
Simplify DateTimeType handling for OpenWeatherMap
jlaur Nov 26, 2024
f6119cb
Simplify DateTimeType handling for PLCLogo
jlaur Nov 18, 2024
0e2ec68
Simplify DateTimeType handling for SAICiSMART
jlaur Nov 9, 2024
5164913
Simplify DateTimeType handling for Satel Integra Alarm System
jlaur Nov 18, 2024
ea3d04a
Simplify DateTimeType handling for Shelly
jlaur Nov 15, 2024
46bb39d
Simplify DateTimeType handling for Siemens HVAC
jlaur Nov 10, 2024
72f3ab4
Simplify DateTimeType handling for Solax
jlaur Nov 24, 2024
2b06e56
Simplify DateTimeType handling for Philips Somneo
jlaur Nov 19, 2024
a2be9b7
Simplify DateTimeType handling for TA C.M.I.
jlaur Nov 18, 2024
eccd927
Simplify DateTimeType handling for Tado
jlaur Nov 9, 2024
0927c9f
Simplify DateTimeType handling for Teleinfo
jlaur Nov 18, 2024
a9c0a27
Simplify DateTimeType handling for Tellstick
jlaur Nov 27, 2024
74277f8
Simplify DateTimeType handling for UniFi
jlaur Nov 26, 2024
1adcc5f
Simplify DateTimeType handling for Vallox MV
jlaur Nov 9, 2024
31217dc
Simplify DateTimeType handling for VeSync
jlaur Nov 25, 2024
c4cba6b
Simplify DateTimeType handling for Video Disk Recorder
jlaur Nov 10, 2024
ebd2d0d
Simplify DateTimeType handling for VisualCrossing
jlaur Dec 10, 2024
4d5f147
Simplify DateTimeType handling for VolvoOnCall
jlaur Nov 26, 2024
f65ccf3
Simplify DateTimeType handling for WeatherUnderground
jlaur Dec 16, 2024
d0f023d
Simplify DateTimeType handling for WeMo
jlaur Nov 9, 2024
2b818ca
Simplify DateTimeType handling for WiZ
jlaur Dec 17, 2024
d2ad72a
Simplify DateTimeType handling for Wolf Smartset
jlaur Dec 9, 2024
05456e9
Simplify DateTimeType handling for XmlTv
jlaur Dec 17, 2024
d616d5b
Simplify DateTimeType handling for ZoneMinder
jlaur Nov 27, 2024
01372a6
Simplify DateTimeType handling for Amazon DynamoDB
jlaur Nov 9, 2024
e698e64
Simplify DateTimeType handling for InfluxDB
jlaur Nov 9, 2024
b5a8023
Simplify DateTimeType handling for Java Persistence API
jlaur Nov 18, 2024
e3d0575
Simplify DateTimeType handling for JDBC
jlaur Nov 14, 2024
c8cbd03
Simplify DateTimeType handling for MongoDB
jlaur Nov 19, 2024
6cbefb4
[roku] Check for ECP Limited Mode (#17925)
mlobstein Dec 19, 2024
ef269dc
[insteon] Use shared jetty http client (#17922)
jsetton Dec 19, 2024
5498d75
Use switch pattern matching
jlaur Dec 16, 2024
2cb66e0
Update readme with smart switches
mkmannmanny Dec 20, 2024
49b9025
Merge branch 'openhab:main' into main
mkmannmanny Dec 20, 2024
2ba047a
Merge remote-tracking branch 'origin/main' into main
mkmannmanny Dec 21, 2024
0d1cb0b
Merge remote-tracking branch 'origin/main' into main
mkmannmanny Dec 24, 2024
4a69ea0
Update bundles/org.openhab.binding.tapocontrol/src/main/java/org/open…
mkmannmanny Dec 25, 2024
86a8af6
Update bundles/org.openhab.binding.tapocontrol/README.md
mkmannmanny Dec 25, 2024
2bd3485
Merge branch 'openhab:main' into main
mkmannmanny Dec 25, 2024
81bfd4b
Merge remote-tracking branch 'origin/main' into main
mkmannmanny Dec 25, 2024
1583814
Resolve rewiew comments from Isiepel
mkmannmanny Dec 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Tapo Smart Switches S210 and S220 added
Signed-off-by: mkmannmanny <mk@die5kraemers.de>
  • Loading branch information
mkmannmanny committed Dec 19, 2024
commit ce07972094cfa73da602a4c0b408e2be7cebbbc6
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.tapocontrol/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>4.3.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.tapocontrol</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.openhab.binding.tapocontrol.internal.devices.bridge.TapoBridgeHandler;
import org.openhab.binding.tapocontrol.internal.devices.rf.smartcontact.TapoSmartContactHandler;
import org.openhab.binding.tapocontrol.internal.devices.rf.smartswitch.TapoSmartSwitchHandler;
import org.openhab.binding.tapocontrol.internal.devices.rf.weathersensor.TapoWeatherSensorHandler;
import org.openhab.binding.tapocontrol.internal.devices.wifi.TapoUniversalDeviceHandler;
import org.openhab.binding.tapocontrol.internal.devices.wifi.bulb.TapoBulbHandler;
Expand Down Expand Up @@ -130,6 +131,8 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return new TapoSmartContactHandler(thing);
} else if (SUPPORTED_WEATHER_SENSORS.contains(thingTypeUID)) {
return new TapoWeatherSensorHandler(thing);
} else if (SUPPORTED_SMART_SWITCHES.contains(thingTypeUID)) {
return new TapoSmartSwitchHandler(thing);
} else if (thingTypeUID.equals(UNIVERSAL_THING_TYPE)) {
return new TapoUniversalDeviceHandler(thing);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class TapoThingConstants {
public static final String DEVICE_T110 = "T110";
public static final String DEVICE_T310 = "T310";
public static final String DEVICE_T315 = "T315";
public static final String DEVICE_S210 = "S210";
public static final String DEVICE_S220 = "S220";
public static final String DEVICE_UNIVERSAL = "Test_Device";

/*** LIST OF SUPPORTED DEVICE DESCRIPTIONS ***/
Expand All @@ -63,6 +65,7 @@ public class TapoThingConstants {
public static final String DEVICE_DESCRIPTION_SMART_CONTACT = "Smart-Contact-Sensor";
public static final String DEVICE_DESCRIPTION_MOTION_SENSOR = "Motion-Sensor";
public static final String DEVICE_DESCRIPTION_TEMP_SENSOR = "Temperature-Sensor";
public static final String DEVICE_DESCRIPTION_SMART_SWITCH = "Smart Switch";
lsiepel marked this conversation as resolved.
Show resolved Hide resolved

/*** LIST OF SUPPORTED THING UIDS ***/
public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_BRIDGE);
Expand All @@ -85,6 +88,8 @@ public class TapoThingConstants {
public static final ThingTypeUID T110_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_T110);
public static final ThingTypeUID T310_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_T310);
public static final ThingTypeUID T315_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_T315);
public static final ThingTypeUID S210_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_S210);
public static final ThingTypeUID S220_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_S220);

/*** SET OF SUPPORTED UIDS ***/
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_UIDS = Set.of(BRIDGE_THING_TYPE);
Expand All @@ -97,27 +102,28 @@ public class TapoThingConstants {
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_HUB_CHILD_TYPES_UIDS = Set.of(T110_THING_TYPE, T310_THING_TYPE,
T315_THING_TYPE);
T315_THING_TYPE, S210_THING_TYPE, S220_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_SMART_CONTACTS = Set.of(T110_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_MOTION_SENSORS = Set.of();
public static final Set<ThingTypeUID> SUPPORTED_WEATHER_SENSORS = Set.of(T310_THING_TYPE, T315_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_SMART_SWITCHES = Set.of(S210_THING_TYPE, S220_THING_TYPE);

/*** SET OF ALL SUPPORTED THINGS ***/
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(Stream
.of(SUPPORTED_BRIDGE_UIDS, SUPPORTED_HUB_UIDS, SUPPORTED_SOCKET_UIDS, SUPPORTED_SOCKET_STRIP_UIDS,
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
Stream.of(SUPPORTED_BRIDGE_UIDS, SUPPORTED_HUB_UIDS, SUPPORTED_SOCKET_UIDS, SUPPORTED_SOCKET_STRIP_UIDS,
SUPPORTED_WHITE_BULB_UIDS, SUPPORTED_COLOR_BULB_UIDS, SUPPORTED_LIGHT_STRIP_UIDS,
SUPPORTED_SMART_CONTACTS, SUPPORTED_MOTION_SENSORS, SUPPORTED_WEATHER_SENSORS)
.flatMap(Set::stream).collect(Collectors.toSet()));
SUPPORTED_SMART_CONTACTS, SUPPORTED_MOTION_SENSORS, SUPPORTED_WEATHER_SENSORS,
SUPPORTED_SMART_SWITCHES).flatMap(Set::stream).collect(Collectors.toSet()));

/*** THINGS WITH ENERGY DATA ***/
public static final Set<ThingTypeUID> SUPPORTED_ENERGY_DATA_UIDS = Set.of(P110_THING_TYPE, P115_THING_TYPE);

/*** THINGS WITH CHANNEL GROUPS ***/
public static final Set<ThingTypeUID> CHANNEL_GROUP_THING_SET = Collections.unmodifiableSet(Stream
.of(SUPPORTED_BRIDGE_UIDS, SUPPORTED_HUB_UIDS, SUPPORTED_SOCKET_UIDS, SUPPORTED_SOCKET_STRIP_UIDS,
public static final Set<ThingTypeUID> CHANNEL_GROUP_THING_SET = Collections.unmodifiableSet(
Stream.of(SUPPORTED_BRIDGE_UIDS, SUPPORTED_HUB_UIDS, SUPPORTED_SOCKET_UIDS, SUPPORTED_SOCKET_STRIP_UIDS,
SUPPORTED_WHITE_BULB_UIDS, SUPPORTED_COLOR_BULB_UIDS, SUPPORTED_LIGHT_STRIP_UIDS,
SUPPORTED_SMART_CONTACTS, SUPPORTED_MOTION_SENSORS, SUPPORTED_WEATHER_SENSORS)
.flatMap(Set::stream).collect(Collectors.toSet()));
SUPPORTED_SMART_CONTACTS, SUPPORTED_MOTION_SENSORS, SUPPORTED_WEATHER_SENSORS,
SUPPORTED_SMART_SWITCHES).flatMap(Set::stream).collect(Collectors.toSet()));

public static final String CHILD_REPRESENTATION_PROPERTY = "serialNumber";

Expand Down Expand Up @@ -177,4 +183,4 @@ public class TapoThingConstants {
public static final String EVENT_STATE_BATTERY_LOW = "batteryLow";
public static final String EVENT_STATE_OPENED = "open";
public static final String EVENT_STATE_CLOSED = "closed";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
package org.openhab.binding.tapocontrol.internal.devices.rf;

import static org.openhab.binding.tapocontrol.internal.constants.TapoErrorCode.*;
import static org.openhab.binding.tapocontrol.internal.constants.TapoErrorCode.ERR_CONFIG_NO_BRIDGE;
import static org.openhab.binding.tapocontrol.internal.constants.TapoThingConstants.*;
import static org.openhab.binding.tapocontrol.internal.helpers.utils.TapoUtils.*;
import static org.openhab.binding.tapocontrol.internal.helpers.utils.TapoUtils.getValueOrDefault;
import static org.openhab.binding.tapocontrol.internal.helpers.utils.TypeUtils.*;

import java.util.HashMap;
Expand Down Expand Up @@ -48,7 +48,7 @@ public abstract class TapoChildDeviceHandler extends BaseThingHandler {
protected final String uid;
protected final String deviceId;
protected @NonNullByDefault({}) TapoHubHandler hub;
private TapoChildDeviceData deviceInfo = new TapoChildDeviceData();
protected TapoChildDeviceData deviceInfo = new TapoChildDeviceData();
private Map<String, Object> oldStates = new HashMap<>();

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/**
* 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.tapocontrol.internal.devices.rf.smartswitch;

import static org.openhab.binding.tapocontrol.internal.constants.TapoThingConstants.*;
import static org.openhab.binding.tapocontrol.internal.helpers.utils.TypeUtils.getOnOffType;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.tapocontrol.internal.devices.dto.TapoChildDeviceData;
import org.openhab.binding.tapocontrol.internal.devices.rf.TapoChildDeviceHandler;
import org.openhab.binding.tapocontrol.internal.devices.rf.smartcontact.TapoSmartContactHandler;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* TAPO Smart-Contact-Device.
*
* @author Manfred Krämer - Initial contributio * Copyright (c) 2010-2024 Contributors to the openHAB project
*/
package org.openhab.binding.tapocontrol.internal.devices.rf.smartswitch;

import static org.openhab.binding.tapocontrol.internal.constants.TapoThingConstants.*;

/**
* TAPO Smart-Contact-Device.
*
* @author Manfred Krämer - Initial contribution
*/

@NonNullByDefault
public class TapoSmartSwitchHandler extends TapoChildDeviceHandler {

private final Logger logger = LoggerFactory.getLogger(TapoSmartContactHandler.class);

/**
* Constructor
*
* @param thing Thing object representing device
*/
public TapoSmartSwitchHandler(Thing thing) {
super(thing);
}

/**
* Update properties
*/
@Override
protected void devicePropertiesChanged(TapoChildDeviceData deviceInfo) {
super.devicePropertiesChanged(deviceInfo);
updateState(getChannelID(CHANNEL_GROUP_ACTUATOR, CHANNEL_OUTPUT), getOnOffType(deviceInfo.isOn()));
}

/**
* handle command sent to device
*
* @param channelUID channelUID command is sent to
* @param command command to be sent
*/
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
/* perform actions */
if (command instanceof RefreshType) {
setDeviceData();
} else if (command instanceof OnOffType) {
if (command == OnOffType.ON) {
deviceInfo.setDeviceOn(true);
} else {
deviceInfo.setDeviceOn(false);
}

hub.sendCommandToChild(deviceInfo);
} else {
logger.warn("({}) command type '{}' not supported for channel '{}'", uid, command, channelUID.getId());
}
}
}

@NonNullByDefault
public class TapoSmartSwitchHandler extends TapoChildDeviceHandler {

private final Logger logger = LoggerFactory.getLogger(TapoSmartContactHandler.class);

/**
* Constructor
*
* @param thing Thing object representing device
*/
public TapoSmartSwitchHandler(Thing thing) {
super(thing);
}

/**
* Update properties
*/
@Override
protected void devicePropertiesChanged(TapoChildDeviceData deviceInfo) {
super.devicePropertiesChanged(deviceInfo);
updateState(getChannelID(CHANNEL_GROUP_ACTUATOR, CHANNEL_OUTPUT), getOnOffType(deviceInfo.isOn()));
}

/**
* handle command sent to device
*
* @param channelUID channelUID command is sent to
* @param command command to be sent
*/
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
/* perform actions */
if (command instanceof RefreshType) {
setDeviceData();
} else if (command instanceof OnOffType) {
if (command == OnOffType.ON) {
deviceInfo.setDeviceOn(true);
} else {
deviceInfo.setDeviceOn(false);
}
mkmannmanny marked this conversation as resolved.
Show resolved Hide resolved

hub.sendCommandToChild(deviceInfo);
} else {
logger.warn("({}) command type '{}' not supported for channel '{}'", uid, command, channelUID.getId());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public Collection<Class<? extends ThingHandlerService>> getServices() {

/**
* Set DiscoveryService
*
*
* @param discoveryService
*/
public void setDiscoveryService(TapoChildDiscoveryService discoveryService) {
Expand Down Expand Up @@ -140,7 +140,7 @@ public void queryDeviceData() {
/**
* Function called by {@link org.openhab.binding.tapocontrol.internal.api.TapoDeviceConnector} if new data were
* received
*
*
* @param queryCommand command where new data belong to
*/
@Override
Expand All @@ -165,6 +165,13 @@ public void newDataResult(String queryCommand) {
* CHILD THINGS
****************************/

/****************************
* Send Command to Child
*/
public void sendCommandToChild(TapoChildDeviceData childData) {
connector.sendChildCommand(childData, false);
}

/**
* Update all Child-Things
*/
Expand Down Expand Up @@ -276,7 +283,7 @@ public List<TapoChildDeviceData> getChildDevices() {

public TapoChildDeviceData getChild(String deviceSerial) {
List<TapoChildDeviceData> childDeviceList = tapoChildsList.getChildDeviceList();
for (int i = 0; i <= childDeviceList.size(); i++) {
for (int i = 0; i < childDeviceList.size(); i++) {
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
TapoChildDeviceData child = childDeviceList.get(i);
if (child.getDeviceId().equals(deviceSerial)) {
return child;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import static org.openhab.binding.tapocontrol.internal.constants.TapoBindingSettings.*;
import static org.openhab.binding.tapocontrol.internal.constants.TapoThingConstants.*;
import static org.openhab.binding.tapocontrol.internal.helpers.utils.TapoUtils.*;
import static org.openhab.binding.tapocontrol.internal.helpers.utils.TapoUtils.formatMac;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class TapoChildDiscoveryService extends AbstractDiscoveryService implemen

/**
* INIT CLASS
*
*
*/
public TapoChildDiscoveryService() {
super(SUPPORTED_HUB_CHILD_TYPES_UIDS, TAPO_DISCOVERY_TIMEOUT_S, false);
Expand Down Expand Up @@ -195,6 +195,8 @@ protected String getDeviceLabel(TapoChildDeviceData child) {
deviceLabel = DEVICE_DESCRIPTION_SMART_CONTACT;
} else if (SUPPORTED_MOTION_SENSORS.contains(deviceUID)) {
deviceLabel = DEVICE_DESCRIPTION_MOTION_SENSOR;
} else if (SUPPORTED_SMART_SWITCHES.contains(deviceUID)) {
deviceLabel = DEVICE_DESCRIPTION_SMART_SWITCH;
}
return DEVICE_VENDOR + " " + deviceModel + " " + deviceLabel;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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">

<!--S210 THING-TYPE (SMART SWITCH) -->
<thing-type id="S210">
<supported-bridge-type-refs>
<bridge-type-ref id="H100"/>
</supported-bridge-type-refs>

<label>S210 Smart Switch</label>
<description>Tapo Smart Switch</description>
<channel-groups>
<channel-group id="actuator" typeId="smartPlug"/>
<channel-group id="device" typeId="childDeviceState"/>
</channel-groups>
<representation-property>serialNumber</representation-property>
</thing-type>
</thing:thing-descriptions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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">

<!--S220 THING-TYPE (SMART SWITCH) -->
<thing-type id="S220">
<supported-bridge-type-refs>
<bridge-type-ref id="H100"/>
</supported-bridge-type-refs>

<label>S220 Smart Switch</label>
<description>Tapo Smart Switch</description>
<channel-groups>
<channel-group id="actuator" typeId="smartPlug"/>
<channel-group id="device" typeId="childDeviceState"/>
</channel-groups>
<representation-property>serialNumber</representation-property>
</thing-type>
</thing:thing-descriptions>
Loading