Java Code Examples for org.eclipse.smarthome.core.thing.ThingStatusDetail#CONFIGURATION_ERROR

The following examples show how to use org.eclipse.smarthome.core.thing.ThingStatusDetail#CONFIGURATION_ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DimmerThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    DimmerThingHandlerConfiguration configuration = getConfig().as(DimmerThingHandlerConfiguration.class);

    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    fadeTime = configuration.fadetime;
    logger.trace("setting fadeTime to {} ms in {}", fadeTime, this.thing.getUID());

    dimTime = configuration.dimtime;
    logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());

    String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";

    ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
    if (!turnOnValue.isEmpty()) {
        this.turnOnValue = turnOnValue;
        logger.trace("set turnonvalue to {} in {}", turnOnValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-on value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOnValue.setFadeTime(fadeTime);

    dynamicTurnOnValue = configuration.dynamicturnonvalue;

    String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
    ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
    if (!turnOffValue.isEmpty()) {
        this.turnOffValue = turnOffValue;
        logger.trace("set turnoffvalue to {} in {}", turnOffValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-off value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOffValue.setFadeTime(fadeTime);

    // register feedback listener
    channels.get(0).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS), this, ListenerType.VALUE);

    if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
        updateStatus(ThingStatus.ONLINE);
        dmxHandlerStatus = ThingStatusDetail.NONE;
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
    }
}
 
Example 2
Source File: ColorThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    ColorThingHandlerConfiguration configuration = getConfig().as(ColorThingHandlerConfiguration.class);
    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    currentValues.add(DmxChannel.MIN_VALUE);
    currentValues.add(DmxChannel.MIN_VALUE);
    currentValues.add(DmxChannel.MIN_VALUE);

    fadeTime = configuration.fadetime;
    logger.trace("setting fadeTime to {} ms in {}", fadeTime, this.thing.getUID());

    dimTime = configuration.dimtime;
    logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());

    String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";
    ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
    if (turnOnValue.size() % 3 == 0) {
        this.turnOnValue = turnOnValue;
        logger.trace("set turnonvalue to {} in {}", turnOnValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-on value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    this.turnOnValue.setFadeTime(fadeTime);

    dynamicTurnOnValue = configuration.dynamicturnonvalue;

    String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
    ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
    if (turnOffValue.size() % 3 == 0) {
        this.turnOffValue = turnOffValue;
        logger.trace("set turnoffvalue to {} in {}", turnOffValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-off value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOffValue.setFadeTime(fadeTime);

    // register feedback listeners
    channels.get(0).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_R), this,
            ListenerType.VALUE);
    channels.get(1).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_G), this,
            ListenerType.VALUE);
    channels.get(2).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_B), this,
            ListenerType.VALUE);

    if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
        updateStatus(ThingStatus.ONLINE);
        dmxHandlerStatus = ThingStatusDetail.NONE;
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
    }
}
 
Example 3
Source File: ChaserThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    ChaserThingHandlerConfiguration configuration = getConfig().as(ChaserThingHandlerConfiguration.class);

    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    if (!configuration.steps.isEmpty()) {
        if (parseChaserConfig(configuration.steps)) {
            if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
                updateStatus(ThingStatus.ONLINE);
                dmxHandlerStatus = ThingStatusDetail.NONE;
            } else {
                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
            }
        } else {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                    "Chase configuration malformed");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        }
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Chase configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
    }

    resumeAfter = configuration.resumeafter;
    logger.trace("set resumeAfter to {}", resumeAfter);
}
 
Example 4
Source File: TunableWhiteThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    TunableWhiteThingHandlerConfiguration configuration = getConfig()
            .as(TunableWhiteThingHandlerConfiguration.class);
    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    currentValues.add(DmxChannel.MIN_VALUE);
    currentValues.add(DmxChannel.MIN_VALUE);

    fadeTime = configuration.fadetime;
    logger.trace("setting fadeTime to {} ms in {}", fadeTime, this.thing.getUID());

    dimTime = configuration.dimtime;
    logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());

    String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";
    ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
    if (turnOnValue.size() % 2 == 0) {
        this.turnOnValue = turnOnValue;
        logger.trace("set turnonvalue to {} in {}", turnOnValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-on value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    this.turnOnValue.setFadeTime(fadeTime);

    dynamicTurnOnValue = configuration.dynamicturnonvalue;

    String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
    ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
    if (turnOffValue.size() % 2 == 0) {
        this.turnOffValue = turnOffValue;
        logger.trace("set turnoffvalue to {} in {}", turnOffValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-off value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOffValue.setFadeTime(fadeTime);

    // register feedback listeners
    channels.get(0).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_CW), this,
            ListenerType.VALUE);
    channels.get(1).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_WW), this,
            ListenerType.VALUE);

    if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
        updateStatus(ThingStatus.ONLINE);
        dmxHandlerStatus = ThingStatusDetail.NONE;
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
    }
}
 
Example 5
Source File: OwBaseThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * check if thing can be refreshed from the bridge handler
 *
 * @return true if thing can be refreshed
 */
public boolean isRefreshable() {
    return super.isInitialized()
            && this.thing.getStatusInfo().getStatusDetail() != ThingStatusDetail.CONFIGURATION_ERROR
            && this.thing.getStatusInfo().getStatusDetail() != ThingStatusDetail.BRIDGE_OFFLINE;
}