* @author Denis Dudnik - switched to internally integrated source of Jue library
* @author Christoph Weitkamp - Added support for bulbs using CIE XY colormode only
* @author Jochen Leopold - Added support for custom fade times
+ * @author Jacob Laursen - Add workaround for LK Wiser products
*/
@NonNullByDefault
public class HueLightHandler extends BaseThingHandler implements HueLightActionsHandler, LightStatusListener {
THING_TYPE_ON_OFF_LIGHT, THING_TYPE_ON_OFF_PLUG, THING_TYPE_DIMMABLE_PLUG);
public static final String OSRAM_PAR16_50_TW_MODEL_ID = "PAR16_50_TW";
+ public static final String LK_WISER_MODEL_ID = "LK_Dimmer";
private final Logger logger = LoggerFactory.getLogger(HueLightHandler.class);
private @Nullable Integer lastSentColorTemp;
private @Nullable Integer lastSentBrightness;
- // Flag to indicate whether the bulb is of type Osram par16 50 TW or not
+ /**
+ * Flag to indicate whether the bulb is of type Osram par16 50 TW
+ */
private boolean isOsramPar16 = false;
+ /**
+ * Flag to indicate whether the dimmer/relay is of type LK Wiser by Schneider Electric
+ */
+ private boolean isLkWiser = false;
private boolean propertiesInitializedSuccessfully = false;
private boolean capabilitiesInitializedSuccessfully = false;
String modelId = fullLight.getNormalizedModelID();
if (modelId != null) {
properties.put(PROPERTY_MODEL_ID, modelId);
+
+ switch (modelId) {
+ case OSRAM_PAR16_50_TW_MODEL_ID:
+ isOsramPar16 = true;
+ break;
+ case LK_WISER_MODEL_ID:
+ isLkWiser = true;
+ break;
+ }
}
properties.put(PROPERTY_VENDOR, fullLight.getManufacturerName());
properties.put(PRODUCT_NAME, fullLight.getProductName());
properties.put(UNIQUE_ID, uniqueID);
}
updateProperties(properties);
- isOsramPar16 = OSRAM_PAR16_50_TW_MODEL_ID.equals(modelId);
propertiesInitializedSuccessfully = true;
}
}
newState = LightStateConverter.toOnOffLightState((OnOffType) command);
if (isOsramPar16) {
newState = addOsramSpecificCommands(newState, (OnOffType) command);
+ } else if (isLkWiser) {
+ newState = addLkWiserSpecificCommands(newState, (OnOffType) command);
}
} else if (command instanceof IncreaseDecreaseType) {
newState = convertBrightnessChangeToStateUpdate((IncreaseDecreaseType) command, light);
newState = LightStateConverter.toOnOffLightState((OnOffType) command);
if (isOsramPar16) {
newState = addOsramSpecificCommands(newState, (OnOffType) command);
+ } else if (isLkWiser) {
+ newState = addLkWiserSpecificCommands(newState, (OnOffType) command);
}
}
lastColorTemp = lastSentColorTemp;
}
}
- /*
+ /**
* Applies additional {@link StateUpdate} commands as a workaround for Osram
* Lightify PAR16 TW firmware bug. Also see
* http://www.everyhue.com/vanilla/discussion/1756/solved-lightify-turning-off
return lightState;
}
+ /**
+ * Applies additional {@link StateUpdate} commands as a workaround for LK Wiser
+ * Dimmer/Relay firmware bug. Additional details here:
+ * https://techblog.vindvejr.dk/?p=455
+ */
+ private StateUpdate addLkWiserSpecificCommands(StateUpdate lightState, OnOffType actionType) {
+ if (actionType.equals(OnOffType.OFF)) {
+ lightState.setTransitionTime(0);
+ }
+ return lightState;
+ }
+
private @Nullable StateUpdate convertColorTempChangeToStateUpdate(IncreaseDecreaseType command, FullLight light) {
StateUpdate stateUpdate = null;
Integer currentColorTemp = getCurrentColorTemp(light.getState());
* @author Denis Dudnik - switched to internally integrated source of Jue library
* @author Simon Kaufmann - migrated to plain Java test
* @author Christoph Weitkamp - Added support for bulbs using CIE XY colormode only
+ * @author Jacob Laursen - Add workaround for LK Wiser products
*/
@NonNullByDefault
public class HueLightHandlerTest {
expectedReply);
}
+ @Test
+ public void assertCommandForLkWiserForBrightnessChannelOff() {
+ final String expectedReply = "{\"on\" : false, \"transitiontime\" : 0}";
+ final String vendor = "Schneider Electric";
+ assertSendCommand(CHANNEL_BRIGHTNESS, OnOffType.OFF,
+ new HueLightState(HueLightHandler.LK_WISER_MODEL_ID, vendor), expectedReply,
+ HueLightHandler.LK_WISER_MODEL_ID, vendor);
+ }
+
@Test
public void assertCommandForColorChannelOn() {
String expectedReply = "{\"on\" : true}";