Search in sources :

Example 56 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class LifxLightHandler method handleIncreaseDecreaseTemperatureCommand.

private void handleIncreaseDecreaseTemperatureCommand(IncreaseDecreaseType increaseDecrease) {
    PercentType baseTemperature = getLightStateForCommand().getNullSafeColor().getTemperature();
    PercentType newTemperature = increaseDecreasePercentType(increaseDecrease, baseTemperature);
    handleTemperatureCommand(newTemperature);
}
Also used : PercentType(org.eclipse.smarthome.core.library.types.PercentType) LifxMessageUtil.increaseDecreasePercentType(org.eclipse.smarthome.binding.lifx.internal.util.LifxMessageUtil.increaseDecreasePercentType)

Example 57 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class LifxLightHandler method handleIncreaseDecreaseCommand.

private void handleIncreaseDecreaseCommand(IncreaseDecreaseType increaseDecrease) {
    HSBK baseColor = getLightStateForCommand().getNullSafeColor();
    PercentType newBrightness = increaseDecreasePercentType(increaseDecrease, baseColor.getHSB().getBrightness());
    handlePercentCommand(newBrightness);
}
Also used : HSBK(org.eclipse.smarthome.binding.lifx.internal.fields.HSBK) PercentType(org.eclipse.smarthome.core.library.types.PercentType) LifxMessageUtil.increaseDecreasePercentType(org.eclipse.smarthome.binding.lifx.internal.util.LifxMessageUtil.increaseDecreasePercentType)

Example 58 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class LifxLightHandler method handleIncreaseDecreaseTemperatureCommand.

private void handleIncreaseDecreaseTemperatureCommand(IncreaseDecreaseType increaseDecrease, int zoneIndex) {
    PercentType baseTemperature = getLightStateForCommand().getNullSafeColor(zoneIndex).getTemperature();
    PercentType newTemperature = increaseDecreasePercentType(increaseDecrease, baseTemperature);
    handleTemperatureCommand(newTemperature, zoneIndex);
}
Also used : PercentType(org.eclipse.smarthome.core.library.types.PercentType) LifxMessageUtil.increaseDecreasePercentType(org.eclipse.smarthome.binding.lifx.internal.util.LifxMessageUtil.increaseDecreasePercentType)

Example 59 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class LifxLightState method setInfrared.

public void setInfrared(PercentType newInfrared) {
    PercentType oldInfrared = this.infrared;
    this.infrared = newInfrared;
    updateLastChange();
    listeners.forEach(listener -> listener.handleInfraredChange(oldInfrared, newInfrared));
}
Also used : PercentType(org.eclipse.smarthome.core.library.types.PercentType)

Example 60 with PercentType

use of org.eclipse.smarthome.core.library.types.PercentType in project smarthome by eclipse.

the class HueLightHandler method onLightStateChanged.

@Override
public void onLightStateChanged(@Nullable HueBridge bridge, FullLight fullLight) {
    logger.trace("onLightStateChanged() was called");
    if (!fullLight.getId().equals(lightId)) {
        logger.trace("Received state change for another handler's light ({}). Will be ignored.", fullLight.getId());
        return;
    }
    initializeProperties();
    lastSentColorTemp = null;
    lastSentBrightness = null;
    // update status (ONLINE, OFFLINE)
    if (fullLight.getState().isReachable()) {
        updateStatus(ThingStatus.ONLINE);
    } else {
        // we assume OFFLINE without any error (NONE), as this is an
        // expected state (when bulb powered off)
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "@text/offline.light-not-reachable");
    }
    HSBType hsbType = LightStateConverter.toHSBType(fullLight.getState());
    if (!fullLight.getState().isOn()) {
        hsbType = new HSBType(hsbType.getHue(), hsbType.getSaturation(), new PercentType(0));
    }
    updateState(CHANNEL_COLOR, hsbType);
    PercentType percentType = LightStateConverter.toColorTemperaturePercentType(fullLight.getState());
    updateState(CHANNEL_COLORTEMPERATURE, percentType);
    percentType = LightStateConverter.toBrightnessPercentType(fullLight.getState());
    if (!fullLight.getState().isOn()) {
        percentType = new PercentType(0);
    }
    updateState(CHANNEL_BRIGHTNESS, percentType);
    if (fullLight.getState().isOn()) {
        updateState(CHANNEL_SWITCH, OnOffType.ON);
    } else {
        updateState(CHANNEL_SWITCH, OnOffType.OFF);
    }
    StringType stringType = LightStateConverter.toAlertStringType(fullLight.getState());
    if (!stringType.toString().equals("NULL")) {
        updateState(CHANNEL_ALERT, stringType);
        scheduleAlertStateRestore(stringType);
    }
}
Also used : StringType(org.eclipse.smarthome.core.library.types.StringType) PercentType(org.eclipse.smarthome.core.library.types.PercentType) HSBType(org.eclipse.smarthome.core.library.types.HSBType)

Aggregations

PercentType (org.eclipse.smarthome.core.library.types.PercentType)63 Test (org.junit.Test)25 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)17 State (org.eclipse.smarthome.core.types.State)17 HSBType (org.eclipse.smarthome.core.library.types.HSBType)16 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)13 LifxMessageUtil.increaseDecreasePercentType (org.eclipse.smarthome.binding.lifx.internal.util.LifxMessageUtil.increaseDecreasePercentType)9 StringType (org.eclipse.smarthome.core.library.types.StringType)9 IncreaseDecreaseType (org.eclipse.smarthome.core.library.types.IncreaseDecreaseType)7 RefreshType (org.eclipse.smarthome.core.types.RefreshType)7 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)6 ColorItem (org.eclipse.smarthome.core.library.items.ColorItem)4 RollershutterItem (org.eclipse.smarthome.core.library.items.RollershutterItem)4 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)4 BigDecimal (java.math.BigDecimal)3 ValueSet (org.eclipse.smarthome.binding.dmx.internal.ValueSet)3 FadeAction (org.eclipse.smarthome.binding.dmx.internal.action.FadeAction)3 DimmerItem (org.eclipse.smarthome.core.library.items.DimmerItem)3 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)3 LinkedList (java.util.LinkedList)2