From 983efd76ea5992afe1b16a38f41d816247f759b9 Mon Sep 17 00:00:00 2001 From: Christian Wild <40909464+wildcs@users.noreply.github.com> Date: Fri, 24 Mar 2023 21:57:00 +0100 Subject: [PATCH] [tapocontrol] Support display light effects for L530 (#14596) * [tapocontrol] support display light effects for L530 color change is now possible if effect was already enabled by app Signed-off-by: Christian Wild --- .../org.openhab.binding.tapocontrol/README.md | 29 ++--- .../internal/TapoDiscoveryService.java | 10 +- .../internal/api/TapoDeviceConnector.java | 57 +++++---- .../constants/TapoThingConstants.java | 114 +++++++++--------- .../internal/device/TapoLightStrip.java | 39 +++--- .../internal/device/TapoSmartBulb.java | 58 +++++++-- .../internal/device/TapoSmartPlug.java | 4 +- .../internal/device/TapoUniversalDevice.java | 20 +-- .../internal/structures/TapoDeviceInfo.java | 44 +++---- .../internal/structures/TapoEnergyData.java | 12 +- .../internal/structures/TapoLightEffect.java | 43 ++++--- .../OH-INF/i18n/tapocontrol.properties | 74 ++++++++++-- .../src/main/resources/OH-INF/thing/L530.xml | 25 ++++ .../src/main/resources/OH-INF/thing/L920.xml | 43 +++++++ .../src/main/resources/OH-INF/thing/L930.xml | 43 +++++++ .../main/resources/OH-INF/thing/channels.xml | 46 ------- .../internal/TapoDiscoveryService.java | 10 +- .../internal/device/TapoUniversalDevice.java | 20 +-- .../internal/structures/TapoDeviceInfo.java | 42 +++---- .../internal/structures/TapoLightEffect.java | 12 +- 20 files changed, 456 insertions(+), 289 deletions(-) diff --git a/bundles/org.openhab.binding.tapocontrol/README.md b/bundles/org.openhab.binding.tapocontrol/README.md index 640285fcb..dde816d52 100644 --- a/bundles/org.openhab.binding.tapocontrol/README.md +++ b/bundles/org.openhab.binding.tapocontrol/README.md @@ -64,20 +64,21 @@ The thing has the following configuration parameters: All devices support some of the following channels: -| group | channel | type | description | things supporting this channel | -|-----------|----------------- |------------------------|------------------------------|------------------------------------------------------------------| -| actuator | output | Switch | Power device on or off | P100, P105, P110, P115, L510, L530, L610, L630, L900, L920, L930 | -| | output1 | Switch | Power socket 1 on or off | P300 | -| | output2 | Switch | Power socket 2 on or off | P300 | -| | output3 | Switch | Power socket 3 on or off | P300 | -| | brightness | Dimmer | Brightness 0-100% | L510, L530, L610, L630, L900 | -| | colorTemperature | Number | White-Color-Temp 2500-6500K | L510, L530, L610, L630, L900 | -| | color | Color | Color | L530, L630, L900 | -| device | wifiSignal | Number | WiFi-quality-level | P100, P105, P110, P115, L510, L530, L610, L630, L900, L920, L930 | -| | onTime | Number:Time | seconds output is on | P100, P105, P110, P115, L510, L530, L900, L920, L930 | -| energy | actualPower | Number:Power | actual Power (Watt) | P110, P115 | -| | todayEnergyUsage | Number:Energy | used energy today (Wh) | P110, P115 | -| | todayRuntime | Number:Time | seconds output was on today | P110, P115 | +| group | channel | type | description | things supporting this channel | +|-----------|----------------- |------------------------|-------------------------------------|------------------------------------------------------------------| +| actuator | output | Switch | Power device on or off | P100, P105, P110, P115, L510, L530, L610, L630, L900, L920, L930 | +| | output1 | Switch | Power socket 1 on or off | P300 | +| | output2 | Switch | Power socket 2 on or off | P300 | +| | output3 | Switch | Power socket 3 on or off | P300 | +| | brightness | Dimmer | Brightness 0-100% | L510, L530, L610, L630, L900 | +| | colorTemperature | Number | White-Color-Temp 2500-6500K | L510, L530, L610, L630, L900 | +| | color | Color | Color | L530, L630, L900 | +| effects | fxName | String | Active lightning effect (readonly) | L530 | +| device | wifiSignal | Number | WiFi-quality-level | P100, P105, P110, P115, L510, L530, L610, L630, L900, L920, L930 | +| | onTime | Number:Time | seconds output is on | P100, P105, P110, P115, L510, L530, L900, L920, L930 | +| energy | actualPower | Number:Power | actual Power (Watt) | P110, P115 | +| | todayEnergyUsage | Number:Energy | used energy today (Wh) | P110, P115 | +| | todayRuntime | Number:Time | seconds output was on today | P110, P115 | ## Channel Refresh diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java index 262df7099..d0284ad31 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java @@ -131,17 +131,17 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th TapoBridgeHandler tapoBridge = this.bridge; String deviceModel = getDeviceModel(device); String label = getDeviceLabel(device); - String deviceMAC = device.get(CLOUD_PROPERTY_MAC).getAsString(); + String deviceMAC = device.get(CLOUD_JSON_KEY_MAC).getAsString(); ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, deviceModel); /* create properties */ Map properties = new HashMap<>(); properties.put(Thing.PROPERTY_VENDOR, DEVICE_VENDOR); properties.put(Thing.PROPERTY_MAC_ADDRESS, formatMac(deviceMAC, MAC_DIVISION_CHAR)); - properties.put(Thing.PROPERTY_FIRMWARE_VERSION, device.get(CLOUD_PROPERTY_FW).getAsString()); - properties.put(Thing.PROPERTY_HARDWARE_VERSION, device.get(CLOUD_PROPERTY_HW).getAsString()); + properties.put(Thing.PROPERTY_FIRMWARE_VERSION, device.get(CLOUD_JSON_KEY_FW).getAsString()); + properties.put(Thing.PROPERTY_HARDWARE_VERSION, device.get(CLOUD_JSON_KEY_HW).getAsString()); properties.put(Thing.PROPERTY_MODEL_ID, deviceModel); - properties.put(Thing.PROPERTY_SERIAL_NUMBER, device.get(CLOUD_PROPERTY_ID).getAsString()); + properties.put(Thing.PROPERTY_SERIAL_NUMBER, device.get(CLOUD_JSON_KEY_ID).getAsString()); logger.debug("device {} discovered", deviceModel); if (tapoBridge != null) { @@ -190,7 +190,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th */ protected String getDeviceModel(JsonObject device) { try { - String deviceModel = device.get(CLOUD_PROPERTY_MODEL).getAsString(); + String deviceModel = device.get(CLOUD_JSON_KEY_MODEL).getAsString(); deviceModel = deviceModel.replaceAll("\\(.*\\)", ""); // replace (DE) deviceModel = deviceModel.replace("Tapo", ""); deviceModel = deviceModel.replace("Series", ""); diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/api/TapoDeviceConnector.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/api/TapoDeviceConnector.java index c1c992338..56bb3d1f1 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/api/TapoDeviceConnector.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/api/TapoDeviceConnector.java @@ -214,23 +214,12 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi { /** * Query Info from Device and refresh deviceInfo * + * * @param ignoreGap ignore gap to last query. query anyway */ public void queryInfo(boolean ignoreGap) { logger.trace("({}) DeviceConnetor_queryInfo from '{}'", uid, deviceURL); - long now = System.currentTimeMillis(); - if (ignoreGap || now > this.lastQuery + TAPO_SEND_MIN_GAP_MS) { - this.lastQuery = now; - - /* create payload */ - PayloadBuilder plBuilder = new PayloadBuilder(); - plBuilder.method = DEVICE_CMD_GETINFO; - String payload = plBuilder.getPayload(); - - sendSecurePasstrhroug(payload, DEVICE_CMD_GETINFO); - } else { - logger.debug("({}) command not sent becauso of min_gap: {}", uid, now + " <- " + lastQuery); - } + queryCommand(DEVICE_CMD_GETINFO, ignoreGap); } /** @@ -239,27 +228,37 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi { @Override public void queryChildDevices() { logger.trace("({}) DeviceConnetor_queryChildDevices from '{}'", uid, deviceURL); - - /* create payload */ - PayloadBuilder plBuilder = new PayloadBuilder(); - plBuilder.method = DEVICE_CMD_CHILD_DEVICE_LIST; - String payload = plBuilder.getPayload(); - - sendSecurePasstrhroug(payload, DEVICE_CMD_CHILD_DEVICE_LIST); + queryCommand(DEVICE_CMD_CHILD_DEVICE_LIST, false); } /** * Get energy usage from device */ public void getEnergyUsage() { - logger.trace("({}) DeviceConnetor_getEnergyUsage from '{}'", uid, deviceURL); + queryCommand(DEVICE_CMD_GETENERGY, true); + } - /* create payload */ - PayloadBuilder plBuilder = new PayloadBuilder(); - plBuilder.method = DEVICE_CMD_GETENERGY; - String payload = plBuilder.getPayload(); + /** + * Send Custom DeviceQuery + * + * @param queryCommand Command to be queried + * @param ignoreGap ignore gap to last query. query anyway + */ + public void queryCommand(String queryCommand, boolean ignoreGap) { + logger.trace("({}) DeviceConnetor_queryCommand '{}' from '{}'", uid, queryCommand, deviceURL); + long now = System.currentTimeMillis(); + if (ignoreGap || now > this.lastQuery + TAPO_SEND_MIN_GAP_MS) { + this.lastQuery = now; - sendSecurePasstrhroug(payload, DEVICE_CMD_GETENERGY); + /* create payload */ + PayloadBuilder plBuilder = new PayloadBuilder(); + plBuilder.method = queryCommand; + String payload = plBuilder.getPayload(); + + sendSecurePasstrhroug(payload, queryCommand); + } else { + logger.debug("({}) command not sent because of min_gap: {}", uid, now + " <- " + lastQuery); + } } /** @@ -314,7 +313,7 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi { @Override protected void handleDeviceResult(String responseBody) { JsonObject jsnResult = getJsonFromResponse(responseBody); - if (jsnResult.has(DEVICE_PROPERTY_ID)) { + if (jsnResult.has(JSON_KEY_ID)) { this.deviceInfo = new TapoDeviceInfo(jsnResult); this.device.setDeviceInfo(deviceInfo); } else { @@ -332,7 +331,7 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi { @Override protected void handleEnergyResult(String responseBody) { JsonObject jsnResult = getJsonFromResponse(responseBody); - if (jsnResult.has(ENERGY_PROPERTY_POWER)) { + if (jsnResult.has(JSON_KEY_ENERGY_POWER)) { this.energyData = new TapoEnergyData(jsnResult); this.device.setEnergyData(energyData); } else { @@ -349,7 +348,7 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi { @Override protected void handleChildDevices(String responseBody) { JsonObject jsnResult = getJsonFromResponse(responseBody); - if (jsnResult.has(CHILD_PROPERTY_START_INDEX)) { + if (jsnResult.has(JSON_KEY_CHILD_START_INDEX)) { this.childData = Objects.requireNonNull(GSON.fromJson(jsnResult, TapoChildData.class)); this.device.setChildData(childData); } else { diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/constants/TapoThingConstants.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/constants/TapoThingConstants.java index d10f51cef..a97b9aebb 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/constants/TapoThingConstants.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/constants/TapoThingConstants.java @@ -98,62 +98,64 @@ public class TapoThingConstants { SUPPORTED_COLOR_BULB_UIDS, SUPPORTED_LIGHT_STRIP_UIDS) .flatMap(Set::stream).collect(Collectors.toSet())); - /*** DEVICE PROPERTY STRINGS (CLOUD) ***/ - public static final String CLOUD_PROPERTY_ALIAS = "alias"; - public static final String CLOUD_PROPERTY_FW = "fwVer"; - public static final String CLOUD_PROPERTY_HW = "deviceHwVer"; - public static final String CLOUD_PROPERTY_ID = "deviceId"; - public static final String CLOUD_PROPERTY_MAC = "deviceMac"; - public static final String CLOUD_PROPERTY_MODEL = "deviceName"; // use name cause modell returns different values - public static final String CLOUD_PROPERTY_NAME = "deviceName"; - public static final String CLOUD_PROPERTY_REGION = "deviceRegion"; - public static final String CLOUD_PROPERTY_SERVER_URL = "appServerUrl"; - public static final String CLOUD_PROPERTY_TYPE = "deviceType"; + /*** DEVICE JSON STRINGS (CLOUD) ***/ + public static final String CLOUD_JSON_KEY_ALIAS = "alias"; + public static final String CLOUD_JSON_KEY_FW = "fwVer"; + public static final String CLOUD_JSON_KEY_HW = "deviceHwVer"; + public static final String CLOUD_JSON_KEY_ID = "deviceId"; + public static final String CLOUD_JSON_KEY_MAC = "deviceMac"; + public static final String CLOUD_JSON_KEY_MODEL = "deviceName"; // use name cause modell returns different values + public static final String CLOUD_JSON_KEY_NAME = "deviceName"; + public static final String CLOUD_JSON_KEY_REGION = "deviceRegion"; + public static final String CLOUD_JSON_KEY_SERVER_URL = "appServerUrl"; + public static final String CLOUD_JSON_KEY_TYPE = "deviceType"; - /*** DEVICE PROPERTY STRINGS (DEVICE) ***/ - public static final String DEVICE_PROPERTY_BRIGHTNES = "brightness"; - public static final String DEVICE_PROPERTY_COLORTEMP = "color_temp"; - public static final String DEVICE_PROPERTY_FW = "fw_ver"; - public static final String DEVICE_PROPERTY_HUE = "hue"; - public static final String DEVICE_PROPERTY_HW = "hw_ver"; - public static final String DEVICE_PROPERTY_ID = "device_id"; - public static final String DEVICE_PROPERTY_IP = "ip"; - public static final String DEVICE_PROPERTY_MAC = "mac"; - public static final String DEVICE_PROPERTY_MODEL = "model"; - public static final String DEVICE_PROPERTY_NICKNAME = "nickname"; - public static final String DEVICE_PROPERTY_ON = "device_on"; - public static final String DEVICE_PROPERTY_ONTIME = "on_time"; - public static final String DEVICE_PROPERTY_OVERHEAT = "overheated"; - public static final String DEVICE_PROPERTY_REGION = "region"; - public static final String DEVICE_PROPERTY_SATURATION = "saturation"; - public static final String DEVICE_PROPERTY_SIGNAL = "signal_level"; - public static final String DEVICE_PROPERTY_SIGNAL_RSSI = "rssi"; - public static final String DEVICE_PROPERTY_TYPE = "type"; - public static final String DEVICE_PROPERTY_USAGE_7 = "time_usage_past7"; - public static final String DEVICE_PROPERTY_USAGE_30 = "time_usage_past30"; - public static final String DEVICE_PROPERTY_USAGE_TODAY = "time_usage_today"; + /*** DEVICE JSON STRINGS (DEVICE) ***/ + public static final String JSON_KEY_BRIGHTNES = "brightness"; + public static final String JSON_KEY_COLORTEMP = "color_temp"; + public static final String JSON_KEY_FW = "fw_ver"; + public static final String JSON_KEY_HUE = "hue"; + public static final String JSON_KEY_HW_VER = "hw_ver"; + public static final String JSON_KEY_ID = "device_id"; + public static final String JSON_KEY_IP = "ip"; + public static final String JSON_KEY_MAC = "mac"; + public static final String JSON_KEY_MODEL = "model"; + public static final String JSON_KEY_NICKNAME = "nickname"; + public static final String JSON_KEY_ON = "device_on"; + public static final String JSON_KEY_ONTIME = "on_time"; + public static final String JSON_KEY_OVERHEAT = "overheated"; + public static final String JSON_KEY_REGION = "region"; + public static final String JSON_KEY_SATURATION = "saturation"; + public static final String JSON_KEY_SIGNAL_LEVEL = "signal_level"; + public static final String JSON_KEY_RSSI = "rssi"; + public static final String JSON_KEY_TYPE = "type"; + public static final String JSON_KEY_USAGE_7 = "time_usage_past7"; + public static final String JSON_KEY_USAGE_30 = "time_usage_past30"; + public static final String JSON_KEY_USAGE_TODAY = "time_usage_today"; public static final String DEVICE_REPRESENTATION_PROPERTY = "macAddress"; // lightning effects - public static final String DEVICE_PROPERTY_EFFECT = "lighting_effect"; - public static final String PROPERTY_LIGHTNING_EFFECT_BRIGHNTESS = "brightness"; - public static final String PROPERTY_LIGHTNING_EFFECT_COLORTEMPRANGE = "color_temp_range"; - public static final String PROPERTY_LIGHTNING_EFFECT_CUSTOM = "custom"; - public static final String PROPERTY_LIGHTNING_EFFECT_DISPLAYCOLORS = "displayColors"; - public static final String PROPERTY_LIGHTNING_EFFECT_ENABLE = "enable"; - public static final String PROPERTY_LIGHTNING_EFFECT_ID = "id"; - public static final String PROPERTY_LIGHTNING_EFFECT_NAME = "name"; + public static final String JSON_KEY_LIGHTNING_EFFECT = "lighting_effect"; + public static final String JSON_KEY_LIGHTNING_EFFECT_BRIGHNTESS = "brightness"; + public static final String JSON_KEY_LIGHTNING_EFFECT_COLORTEMPRANGE = "color_temp_range"; + public static final String JSON_KEY_LIGHTNING_EFFECT_CUSTOM = "custom"; + public static final String JSON_KEY_LIGHTNING_EFFECT_DISPLAYCOLORS = "displayColors"; + public static final String JSON_KEY_LIGHTNING_EFFECT_ENABLE = "enable"; + public static final String JSON_KEY_LIGHTNING_EFFECT_ID = "id"; + public static final String JSON_KEY_LIGHTNING_EFFECT_NAME = "name"; + public static final String JSON_KEY_LIGHTNING_DYNAMIC_ENABLE = "dynamic_light_effect_enable"; + public static final String JSON_KEY_LIGHTNING_DYNAMIC_ID = "dynamic_light_effect_id"; // energy monitoring - public static final String ENERGY_PROPERTY_POWER = "current_power"; - public static final String ENERGY_PROPERTY_RUNTIME_TODAY = "today_runtime"; - public static final String ENERGY_PROPERTY_RUNTIME_MONTH = "month_runtime"; - public static final String ENERGY_PROPERTY_ENERGY_TODAY = "today_energy"; - public static final String ENERGY_PROPERTY_ENERGY_MONTH = "month_energy"; - public static final String ENERGY_PROPERTY_PAST24H = "past24h"; - public static final String ENERGY_PROPERTY_PAST7D = "past7d"; - public static final String ENERGY_PROPERTY_PAST30D = "past30d"; - public static final String ENERGY_PROPERTY_PAST1Y = "past1y"; + public static final String JSON_KEY_ENERGY_POWER = "current_power"; + public static final String JSON_KEY_ENERGY_RUNTIME_TODAY = "today_runtime"; + public static final String JSON_KEY_ENERGY_RUNTIME_MONTH = "month_runtime"; + public static final String JSON_KEY_ENERGY_ENERGY_TODAY = "today_energy"; + public static final String JSON_KEY_ENERGY_ENERGY_MONTH = "month_energy"; + public static final String JSON_KEY_ENERGY_PAST24H = "past24h"; + public static final String JSON_KEY_ENERGY_PAST7D = "past7d"; + public static final String JSON_KEY_ENERGY_PAST30D = "past30d"; + public static final String JSON_KEY_ENERGY_PAST1Y = "past1y"; // childs management - public static final String CHILD_PROPERTY_START_INDEX = "start_index"; + public static final String JSON_KEY_CHILD_START_INDEX = "start_index"; /*** DEVICE SETTINGS ***/ public static final Integer BULB_MIN_COLORTEMP = 2500; @@ -178,12 +180,10 @@ public class TapoThingConstants { public static final String CHANNEL_NRG_USAGE_TODAY = "todayEnergyUsage"; public static final String CHANNEL_NRG_RUNTIME_TODAY = "todayRuntime"; // channel group effect - public static final String CHANNEL_GROUP_EFFECTS = "effect"; - public static final String CHANNEL_FX_BRIGHTNESS = "brightness"; - public static final String CHANNEL_FX_COLORS = "displayColors"; - public static final String CHANNEL_FX_CUSTOM = "custom"; - public static final String CHANNEL_FX_ENABLE = "enable"; - public static final String CHANNEL_FX_NAME = "name"; + public static final String CHANNEL_GROUP_EFFECTS = "effects"; + public static final String CHANNEL_FX_BRIGHTNESS = "fxBrightness"; + public static final String CHANNEL_FX_COLORS = "fxColors"; + public static final String CHANNEL_FX_NAME = "fxName"; /*** LIST OF PROPERTY NAMES ***/ public static final String PROPERTY_FAMILY = "deviceFamily"; diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoLightStrip.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoLightStrip.java index 4aea31fd6..aa01fb72b 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoLightStrip.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoLightStrip.java @@ -72,7 +72,7 @@ public class TapoLightStrip extends TapoDevice { } else { switch (channel) { case CHANNEL_OUTPUT: - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, command == OnOffType.ON); + connector.sendDeviceCommand(JSON_KEY_ON, command == OnOffType.ON); refreshInfo = true; break; case CHANNEL_BRIGHTNESS: @@ -117,11 +117,11 @@ public class TapoLightStrip extends TapoDevice { protected void setBrightness(Integer newBrightness) { /* switch off if 0 */ if (newBrightness == 0) { - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, false); + connector.sendDeviceCommand(JSON_KEY_ON, false); } else { HashMap newState = new HashMap<>(); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_BRIGHTNES, newBrightness); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_BRIGHTNES, newBrightness); connector.sendDeviceCommands(newState); } } @@ -133,10 +133,10 @@ public class TapoLightStrip extends TapoDevice { */ protected void setColor(HSBType command) { HashMap 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(JSON_KEY_ON, true); + newState.put(JSON_KEY_HUE, command.getHue()); + newState.put(JSON_KEY_SATURATION, command.getSaturation()); + newState.put(JSON_KEY_BRIGHTNES, command.getBrightness()); connector.sendDeviceCommands(newState); } @@ -148,8 +148,8 @@ public class TapoLightStrip extends TapoDevice { protected void setColorTemp(Integer colorTemp) { HashMap newState = new HashMap<>(); colorTemp = limitVal(colorTemp, BULB_MIN_COLORTEMP, BULB_MAX_COLORTEMP); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_COLORTEMP, colorTemp); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_COLORTEMP, colorTemp); connector.sendDeviceCommands(newState); } @@ -176,9 +176,6 @@ public class TapoLightStrip extends TapoDevice { case CHANNEL_FX_NAME: lightEffect.setName(command.toString()); break; - case CHANNEL_FX_ENABLE: - lightEffect.setEnable(command == OnOffType.ON); - break; } setLightEffects(lightEffect); } @@ -190,14 +187,14 @@ public class TapoLightStrip extends TapoDevice { */ protected void setLightEffects(TapoLightEffect lightEffect) { JsonObject newEffect = new JsonObject(); - newEffect.addProperty(PROPERTY_LIGHTNING_EFFECT_ENABLE, lightEffect.getEnable()); - newEffect.addProperty(PROPERTY_LIGHTNING_EFFECT_NAME, lightEffect.getName()); - newEffect.addProperty(PROPERTY_LIGHTNING_EFFECT_BRIGHNTESS, lightEffect.getBrightness()); - newEffect.addProperty(PROPERTY_LIGHTNING_EFFECT_COLORTEMPRANGE, lightEffect.getColorTempRange().toString()); - newEffect.addProperty(PROPERTY_LIGHTNING_EFFECT_DISPLAYCOLORS, lightEffect.getDisplayColors().toString()); - newEffect.addProperty(PROPERTY_LIGHTNING_EFFECT_CUSTOM, lightEffect.getCustom()); + newEffect.addProperty(JSON_KEY_LIGHTNING_EFFECT_ENABLE, lightEffect.getEnable()); + newEffect.addProperty(JSON_KEY_LIGHTNING_EFFECT_NAME, lightEffect.getName()); + newEffect.addProperty(JSON_KEY_LIGHTNING_EFFECT_BRIGHNTESS, lightEffect.getBrightness()); + newEffect.addProperty(JSON_KEY_LIGHTNING_EFFECT_COLORTEMPRANGE, lightEffect.getColorTempRange().toString()); + newEffect.addProperty(JSON_KEY_LIGHTNING_EFFECT_DISPLAYCOLORS, lightEffect.getDisplayColors().toString()); + newEffect.addProperty(JSON_KEY_LIGHTNING_EFFECT_CUSTOM, lightEffect.getCustom()); - connector.sendDeviceCommand(DEVICE_PROPERTY_EFFECT, newEffect.toString()); + connector.sendDeviceCommand(JSON_KEY_LIGHTNING_EFFECT, newEffect.toString()); } /** @@ -224,7 +221,5 @@ public class TapoLightStrip extends TapoDevice { publishState(getChannelID(CHANNEL_GROUP_EFFECTS, CHANNEL_FX_BRIGHTNESS), getPercentType(lightEffect.getBrightness())); publishState(getChannelID(CHANNEL_GROUP_EFFECTS, CHANNEL_FX_NAME), getStringType(lightEffect.getName())); - publishState(getChannelID(CHANNEL_GROUP_EFFECTS, CHANNEL_FX_ENABLE), getOnOffType(lightEffect.getEnable())); - publishState(getChannelID(CHANNEL_GROUP_EFFECTS, CHANNEL_FX_CUSTOM), getOnOffType(lightEffect.getCustom())); } } diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartBulb.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartBulb.java index 02f1299b2..ee9475a81 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartBulb.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartBulb.java @@ -19,6 +19,7 @@ import java.util.HashMap; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.tapocontrol.internal.structures.TapoDeviceInfo; +import org.openhab.binding.tapocontrol.internal.structures.TapoLightEffect; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.HSBType; import org.openhab.core.library.types.OnOffType; @@ -65,7 +66,7 @@ public class TapoSmartBulb extends TapoDevice { } else { switch (channel) { case CHANNEL_OUTPUT: - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, command == OnOffType.ON); + connector.sendDeviceCommand(JSON_KEY_ON, command == OnOffType.ON); refreshInfo = true; break; case CHANNEL_BRIGHTNESS: @@ -90,6 +91,9 @@ public class TapoSmartBulb extends TapoDevice { refreshInfo = true; } break; + case CHANNEL_FX_NAME: + setLightEffect(command.toString()); + break; default: logger.warn("({}) command type '{}' not supported for channel '{}'", uid, command.toString(), channelUID.getId()); @@ -110,11 +114,11 @@ public class TapoSmartBulb extends TapoDevice { protected void setBrightness(Integer newBrightness) { /* switch off if 0 */ if (newBrightness == 0) { - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, false); + connector.sendDeviceCommand(JSON_KEY_ON, false); } else { HashMap newState = new HashMap<>(); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_BRIGHTNES, newBrightness); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_BRIGHTNES, newBrightness); connector.sendDeviceCommands(newState); } } @@ -126,10 +130,11 @@ public class TapoSmartBulb extends TapoDevice { */ protected void setColor(HSBType command) { HashMap newState = new HashMap<>(); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_HUE, command.getHue().intValue()); - newState.put(DEVICE_PROPERTY_SATURATION, command.getSaturation().intValue()); - newState.put(DEVICE_PROPERTY_BRIGHTNES, command.getBrightness().intValue()); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_HUE, command.getHue().intValue()); + newState.put(JSON_KEY_SATURATION, command.getSaturation().intValue()); + newState.put(JSON_KEY_BRIGHTNES, command.getBrightness().intValue()); + newState.put(JSON_KEY_LIGHTNING_DYNAMIC_ENABLE, false); connector.sendDeviceCommands(newState); } @@ -141,8 +146,26 @@ public class TapoSmartBulb extends TapoDevice { protected void setColorTemp(Integer colorTemp) { HashMap newState = new HashMap<>(); colorTemp = limitVal(colorTemp, BULB_MIN_COLORTEMP, BULB_MAX_COLORTEMP); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_COLORTEMP, colorTemp); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_COLORTEMP, colorTemp); + connector.sendDeviceCommands(newState); + } + + /** + * Set light effect + * + * @param fxName (String) id of LightEffect + */ + protected void setLightEffect(String fxName) { + HashMap newState = new HashMap<>(); + if (fxName.length() > 0) { + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_LIGHTNING_DYNAMIC_ENABLE, true); + newState.put(JSON_KEY_LIGHTNING_DYNAMIC_ID, fxName); + } else { + newState.put(JSON_KEY_LIGHTNING_DYNAMIC_ENABLE, false); + newState.put(JSON_KEY_LIGHTNING_DYNAMIC_ID, ""); + } connector.sendDeviceCommands(newState); } @@ -165,5 +188,20 @@ public class TapoSmartBulb extends TapoDevice { publishState(getChannelID(CHANNEL_GROUP_DEVICE, CHANNEL_ONTIME), getTimeType(deviceInfo.getOnTime(), Units.SECOND)); publishState(getChannelID(CHANNEL_GROUP_DEVICE, CHANNEL_OVERHEAT), getOnOffType(deviceInfo.isOverheated())); + + updateLightEffectChannels(deviceInfo.getLightEffect()); + } + + /** + * Set light effect channels + * + * @param lightEffect + */ + protected void updateLightEffectChannels(TapoLightEffect lightEffect) { + String fxId = ""; + if (lightEffect.getEnable().equals(true)) { + fxId = lightEffect.getId(); + } + publishState(getChannelID(CHANNEL_GROUP_EFFECTS, CHANNEL_FX_NAME), getStringType(fxId)); } } diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartPlug.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartPlug.java index 50e09ab5f..1202bb7d4 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartPlug.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoSmartPlug.java @@ -61,11 +61,11 @@ public class TapoSmartPlug extends TapoDevice { } else if (command instanceof OnOffType) { Boolean targetState = command == OnOffType.ON ? Boolean.TRUE : Boolean.FALSE; if (CHANNEL_OUTPUT.equals(id)) { // Command is sent to the device output - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, targetState); + connector.sendDeviceCommand(JSON_KEY_ON, targetState); refreshInfo = true; } else if (id.startsWith(CHANNEL_OUTPUT)) { // Command is sent to a child's device output Integer index = Integer.valueOf(id.replace(CHANNEL_OUTPUT, "")); - connector.sendChildCommand(index, DEVICE_PROPERTY_ON, targetState); + connector.sendChildCommand(index, JSON_KEY_ON, targetState); refreshInfo = true; } } else { diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java index 8021194b6..12e777172 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java @@ -66,7 +66,7 @@ public class TapoUniversalDevice extends TapoDevice { } else { switch (channel) { case CHANNEL_OUTPUT: - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, command == OnOffType.ON); + connector.sendDeviceCommand(JSON_KEY_ON, command == OnOffType.ON); refreshInfo = true; break; case CHANNEL_BRIGHTNESS: @@ -121,11 +121,11 @@ public class TapoUniversalDevice extends TapoDevice { protected void setBrightness(Integer newBrightness) { /* switch off if 0 */ if (newBrightness == 0) { - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, false); + connector.sendDeviceCommand(JSON_KEY_ON, false); } else { HashMap newState = new HashMap<>(); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_BRIGHTNES, newBrightness); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_BRIGHTNES, newBrightness); connector.sendDeviceCommands(newState); } } @@ -137,10 +137,10 @@ public class TapoUniversalDevice extends TapoDevice { */ protected void setColor(HSBType command) { HashMap 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(JSON_KEY_ON, true); + newState.put(JSON_KEY_HUE, command.getHue()); + newState.put(JSON_KEY_SATURATION, command.getSaturation()); + newState.put(JSON_KEY_BRIGHTNES, command.getBrightness()); connector.sendDeviceCommands(newState); } @@ -152,8 +152,8 @@ public class TapoUniversalDevice extends TapoDevice { protected void setColorTemp(Integer colorTemp) { HashMap newState = new HashMap<>(); colorTemp = limitVal(colorTemp, BULB_MIN_COLORTEMP, BULB_MAX_COLORTEMP); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_COLORTEMP, colorTemp); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_COLORTEMP, colorTemp); connector.sendDeviceCommands(newState); } diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java index 752827606..38d3bce34 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java @@ -84,27 +84,27 @@ public class TapoDeviceInfo { } private void setData() { - this.brightness = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_BRIGHTNES); - this.colorTemp = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_COLORTEMP, BULB_MIN_COLORTEMP); - this.deviceId = jsonObjectToString(jsonObject, DEVICE_PROPERTY_ID); - this.deviceOn = jsonObjectToBool(jsonObject, DEVICE_PROPERTY_ON); - this.fwVer = jsonObjectToString(jsonObject, DEVICE_PROPERTY_FW); - this.hue = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_HUE); - this.hwVer = jsonObjectToString(jsonObject, DEVICE_PROPERTY_HW); - this.ip = jsonObjectToString(jsonObject, DEVICE_PROPERTY_IP); - this.mac = jsonObjectToString(jsonObject, DEVICE_PROPERTY_MAC); - this.model = jsonObjectToString(jsonObject, DEVICE_PROPERTY_MODEL); - this.nickname = jsonObjectToString(jsonObject, DEVICE_PROPERTY_NICKNAME); - this.onTime = jsonObjectToNumber(jsonObject, DEVICE_PROPERTY_ONTIME); - this.overheated = jsonObjectToBool(jsonObject, DEVICE_PROPERTY_OVERHEAT); - this.region = jsonObjectToString(jsonObject, DEVICE_PROPERTY_REGION); - this.saturation = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_SATURATION); - this.signalLevel = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_SIGNAL); - this.rssi = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_SIGNAL_RSSI); - this.timeUsagePast7 = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_USAGE_7); - this.timeUsagePast30 = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_USAGE_30); - this.timeUsageToday = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_USAGE_TODAY); - this.type = jsonObjectToString(jsonObject, DEVICE_PROPERTY_TYPE); + this.brightness = jsonObjectToInt(jsonObject, JSON_KEY_BRIGHTNES); + this.colorTemp = jsonObjectToInt(jsonObject, JSON_KEY_COLORTEMP, BULB_MIN_COLORTEMP); + this.deviceId = jsonObjectToString(jsonObject, JSON_KEY_ID); + this.deviceOn = jsonObjectToBool(jsonObject, JSON_KEY_ON); + this.fwVer = jsonObjectToString(jsonObject, JSON_KEY_FW); + this.hue = jsonObjectToInt(jsonObject, JSON_KEY_HUE); + this.hwVer = jsonObjectToString(jsonObject, JSON_KEY_HW_VER); + this.ip = jsonObjectToString(jsonObject, JSON_KEY_IP); + this.mac = jsonObjectToString(jsonObject, JSON_KEY_MAC); + this.model = jsonObjectToString(jsonObject, JSON_KEY_MODEL); + this.nickname = jsonObjectToString(jsonObject, JSON_KEY_NICKNAME); + this.onTime = jsonObjectToNumber(jsonObject, JSON_KEY_ONTIME); + this.overheated = jsonObjectToBool(jsonObject, JSON_KEY_OVERHEAT); + this.region = jsonObjectToString(jsonObject, JSON_KEY_REGION); + this.saturation = jsonObjectToInt(jsonObject, JSON_KEY_SATURATION); + this.signalLevel = jsonObjectToInt(jsonObject, JSON_KEY_SIGNAL_LEVEL); + this.rssi = jsonObjectToInt(jsonObject, JSON_KEY_RSSI); + this.timeUsagePast7 = jsonObjectToInt(jsonObject, JSON_KEY_USAGE_7); + this.timeUsagePast30 = jsonObjectToInt(jsonObject, JSON_KEY_USAGE_30); + this.timeUsageToday = jsonObjectToInt(jsonObject, JSON_KEY_USAGE_TODAY); + this.type = jsonObjectToString(jsonObject, JSON_KEY_TYPE); if (this.hasLightEffect()) { this.lightEffect = lightEffect.setData(jsonObject); @@ -117,7 +117,7 @@ public class TapoDeviceInfo { * ************************************/ public Boolean hasLightEffect() { - return this.jsonObject.has(DEVICE_PROPERTY_EFFECT); + return this.jsonObject.has(JSON_KEY_LIGHTNING_EFFECT) || this.jsonObject.has(JSON_KEY_LIGHTNING_DYNAMIC_ENABLE); } /*********************************** diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoEnergyData.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoEnergyData.java index 87cca0f4a..8210fd844 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoEnergyData.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoEnergyData.java @@ -60,7 +60,7 @@ public class TapoEnergyData { */ public TapoEnergyData setData(JsonObject jso) { /* create empty jsonObject to set efault values if has no energydata */ - if (jso.has(ENERGY_PROPERTY_POWER)) { + if (jso.has(JSON_KEY_ENERGY_POWER)) { this.jsonObject = jso; } else { jsonObject = new JsonObject(); @@ -70,12 +70,12 @@ public class TapoEnergyData { } private void setData() { - this.currentPower = (float) jsonObjectToInt(jsonObject, ENERGY_PROPERTY_POWER) / 1000; + this.currentPower = (float) jsonObjectToInt(jsonObject, JSON_KEY_ENERGY_POWER) / 1000; - this.todayEnergy = jsonObjectToInt(jsonObject, ENERGY_PROPERTY_ENERGY_TODAY); - this.monthEnergy = jsonObjectToInt(jsonObject, ENERGY_PROPERTY_ENERGY_MONTH); - this.todayRuntime = jsonObjectToInt(jsonObject, ENERGY_PROPERTY_RUNTIME_TODAY); - this.monthRuntime = jsonObjectToInt(jsonObject, ENERGY_PROPERTY_RUNTIME_MONTH); + this.todayEnergy = jsonObjectToInt(jsonObject, JSON_KEY_ENERGY_ENERGY_TODAY); + this.monthEnergy = jsonObjectToInt(jsonObject, JSON_KEY_ENERGY_ENERGY_MONTH); + this.todayRuntime = jsonObjectToInt(jsonObject, JSON_KEY_ENERGY_RUNTIME_TODAY); + this.monthRuntime = jsonObjectToInt(jsonObject, JSON_KEY_ENERGY_RUNTIME_MONTH); this.past24h = new Number[24]; this.past30d = new Number[30]; this.past1y = new Number[12]; diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java index 68bee1a4c..396160f21 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java +++ b/bundles/org.openhab.binding.tapocontrol/src/main/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java @@ -28,10 +28,10 @@ import com.google.gson.JsonObject; */ @NonNullByDefault public class TapoLightEffect { - private Integer enable = 0; + private Boolean enable = false; private String id = ""; private String name = ""; - private Integer custom = 0; + private Boolean custom = false; private Integer brightness = 0; private Integer[] colorTempRange = { 9000, 9000 }; // :[9000,9000] private Color displayColors[] = { Color.WHITE }; @@ -42,7 +42,6 @@ public class TapoLightEffect { * INIT */ public TapoLightEffect() { - setData(); } /** @@ -61,21 +60,33 @@ public class TapoLightEffect { */ public TapoLightEffect setData(JsonObject jso) { /* create empty jsonObject to set efault values if has no lighning effect */ - if (jso.has(DEVICE_PROPERTY_EFFECT)) { + if (jso.has(JSON_KEY_LIGHTNING_EFFECT)) { + this.jsonObject = jso.getAsJsonObject(JSON_KEY_LIGHTNING_EFFECT); + this.enable = jsonObjectToBool(jsonObject, JSON_KEY_LIGHTNING_EFFECT_ENABLE); + this.id = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_EFFECT_ID); + this.name = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_EFFECT_NAME); + this.custom = jsonObjectToBool(jsonObject, JSON_KEY_LIGHTNING_EFFECT_CUSTOM); + this.brightness = jsonObjectToInt(jsonObject, JSON_KEY_LIGHTNING_EFFECT_BRIGHNTESS); + } else if (jso.has(JSON_KEY_LIGHTNING_DYNAMIC_ENABLE)) { this.jsonObject = jso; + this.enable = jsonObjectToBool(jsonObject, JSON_KEY_LIGHTNING_DYNAMIC_ENABLE); + this.id = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_DYNAMIC_ID); } else { - jsonObject = new JsonObject(); + setDefaults(); } - setData(); return this; } - private void setData() { - this.enable = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_ENABLE); - this.id = jsonObjectToString(jsonObject, PROPERTY_LIGHTNING_EFFECT_ID); - this.name = jsonObjectToString(jsonObject, PROPERTY_LIGHTNING_EFFECT_NAME); - this.custom = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_CUSTOM); // jsonObjectToBool - this.brightness = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_BRIGHNTESS); + /** + * Set default values + */ + private void setDefaults() { + this.jsonObject = new JsonObject(); + this.enable = false; + this.id = ""; + this.name = ""; + this.custom = false; + this.brightness = 100; } /*********************************** @@ -85,7 +96,7 @@ public class TapoLightEffect { ************************************/ public void setEnable(Boolean enable) { - this.enable = enable ? 1 : 0; + this.enable = enable; } public void setName(String value) { @@ -93,7 +104,7 @@ public class TapoLightEffect { } public void setCustom(Boolean enable) { - this.custom = enable ? 1 : 0; + this.custom = enable; } public void setBrightness(Integer value) { @@ -106,7 +117,7 @@ public class TapoLightEffect { * ************************************/ - public Integer getEnable() { + public Boolean getEnable() { return this.enable; } @@ -118,7 +129,7 @@ public class TapoLightEffect { return this.name; } - public Integer getCustom() { + public Boolean getCustom() { return this.custom; } diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/i18n/tapocontrol.properties b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/i18n/tapocontrol.properties index 8517d6ef6..755a90a6b 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/i18n/tapocontrol.properties +++ b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/i18n/tapocontrol.properties @@ -58,8 +58,12 @@ 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 channel-group-type.tapocontrol.lightBulb.description = Tapo Smart Light Bulb -channel-group-type.tapocontrol.lightEffect.label = Lightning Effect -channel-group-type.tapocontrol.lightEffect.description = Tapo Lightning Effects +channel-group-type.tapocontrol.lightEffectL530.label = Lightning Effect +channel-group-type.tapocontrol.lightEffectL530.description = Tapo Lightning Effects +channel-group-type.tapocontrol.lightEffectL920.label = Lightning Effect +channel-group-type.tapocontrol.lightEffectL920.description = Tapo Lightning Effects +channel-group-type.tapocontrol.lightEffectL920.label = Lightning Effect +channel-group-type.tapocontrol.lightEffectL920.description = Tapo Lightning Effects channel-group-type.tapocontrol.lightStrip.label = Color Light Strip channel-group-type.tapocontrol.lightStrip.description = Tapo Multicolor Smart Light Strip channel-group-type.tapocontrol.powerStrip.label = SmartPlug @@ -81,16 +85,56 @@ channel-type.tapocontrol.colorChannel.label = Color channel-type.tapocontrol.colorChannel.description = Color channel-type.tapocontrol.colorTemperature.label = Color Temperature channel-type.tapocontrol.colorTemperature.description = This channel supports adjusting the color temperature from 2700K to 6500K. -channel-type.tapocontrol.customEffect.label = Custom Effect -channel-type.tapocontrol.customEffect.description = Use custom lightning effect channel-type.tapocontrol.dimmerChannel.label = Brightness channel-type.tapocontrol.dimmerChannel.description = Brightness -channel-type.tapocontrol.effectName.label = Effect Name -channel-type.tapocontrol.effectName.description = Name of LightningEffect -channel-type.tapocontrol.effectOn.label = Lightning Effect Enable -channel-type.tapocontrol.effectOn.description = Switches the lightning effect on/off channel-type.tapocontrol.fade.label = Fade Light channel-type.tapocontrol.fade.description = Make the light darker or lighter slowly +channel-type.tapocontrol.l530fxList.label = Light Effect Theme +channel-type.tapocontrol.l530fxList.description = Name of active lightning effect +channel-type.tapocontrol.l530fxList.state.option. = None (No FX) +channel-type.tapocontrol.l530fxList.state.option.custom = Custom +channel-type.tapocontrol.l530fxList.state.option.L1 = Party +channel-type.tapocontrol.l530fxList.state.option.L2 = Relax +channel-type.tapocontrol.l920fxList.label = Light Effect Theme +channel-type.tapocontrol.l920fxList.description = Name of lightning effect +channel-type.tapocontrol.l920fxList.state.option. = None (No FX) +channel-type.tapocontrol.l920fxList.state.option.aurora = Aurora +channel-type.tapocontrol.l920fxList.state.option.bubbling_calderon = Bubbling Calderon +channel-type.tapocontrol.l920fxList.state.option.christmas = Christmas +channel-type.tapocontrol.l920fxList.state.option.christmas_light = Christmas Light +channel-type.tapocontrol.l920fxList.state.option.candy_cane = Candy +channel-type.tapocontrol.l920fxList.state.option.flicker = Flicker +channel-type.tapocontrol.l920fxList.state.option.hanukkah = Hanukkah +channel-type.tapocontrol.l920fxList.state.option.haunted_mansion = Haunted Mansion +channel-type.tapocontrol.l920fxList.state.option.icicle = Icicle +channel-type.tapocontrol.l920fxList.state.option.lightning = Lightning +channel-type.tapocontrol.l920fxList.state.option.ocean = Ocean +channel-type.tapocontrol.l920fxList.state.option.rainbow = Rainbow +channel-type.tapocontrol.l920fxList.state.option.raindrop = Raindrop +channel-type.tapocontrol.l920fxList.state.option.spring = Spring +channel-type.tapocontrol.l920fxList.state.option.sunrise = Sunrise +channel-type.tapocontrol.l920fxList.state.option.sunset = Sunset +channel-type.tapocontrol.l920fxList.state.option.valentines = Valentines +channel-type.tapocontrol.l930fxList.label = Light Effect Theme +channel-type.tapocontrol.l930fxList.description = Name of lightning effect +channel-type.tapocontrol.l930fxList.state.option. = None (No FX) +channel-type.tapocontrol.l930fxList.state.option.aurora = Aurora +channel-type.tapocontrol.l930fxList.state.option.bubbling_calderon = Bubbling Calderon +channel-type.tapocontrol.l930fxList.state.option.christmas = Christmas +channel-type.tapocontrol.l930fxList.state.option.christmas_light = Christmas Light +channel-type.tapocontrol.l930fxList.state.option.candy_cane = Candy +channel-type.tapocontrol.l930fxList.state.option.flicker = Flicker +channel-type.tapocontrol.l930fxList.state.option.hanukkah = Hanukkah +channel-type.tapocontrol.l930fxList.state.option.haunted_mansion = Haunted Mansion +channel-type.tapocontrol.l930fxList.state.option.icicle = Icicle +channel-type.tapocontrol.l930fxList.state.option.lightning = Lightning +channel-type.tapocontrol.l930fxList.state.option.ocean = Ocean +channel-type.tapocontrol.l930fxList.state.option.rainbow = Rainbow +channel-type.tapocontrol.l930fxList.state.option.raindrop = Raindrop +channel-type.tapocontrol.l930fxList.state.option.spring = Spring +channel-type.tapocontrol.l930fxList.state.option.sunrise = Sunrise +channel-type.tapocontrol.l930fxList.state.option.sunset = Sunset +channel-type.tapocontrol.l930fxList.state.option.valentines = Valentines channel-type.tapocontrol.led.label = Switch Led channel-type.tapocontrol.led.description = Switch the Smart Home device led on or off. channel-type.tapocontrol.lightOn.label = Light On @@ -105,3 +149,17 @@ channel-type.tapocontrol.todayEnergyUsageChannel.label = Today Usage channel-type.tapocontrol.todayEnergyUsageChannel.description = Today energy usage channel-type.tapocontrol.todayRuntimeChannel.label = Today Runtime channel-type.tapocontrol.todayRuntimeChannel.description = Today runtime (On-Time) + +# channel group types + +channel-group-type.tapocontrol.lightEffect.label = Lightning Effect +channel-group-type.tapocontrol.lightEffect.description = Tapo Lightning Effects + +# channel types + +channel-type.tapocontrol.customEffect.label = Custom Effect +channel-type.tapocontrol.customEffect.description = Use custom lightning effect +channel-type.tapocontrol.effectName.label = Effect Name +channel-type.tapocontrol.effectName.description = Name of LightningEffect +channel-type.tapocontrol.effectOn.label = Lightning Effect Enable +channel-type.tapocontrol.effectOn.description = Switches the lightning effect on/off diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L530.xml b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L530.xml index 679cbb364..85b08cd5f 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L530.xml +++ b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L530.xml @@ -14,10 +14,35 @@ Tapo Smart Multicolor Light-Bulb + macAddress + + + + + Tapo Lightning Effects + + + + + + + + String + + Name of active lightning effect + + + + + + + + + diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L920.xml b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L920.xml index d62285c82..0588cae99 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L920.xml +++ b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L920.xml @@ -20,4 +20,47 @@ + + + + + Tapo Lightning Effects + + + + + + + + + + + + + String + + Name of lightning effect + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L930.xml b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L930.xml index 2fe67041b..359b6e63b 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L930.xml +++ b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/L930.xml @@ -20,4 +20,47 @@ + + + + + Tapo Lightning Effects + + + + + + + + + + + + + String + + Name of lightning effect + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/channels.xml index c4c3c49b6..a2b80ec28 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.tapocontrol/src/main/resources/OH-INF/thing/channels.xml @@ -102,23 +102,6 @@ - - - - Tapo Lightning Effects - - - - - - - - - - - - - @@ -216,35 +199,6 @@ - - - - - Switch - - Switches the lightning effect on/off - LightBulb - - - - - - String - - Name of LightningEffect - - - - - - Switch - - Use custom lightning effect - LightBulb - - - - diff --git a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java index 97b485455..26f377033 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java +++ b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/TapoDiscoveryService.java @@ -131,17 +131,17 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th TapoBridgeHandler tapoBridge = this.bridge; String deviceModel = getDeviceModel(device); String label = getDeviceLabel(device); - String deviceMAC = device.get(CLOUD_PROPERTY_MAC).getAsString(); + String deviceMAC = device.get(CLOUD_JSON_KEY_MAC).getAsString(); ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, deviceModel); /* create properties */ Map properties = new HashMap<>(); properties.put(Thing.PROPERTY_VENDOR, DEVICE_VENDOR); properties.put(Thing.PROPERTY_MAC_ADDRESS, formatMac(deviceMAC, MAC_DIVISION_CHAR)); - properties.put(Thing.PROPERTY_FIRMWARE_VERSION, device.get(CLOUD_PROPERTY_FW).getAsString()); - properties.put(Thing.PROPERTY_HARDWARE_VERSION, device.get(CLOUD_PROPERTY_HW).getAsString()); + properties.put(Thing.PROPERTY_FIRMWARE_VERSION, device.get(CLOUD_JSON_KEY_FW).getAsString()); + properties.put(Thing.PROPERTY_HARDWARE_VERSION, device.get(CLOUD_JSON_KEY_HW).getAsString()); properties.put(Thing.PROPERTY_MODEL_ID, deviceModel); - properties.put(Thing.PROPERTY_SERIAL_NUMBER, device.get(CLOUD_PROPERTY_ID).getAsString()); + properties.put(Thing.PROPERTY_SERIAL_NUMBER, device.get(CLOUD_JSON_KEY_ID).getAsString()); logger.debug("device {} discovered", deviceModel); if (tapoBridge != null) { @@ -190,7 +190,7 @@ public class TapoDiscoveryService extends AbstractDiscoveryService implements Th */ protected String getDeviceModel(JsonObject device) { try { - String deviceModel = device.get(CLOUD_PROPERTY_MODEL).getAsString(); + String deviceModel = device.get(CLOUD_JSON_KEY_MODEL).getAsString(); deviceModel = deviceModel.replaceAll("\\(.*\\)", ""); // replace (DE) deviceModel = deviceModel.replace("Tapo", ""); deviceModel = deviceModel.replace("Series", ""); diff --git a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java index a5f34ee9c..7663a1ada 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java +++ b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/device/TapoUniversalDevice.java @@ -66,7 +66,7 @@ public class TapoUniversalDevice extends TapoDevice { } else { switch (channel) { case CHANNEL_OUTPUT: - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, command == OnOffType.ON); + connector.sendDeviceCommand(JSON_KEY_ON, command == OnOffType.ON); refreshInfo = true; break; case CHANNEL_BRIGHTNESS: @@ -121,11 +121,11 @@ public class TapoUniversalDevice extends TapoDevice { protected void setBrightness(Integer newBrightness) { /* switch off if 0 */ if (newBrightness == 0) { - connector.sendDeviceCommand(DEVICE_PROPERTY_ON, false); + connector.sendDeviceCommand(JSON_KEY_ON, false); } else { HashMap newState = new HashMap<>(); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_BRIGHTNES, newBrightness); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_BRIGHTNES, newBrightness); connector.sendDeviceCommands(newState); } } @@ -137,10 +137,10 @@ public class TapoUniversalDevice extends TapoDevice { */ protected void setColor(HSBType command) { HashMap 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(JSON_KEY_ON, true); + newState.put(JSON_KEY_HUE, command.getHue()); + newState.put(JSON_KEY_SATURATION, command.getSaturation()); + newState.put(JSON_KEY_BRIGHTNES, command.getBrightness()); connector.sendDeviceCommands(newState); } @@ -152,8 +152,8 @@ public class TapoUniversalDevice extends TapoDevice { protected void setColorTemp(Integer colorTemp) { HashMap newState = new HashMap<>(); colorTemp = limitVal(colorTemp, BULB_MIN_COLORTEMP, BULB_MAX_COLORTEMP); - newState.put(DEVICE_PROPERTY_ON, true); - newState.put(DEVICE_PROPERTY_COLORTEMP, colorTemp); + newState.put(JSON_KEY_ON, true); + newState.put(JSON_KEY_COLORTEMP, colorTemp); connector.sendDeviceCommands(newState); } diff --git a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java index 0a37c0a9b..0ed714819 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java +++ b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoDeviceInfo.java @@ -102,28 +102,28 @@ public class TapoDeviceInfo { } private void setData() { - this.brightness = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_BRIGHTNES); - this.colorTemp = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_COLORTEMP, BULB_MIN_COLORTEMP); - this.deviceId = jsonObjectToString(jsonObject, DEVICE_PROPERTY_ID); - this.deviceOn = jsonObjectToBool(jsonObject, DEVICE_PROPERTY_ON); - this.fwVer = jsonObjectToString(jsonObject, DEVICE_PROPERTY_FW); - this.hue = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_HUE); - this.hwVer = jsonObjectToString(jsonObject, DEVICE_PROPERTY_HW); - this.ip = jsonObjectToString(jsonObject, DEVICE_PROPERTY_IP); + this.brightness = jsonObjectToInt(jsonObject, JSON_KEY_BRIGHTNES); + this.colorTemp = jsonObjectToInt(jsonObject, JSON_KEY_COLORTEMP, BULB_MIN_COLORTEMP); + this.deviceId = jsonObjectToString(jsonObject, JSON_KEY_ID); + this.deviceOn = jsonObjectToBool(jsonObject, JSON_KEY_ON); + this.fwVer = jsonObjectToString(jsonObject, JSON_KEY_FW); + this.hue = jsonObjectToInt(jsonObject, JSON_KEY_HUE); + this.hwVer = jsonObjectToString(jsonObject, JSON_KEY_HW_VER); + this.ip = jsonObjectToString(jsonObject, JSON_KEY_IP); this.lightEffect = lightEffect.setData(jsonObject); - this.mac = jsonObjectToString(jsonObject, DEVICE_PROPERTY_MAC); - this.model = jsonObjectToString(jsonObject, DEVICE_PROPERTY_MODEL); - this.nickname = jsonObjectToString(jsonObject, DEVICE_PROPERTY_NICKNAME); - this.onTime = jsonObjectToNumber(jsonObject, DEVICE_PROPERTY_ONTIME); - this.overheated = jsonObjectToBool(jsonObject, DEVICE_PROPERTY_OVERHEAT); - this.region = jsonObjectToString(jsonObject, DEVICE_PROPERTY_REGION); - this.saturation = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_SATURATION); - this.signalLevel = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_SIGNAL); - this.rssi = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_SIGNAL_RSSI); - this.timeUsagePast7 = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_USAGE_7); - this.timeUsagePast30 = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_USAGE_30); - this.timeUsageToday = jsonObjectToInt(jsonObject, DEVICE_PROPERTY_USAGE_TODAY); - this.type = jsonObjectToString(jsonObject, DEVICE_PROPERTY_TYPE); + this.mac = jsonObjectToString(jsonObject, JSON_KEY_MAC); + this.model = jsonObjectToString(jsonObject, JSON_KEY_MODEL); + this.nickname = jsonObjectToString(jsonObject, JSON_KEY_NICKNAME); + this.onTime = jsonObjectToNumber(jsonObject, JSON_KEY_ONTIME); + this.overheated = jsonObjectToBool(jsonObject, JSON_KEY_OVERHEAT); + this.region = jsonObjectToString(jsonObject, JSON_KEY_REGION); + this.saturation = jsonObjectToInt(jsonObject, JSON_KEY_SATURATION); + this.signalLevel = jsonObjectToInt(jsonObject, JSON_KEY_SIGNAL_LEVEL); + this.rssi = jsonObjectToInt(jsonObject, JSON_KEY_RSSI); + this.timeUsagePast7 = jsonObjectToInt(jsonObject, JSON_KEY_USAGE_7); + this.timeUsagePast30 = jsonObjectToInt(jsonObject, JSON_KEY_USAGE_30); + this.timeUsageToday = jsonObjectToInt(jsonObject, JSON_KEY_USAGE_TODAY); + this.type = jsonObjectToString(jsonObject, JSON_KEY_TYPE); } /*********************************** diff --git a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java index 0a236b7bb..0e4e9fe49 100644 --- a/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java +++ b/bundles/org.openhab.binding.tapocontrol/src/test/java/org/openhab/binding/tapocontrol/internal/structures/TapoLightEffect.java @@ -61,7 +61,7 @@ public class TapoLightEffect { */ public TapoLightEffect setData(JsonObject jso) { /* create empty jsonObject to set efault values if has no lighning effect */ - if (jsonObject.has(DEVICE_PROPERTY_EFFECT)) { + if (jsonObject.has(JSON_KEY_LIGHTNING_EFFECT)) { this.jsonObject = jso; } else { jsonObject = new JsonObject(); @@ -71,11 +71,11 @@ public class TapoLightEffect { } private void setData() { - this.enable = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_ENABLE); - this.id = jsonObjectToString(jsonObject, PROPERTY_LIGHTNING_EFFECT_ID); - this.name = jsonObjectToString(jsonObject, PROPERTY_LIGHTNING_EFFECT_NAME); - this.custom = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_CUSTOM); // jsonObjectToBool - this.brightness = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_BRIGHNTESS); + this.enable = jsonObjectToInt(jsonObject, JSON_KEY_LIGHTNING_EFFECT_ENABLE); + this.id = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_EFFECT_ID); + this.name = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_EFFECT_NAME); + this.custom = jsonObjectToInt(jsonObject, JSON_KEY_LIGHTNING_EFFECT_CUSTOM); // jsonObjectToBool + this.brightness = jsonObjectToInt(jsonObject, JSON_KEY_LIGHTNING_EFFECT_BRIGHNTESS); // this.color_temp_range = { 9000, 9000 }; PROPERTY_LIGHNTING_ //:[9000,9000] // this.displayColors[] PROPERTY_LIGHNTING_; }