-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tapocontrol] Add Smart Switches S210 and S220 (#17927)
* Tapo Smart Switches S210 and S220 added Signed-off-by: mkmannmanny <[email protected]> Signed-off-by: Manfred Krämer <[email protected]>
- Loading branch information
1 parent
0e5e48f
commit 2f2cf22
Showing
9 changed files
with
156 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...g/openhab/binding/tapocontrol/internal/devices/rf/smartswitch/TapoSmartSwitchHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* 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.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 contribution | ||
*/ | ||
|
||
@NonNullByDefault | ||
public class TapoSmartSwitchHandler extends TapoChildDeviceHandler { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(TapoSmartSwitchHandler.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 onOffCommand) { | ||
deviceInfo.setDeviceOn(OnOffType.ON.equals(onOffCommand)); | ||
|
||
hub.sendCommandToChild(deviceInfo); | ||
} else { | ||
logger.warn("({}) command type '{}' not supported for channel '{}'", uid, command, channelUID.getId()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/S210.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
21 changes: 21 additions & 0 deletions
21
bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/S220.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |