[tapocontrol] LightEffects for L530 can now be set (#14972)
removed 'queryChild' for devices with no childs Signed-off-by: Christian Wild <christian@wildclan.de>
This commit is contained in:
parent
ccab566172
commit
6ab8111f9e
|
@ -70,9 +70,9 @@ All devices support some of the following channels:
|
|||
| | 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, L920 |
|
||||
| | colorTemperature | Number | White-Color-Temp 2500-6500K | L510, L530, L610, L630, L900, L920 |
|
||||
| | color | Color | Color | L530, L630, L900, L920 |
|
||||
| effects | fxName | String | Active lightning effect (readonly) | L530 |
|
||||
| | colorTemperature | Number | White-Color-Temp 2500-6500K | L510, L530, L610, L630, L900, L920 |
|
||||
| | color | Color | Color | L530, L630, L900, L920 |
|
||||
| effects | fxName | String | Active lightning effect | 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 |
|
||||
|
|
|
@ -142,17 +142,28 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi {
|
|||
* @param value Value to send to control
|
||||
*/
|
||||
public void sendDeviceCommand(String name, Object value) {
|
||||
sendDeviceCommand(DEVICE_CMD_SETINFO, name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* send "set_device_info" command to device
|
||||
*
|
||||
* @param method Method command belongs to
|
||||
* @param name Name of command to send
|
||||
* @param value Value to send to control
|
||||
*/
|
||||
public void sendDeviceCommand(String method, String name, Object value) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > this.lastSent + TAPO_SEND_MIN_GAP_MS) {
|
||||
this.lastSent = now;
|
||||
|
||||
/* create payload */
|
||||
PayloadBuilder plBuilder = new PayloadBuilder();
|
||||
plBuilder.method = DEVICE_CMD_SETINFO;
|
||||
plBuilder.method = method;
|
||||
plBuilder.addParameter(name, value);
|
||||
String payload = plBuilder.getPayload();
|
||||
|
||||
sendSecurePasstrhroug(payload, DEVICE_CMD_SETINFO);
|
||||
sendSecurePasstrhroug(payload, method);
|
||||
} else {
|
||||
logger.debug("({}) command not sent becauso of min_gap: {}", uid, now + " <- " + lastSent);
|
||||
}
|
||||
|
@ -185,19 +196,29 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi {
|
|||
* @param map HashMap<String, Object> (name, value of parameter)
|
||||
*/
|
||||
public void sendDeviceCommands(HashMap<String, Object> map) {
|
||||
sendDeviceCommands(DEVICE_CMD_SETINFO, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* send multiple commands to device
|
||||
*
|
||||
* @param method Method command belongs to
|
||||
* @param map HashMap<String, Object> (name, value of parameter)
|
||||
*/
|
||||
public void sendDeviceCommands(String method, HashMap<String, Object> map) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > this.lastSent + TAPO_SEND_MIN_GAP_MS) {
|
||||
this.lastSent = now;
|
||||
|
||||
/* create payload */
|
||||
PayloadBuilder plBuilder = new PayloadBuilder();
|
||||
plBuilder.method = DEVICE_CMD_SETINFO;
|
||||
plBuilder.method = method;
|
||||
for (HashMap.Entry<String, Object> entry : map.entrySet()) {
|
||||
plBuilder.addParameter(entry.getKey(), entry.getValue());
|
||||
}
|
||||
String payload = plBuilder.getPayload();
|
||||
|
||||
sendSecurePasstrhroug(payload, DEVICE_CMD_SETINFO);
|
||||
sendSecurePasstrhroug(payload, method);
|
||||
} else {
|
||||
logger.debug("({}) command not sent becauso of min_gap: {}", uid, now + " <- " + lastSent);
|
||||
}
|
||||
|
@ -208,7 +229,6 @@ public class TapoDeviceConnector extends TapoDeviceHttpApi {
|
|||
*/
|
||||
public void queryInfo() {
|
||||
queryInfo(false);
|
||||
queryChildDevices();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,4 +56,5 @@ public class TapoBindingSettings {
|
|||
public static final String DEVICE_CMD_CONTROL_CHILD = "control_child";
|
||||
public static final String DEVICE_CMD_MULTIPLE_REQ = "multipleRequest";
|
||||
public static final String DEVICE_CMD_CUSTOM = "custom_command";
|
||||
public static final String DEVICE_CMD_SET_LIGHT_FX = "set_dynamic_light_effect_rule_enable";
|
||||
}
|
||||
|
|
|
@ -138,12 +138,14 @@ public class TapoThingConstants {
|
|||
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_OFF = "off";
|
||||
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 JSON_KEY_ENERGY_POWER = "current_power";
|
||||
public static final String JSON_KEY_ENERGY_RUNTIME_TODAY = "today_runtime";
|
||||
|
|
|
@ -439,7 +439,7 @@ public abstract class TapoDevice extends BaseThingHandler {
|
|||
try {
|
||||
loginSuccess = connector.login();
|
||||
if (loginSuccess) {
|
||||
connector.queryInfo();
|
||||
queryDeviceInfo(true);
|
||||
} else {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, deviceError.getMessage());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
package org.openhab.binding.tapocontrol.internal.device;
|
||||
|
||||
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.TapoUtils.*;
|
||||
|
||||
|
@ -158,15 +159,13 @@ public class TapoSmartBulb extends TapoDevice {
|
|||
*/
|
||||
protected void setLightEffect(String fxName) {
|
||||
HashMap<String, Object> 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);
|
||||
if (fxName.length() > 0 && !fxName.equals(JSON_KEY_LIGHTNING_EFFECT_OFF)) {
|
||||
newState.put(JSON_KEY_LIGHTNING_EFFECT_ENABLE, true);
|
||||
newState.put(JSON_KEY_LIGHTNING_EFFECT_ID, fxName);
|
||||
} else {
|
||||
newState.put(JSON_KEY_LIGHTNING_DYNAMIC_ENABLE, false);
|
||||
newState.put(JSON_KEY_LIGHTNING_DYNAMIC_ID, "");
|
||||
newState.put(JSON_KEY_LIGHTNING_EFFECT_ENABLE, false);
|
||||
}
|
||||
connector.sendDeviceCommands(newState);
|
||||
connector.sendDeviceCommands(DEVICE_CMD_SET_LIGHT_FX, newState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,14 +63,14 @@ public class TapoLightEffect {
|
|||
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.id = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_EFFECT_ID, JSON_KEY_LIGHTNING_EFFECT_OFF);
|
||||
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);
|
||||
this.id = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_DYNAMIC_ID, JSON_KEY_LIGHTNING_EFFECT_OFF);
|
||||
} else {
|
||||
setDefaults();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class TapoLightEffect {
|
|||
private void setDefaults() {
|
||||
this.jsonObject = new JsonObject();
|
||||
this.enable = false;
|
||||
this.id = "";
|
||||
this.id = JSON_KEY_LIGHTNING_EFFECT_OFF;
|
||||
this.name = "";
|
||||
this.custom = false;
|
||||
this.brightness = 100;
|
||||
|
|
|
@ -91,7 +91,7 @@ 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.off = 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
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
<item-type>String</item-type>
|
||||
<label>Light Effect Theme</label>
|
||||
<description>Name of active lightning effect</description>
|
||||
<state readOnly="true">
|
||||
<state readOnly="false">
|
||||
<options>
|
||||
<option value="">None (No FX)</option>
|
||||
<option value="off">None (No FX)</option>
|
||||
<option value="custom">Custom</option>
|
||||
<option value="L1">Party</option>
|
||||
<option value="L2">Relax</option>
|
||||
|
|
Loading…
Reference in New Issue