Search in sources :

Example 1 with TradfriLightData

use of org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData in project smarthome by eclipse.

the class TradfriLightHandler method setState.

private void setState(OnOffType onOff) {
    TradfriLightData data = new TradfriLightData();
    data.setOnOffState(onOff == OnOffType.ON);
    set(data.getJsonString());
}
Also used : TradfriLightData(org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData)

Example 2 with TradfriLightData

use of org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData in project smarthome by eclipse.

the class TradfriLightHandler method onUpdate.

@Override
public void onUpdate(JsonElement data) {
    if (active && !(data.isJsonNull())) {
        state = new TradfriLightData(data);
        updateStatus(state.getReachabilityStatus() ? ThingStatus.ONLINE : ThingStatus.OFFLINE);
        if (!state.getOnOffState()) {
            logger.debug("Setting state to OFF");
            updateState(CHANNEL_BRIGHTNESS, PercentType.ZERO);
            if (lightHasColorSupport()) {
                updateState(CHANNEL_COLOR, HSBType.BLACK);
            }
            // if we are turned off, we do not set any brightness value
            return;
        }
        PercentType dimmer = state.getBrightness();
        if (dimmer != null && !lightHasColorSupport()) {
            // color lights do not have brightness channel
            updateState(CHANNEL_BRIGHTNESS, dimmer);
        }
        PercentType colorTemp = state.getColorTemperature();
        if (colorTemp != null) {
            updateState(CHANNEL_COLOR_TEMPERATURE, colorTemp);
        }
        HSBType color = null;
        if (lightHasColorSupport()) {
            color = state.getColor();
            if (color != null) {
                updateState(CHANNEL_COLOR, color);
            }
        }
        updateDeviceProperties(state);
        logger.debug("Updating thing for lightId {} to state {dimmer: {}, colorTemp: {}, color: {}, firmwareVersion: {}, modelId: {}, vendor: {}}", state.getDeviceId(), dimmer, colorTemp, color, state.getFirmwareVersion(), state.getModelId(), state.getVendor());
    }
}
Also used : TradfriLightData(org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData) PercentType(org.eclipse.smarthome.core.library.types.PercentType) HSBType(org.eclipse.smarthome.core.library.types.HSBType)

Example 3 with TradfriLightData

use of org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData in project smarthome by eclipse.

the class TradfriLightHandler method setBrightness.

private void setBrightness(PercentType percent) {
    TradfriLightData data = new TradfriLightData();
    data.setBrightness(percent).setTransitionTime(DEFAULT_DIMMER_TRANSITION_TIME);
    set(data.getJsonString());
}
Also used : TradfriLightData(org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData)

Example 4 with TradfriLightData

use of org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData in project smarthome by eclipse.

the class TradfriLightHandler method setColorTemperature.

private void setColorTemperature(PercentType percent) {
    TradfriLightData data = new TradfriLightData();
    data.setColorTemperature(percent).setTransitionTime(DEFAULT_DIMMER_TRANSITION_TIME);
    set(data.getJsonString());
}
Also used : TradfriLightData(org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData)

Example 5 with TradfriLightData

use of org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData in project smarthome by eclipse.

the class TradfriLightHandler method setColor.

private void setColor(HSBType hsb) {
    TradfriLightData data = new TradfriLightData();
    data.setColor(hsb).setTransitionTime(DEFAULT_DIMMER_TRANSITION_TIME);
    set(data.getJsonString(), 1000);
}
Also used : TradfriLightData(org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData)

Aggregations

TradfriLightData (org.eclipse.smarthome.binding.tradfri.internal.model.TradfriLightData)5 HSBType (org.eclipse.smarthome.core.library.types.HSBType)1 PercentType (org.eclipse.smarthome.core.library.types.PercentType)1