]> git.basschouten.com Git - openhab-addons.git/blob
462a9640fd2616e4708b2935ae9f56f00885757c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.tplinksmarthome.internal.device;
14
15 import java.io.IOException;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.tplinksmarthome.internal.TPLinkSmartHomeThingType;
20 import org.openhab.binding.tplinksmarthome.internal.model.HasErrorResponse;
21 import org.openhab.core.library.types.HSBType;
22 import org.openhab.core.library.types.OnOffType;
23
24 /**
25  * TP-Link Smart Home Light Strip.
26  *
27  * @author Hilbrand Bouwkamp - Initial contribution
28  */
29 @NonNullByDefault
30 public class LightStripDevice extends BulbDevice {
31
32     public LightStripDevice(final TPLinkSmartHomeThingType type) {
33         super(type);
34     }
35
36     @Override
37     protected @Nullable HasErrorResponse handleOnOffType(final String channelID, final OnOffType onOff,
38             final int transitionPeriod) throws IOException {
39         return commands.setLightStripStateResponse(
40                 connection.sendCommand(commands.setLightStripState(onOff, transitionPeriod)));
41     }
42
43     @Override
44     protected @Nullable HasErrorResponse handleBrightness(final int brightness, final int transitionPeriod)
45             throws IOException {
46         return commands.setLightStripStateResponse(
47                 connection.sendCommand(commands.setLightStripBrightness(brightness, transitionPeriod)));
48     }
49
50     @Override
51     protected @Nullable HasErrorResponse handleColorTemperature(final int colorTemperature, final int transitionPeriod)
52             throws IOException {
53         return commands.setLightStripStateResponse(
54                 connection.sendCommand(commands.setLightStripColorTemperature(colorTemperature, transitionPeriod)));
55     }
56
57     @Override
58     protected @Nullable HasErrorResponse handleHSBType(final String channelID, final HSBType command,
59             final int transitionPeriod) throws IOException {
60         return commands.setLightStripStateResponse(
61                 connection.sendCommand(commands.setLightStripColor(command, transitionPeriod)));
62     }
63 }