Java Code Examples for org.eclipse.smarthome.core.thing.ChannelUID#getIdWithoutGroup()

The following examples show how to use org.eclipse.smarthome.core.thing.ChannelUID#getIdWithoutGroup() . 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: OpenWeatherMapUVIndexHandler.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Update the channel from the last OpenWeatherMap data retrieved.
 *
 * @param channelUID the id identifying the channel to be updated
 */
private void updateUVIndexChannel(ChannelUID channelUID) {
    String channelId = channelUID.getIdWithoutGroup();
    String channelGroupId = channelUID.getGroupId();
    if (uvindexData != null) {
        State state = UnDefType.UNDEF;
        switch (channelId) {
            case CHANNEL_TIME_STAMP:
                state = getDateTimeTypeState(uvindexData.getDate());
                break;
            case CHANNEL_UVINDEX:
                state = getDecimalTypeState(uvindexData.getValue());
                break;
        }
        logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state);
        updateState(channelUID, state);
    } else {
        logger.debug("No UV Index data available to update channel '{}' of group '{}'.", channelId, channelGroupId);
    }
}
 
Example 2
Source File: OpenWeatherMapUVIndexHandler.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Update the channel from the last OpenWeatherMap data retrieved.
 *
 * @param channelUID the id identifying the channel to be updated
 * @param count
 */
private void updateUVIndexForecastChannel(ChannelUID channelUID, int count) {
    String channelId = channelUID.getIdWithoutGroup();
    String channelGroupId = channelUID.getGroupId();
    if (uvindexForecastData != null && uvindexForecastData.size() >= count) {
        OpenWeatherMapJsonUVIndexData forecastData = uvindexForecastData.get(count - 1);
        State state = UnDefType.UNDEF;
        switch (channelId) {
            case CHANNEL_TIME_STAMP:
                state = getDateTimeTypeState(forecastData.getDate());
                break;
            case CHANNEL_UVINDEX:
                state = getDecimalTypeState(forecastData.getValue());
                break;
        }
        logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state);
        updateState(channelUID, state);
    } else {
        logger.debug("No UV Index data available to update channel '{}' of group '{}'.", channelId, channelGroupId);
    }
}
 
Example 3
Source File: OpenWeatherMapWeatherAndForecastHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Update the channel from the last OpenWeatherMap data retrieved.
 *
 * @param channelUID the id identifying the channel to be updated
 */
private void updateCurrentChannel(ChannelUID channelUID) {
    String channelId = channelUID.getIdWithoutGroup();
    String channelGroupId = channelUID.getGroupId();
    if (weatherData != null) {
        State state = UnDefType.UNDEF;
        switch (channelId) {
            case CHANNEL_STATION_ID:
                state = getStringTypeState(weatherData.getId().toString());
                break;
            case CHANNEL_STATION_NAME:
                state = getStringTypeState(weatherData.getName());
                break;
            case CHANNEL_STATION_LOCATION:
                state = getPointTypeState(weatherData.getCoord().getLat(), weatherData.getCoord().getLon());
                break;
            case CHANNEL_TIME_STAMP:
                state = getDateTimeTypeState(weatherData.getDt());
                break;
            case CHANNEL_CONDITION:
                state = getStringTypeState(weatherData.getWeather().get(0).getDescription());
                break;
            case CHANNEL_CONDITION_ID:
                state = getStringTypeState(weatherData.getWeather().get(0).getId().toString());
                break;
            case CHANNEL_CONDITION_ICON:
                state = getRawTypeState(
                        OpenWeatherMapConnection.getWeatherIcon(weatherData.getWeather().get(0).getIcon()));
                break;
            case CHANNEL_CONDITION_ICON_ID:
                state = getStringTypeState(weatherData.getWeather().get(0).getIcon());
                break;
            case CHANNEL_TEMPERATURE:
                state = getQuantityTypeState(weatherData.getMain().getTemp(), CELSIUS);
                break;
            case CHANNEL_PRESSURE:
                state = getQuantityTypeState(weatherData.getMain().getPressure(), HECTO(PASCAL));
                break;
            case CHANNEL_HUMIDITY:
                state = getQuantityTypeState(weatherData.getMain().getHumidity(), SmartHomeUnits.PERCENT);
                break;
            case CHANNEL_WIND_SPEED:
                state = getQuantityTypeState(weatherData.getWind().getSpeed(), SmartHomeUnits.METRE_PER_SECOND);
                break;
            case CHANNEL_WIND_DIRECTION:
                state = getQuantityTypeState(weatherData.getWind().getDeg(), SmartHomeUnits.DEGREE_ANGLE);
                break;
            case CHANNEL_GUST_SPEED:
                state = getQuantityTypeState(weatherData.getWind().getGust(), SmartHomeUnits.METRE_PER_SECOND);
                break;
            case CHANNEL_CLOUDINESS:
                state = getQuantityTypeState(weatherData.getClouds().getAll(), SmartHomeUnits.PERCENT);
                break;
            case CHANNEL_RAIN:
                state = getQuantityTypeState(
                        weatherData.getRain() == null || weatherData.getRain().get3h() == null ? 0
                                : weatherData.getRain().get3h(),
                        MILLI(METRE));
                break;
            case CHANNEL_SNOW:
                state = getQuantityTypeState(
                        weatherData.getSnow() == null || weatherData.getSnow().get3h() == null ? 0
                                : weatherData.getSnow().get3h(),
                        MILLI(METRE));
                break;
        }
        logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state);
        updateState(channelUID, state);
    } else {
        logger.debug("No weather data available to update channel '{}' of group '{}'.", channelId, channelGroupId);
    }
}
 
Example 4
Source File: OpenWeatherMapWeatherAndForecastHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Update the channel from the last OpenWeatherMap data retrieved.
 *
 * @param channelUID the id identifying the channel to be updated
 * @param count
 */
private void updateHourlyForecastChannel(ChannelUID channelUID, int count) {
    String channelId = channelUID.getIdWithoutGroup();
    String channelGroupId = channelUID.getGroupId();
    if (hourlyForecastData != null && hourlyForecastData.getList().size() > count) {
        org.eclipse.smarthome.binding.openweathermap.internal.model.forecast.hourly.List forecastData = hourlyForecastData
                .getList().get(count);
        State state = UnDefType.UNDEF;
        switch (channelId) {
            case CHANNEL_TIME_STAMP:
                state = getDateTimeTypeState(forecastData.getDt());
                break;
            case CHANNEL_CONDITION:
                state = getStringTypeState(forecastData.getWeather().get(0).getDescription());
                break;
            case CHANNEL_CONDITION_ID:
                state = getStringTypeState(forecastData.getWeather().get(0).getId().toString());
                break;
            case CHANNEL_CONDITION_ICON:
                state = getRawTypeState(
                        OpenWeatherMapConnection.getWeatherIcon(forecastData.getWeather().get(0).getIcon()));
                break;
            case CHANNEL_CONDITION_ICON_ID:
                state = getStringTypeState(forecastData.getWeather().get(0).getIcon());
                break;
            case CHANNEL_TEMPERATURE:
                state = getQuantityTypeState(forecastData.getMain().getTemp(), CELSIUS);
                break;
            case CHANNEL_PRESSURE:
                state = getQuantityTypeState(forecastData.getMain().getPressure(), HECTO(PASCAL));
                break;
            case CHANNEL_HUMIDITY:
                state = getQuantityTypeState(forecastData.getMain().getHumidity(), SmartHomeUnits.PERCENT);
                break;
            case CHANNEL_WIND_SPEED:
                state = getQuantityTypeState(forecastData.getWind().getSpeed(), SmartHomeUnits.METRE_PER_SECOND);
                break;
            case CHANNEL_WIND_DIRECTION:
                state = getQuantityTypeState(forecastData.getWind().getDeg(), SmartHomeUnits.DEGREE_ANGLE);
                break;
            case CHANNEL_GUST_SPEED:
                state = getQuantityTypeState(forecastData.getWind().getGust(), SmartHomeUnits.METRE_PER_SECOND);
                break;
            case CHANNEL_CLOUDINESS:
                state = getQuantityTypeState(forecastData.getClouds().getAll(), SmartHomeUnits.PERCENT);
                break;
            case CHANNEL_RAIN:
                state = getQuantityTypeState(
                        forecastData.getRain() == null || forecastData.getRain().get3h() == null ? 0
                                : forecastData.getRain().get3h(),
                        MILLI(METRE));
                break;
            case CHANNEL_SNOW:
                state = getQuantityTypeState(
                        forecastData.getSnow() == null || forecastData.getSnow().get3h() == null ? 0
                                : forecastData.getSnow().get3h(),
                        MILLI(METRE));
                break;
        }
        logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state);
        updateState(channelUID, state);
    } else {
        logger.debug("No weather data available to update channel '{}' of group '{}'.", channelId, channelGroupId);
    }
}
 
Example 5
Source File: OpenWeatherMapWeatherAndForecastHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Update the channel from the last OpenWeatherMap data retrieved.
 *
 * @param channelUID the id identifying the channel to be updated
 * @param count
 */
private void updateDailyForecastChannel(ChannelUID channelUID, int count) {
    String channelId = channelUID.getIdWithoutGroup();
    String channelGroupId = channelUID.getGroupId();
    if (dailyForecastData != null && dailyForecastData.getList().size() > count) {
        org.eclipse.smarthome.binding.openweathermap.internal.model.forecast.daily.List forecastData = dailyForecastData
                .getList().get(count);
        State state = UnDefType.UNDEF;
        switch (channelId) {
            case CHANNEL_TIME_STAMP:
                state = getDateTimeTypeState(forecastData.getDt());
                break;
            case CHANNEL_CONDITION:
                state = getStringTypeState(forecastData.getWeather().get(0).getDescription());
                break;
            case CHANNEL_CONDITION_ID:
                state = getStringTypeState(forecastData.getWeather().get(0).getId().toString());
                break;
            case CHANNEL_CONDITION_ICON:
                state = getRawTypeState(
                        OpenWeatherMapConnection.getWeatherIcon(forecastData.getWeather().get(0).getIcon()));
                break;
            case CHANNEL_CONDITION_ICON_ID:
                state = getStringTypeState(forecastData.getWeather().get(0).getIcon());
                break;
            case CHANNEL_MIN_TEMPERATURE:
                state = getQuantityTypeState(forecastData.getTemp().getMin(), CELSIUS);
                break;
            case CHANNEL_MAX_TEMPERATURE:
                state = getQuantityTypeState(forecastData.getTemp().getMax(), CELSIUS);
                break;
            case CHANNEL_PRESSURE:
                state = getQuantityTypeState(forecastData.getPressure(), HECTO(PASCAL));
                break;
            case CHANNEL_HUMIDITY:
                state = getQuantityTypeState(forecastData.getHumidity(), SmartHomeUnits.PERCENT);
                break;
            case CHANNEL_WIND_SPEED:
                state = getQuantityTypeState(forecastData.getSpeed(), SmartHomeUnits.METRE_PER_SECOND);
                break;
            case CHANNEL_WIND_DIRECTION:
                state = getQuantityTypeState(forecastData.getDeg(), SmartHomeUnits.DEGREE_ANGLE);
                break;
            case CHANNEL_GUST_SPEED:
                state = getQuantityTypeState(forecastData.getGust(), SmartHomeUnits.METRE_PER_SECOND);
                break;
            case CHANNEL_CLOUDINESS:
                state = getQuantityTypeState(forecastData.getClouds(), SmartHomeUnits.PERCENT);
                break;
            case CHANNEL_RAIN:
                state = getQuantityTypeState(forecastData.getRain() == null ? 0 : forecastData.getRain(),
                        MILLI(METRE));
                break;
            case CHANNEL_SNOW:
                state = getQuantityTypeState(forecastData.getSnow() == null ? 0 : forecastData.getSnow(),
                        MILLI(METRE));
                break;
        }
        logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state);
        updateState(channelUID, state);
    } else {
        logger.debug("No weather data available to update channel '{}' of group '{}'.", channelId, channelGroupId);
    }
}
 
Example 6
Source File: UidUtils.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Generates the HmDatapointInfo for the given thing and channelUID.
 */
public static HmDatapointInfo createHmDatapointInfo(ChannelUID channelUID) {
    return new HmDatapointInfo(channelUID.getThingUID().getId(), HmParamsetType.VALUES,
            NumberUtils.toInt(channelUID.getGroupId()), channelUID.getIdWithoutGroup());
}