Source:
<code>private void updateChannel(String channelId) { Channel channel = getThing().getChannel(channelId); if (channel == null || !isLinked(channelId)) { logger.trace("Channel '{}' was null or not linked! Not updated.", channelId); return; } String[] channelParts = channelId.split("#"); String forecastDay = channelParts[0]; String datapointName = channelParts[1]; if (channelParts.length != 2) { logger.debug("Skipped invalid channelId '{}'", channelId); return; } logger.debug("Updating channel '{}'", channelId); Forecast forecast = getForecast(forecastDay); if (forecast == null) { logger.debug("No forecast found for '{}'. Not updating.", forecastDay); return; } Object datapoint = forecast.getDatapoint(datapointName); logger.debug("Value for datapoint '{}' is '{}'", datapointName, datapoint); State state = null; if (datapoint == null) { <START> state = UnDefType.UNDEF; <END> } else if (datapoint instanceof Calendar) { state = new DateTimeType((Calendar) datapoint); } else if (datapoint instanceof Integer) { state = getStateForType(channel.getAcceptedItemType(), (Integer) datapoint); } else if (datapoint instanceof Number) { BigDecimal decimalValue = new BigDecimal(datapoint.toString()).setScale(2, RoundingMode.HALF_UP); state = getStateForType(channel.getAcceptedItemType(), decimalValue); } else if (datapoint instanceof String) { state = new StringType(datapoint.toString()); } else if (datapoint instanceof BufferedImage) { ImageItem item = new ImageItem("rain area"); state = new RawType(renderImage((BufferedImage) datapoint), "image/png"); item.setState(state); } else { logger.debug("Unsupported value type {}", datapoint.getClass().getSimpleName()); } if (state != null) { logger.trace("Updating channel with state value {}. (object type {})", state, (datapoint == null) ? "null" : datapoint.getClass().getSimpleName()); updateState(channelId, state); } }</code><technical_language>In situations datapoint null? Note UNDEF means: "I a value, I express a state". If service simply provide current value, simply send state update all</technical_language>

Target:
private void updateChannel(String channelId) { Channel channel = getThing().getChannel(channelId); if (channel == null || !isLinked(channelId)) { logger.trace("Channel '{}' was null or not linked! Not updated.", channelId); return; } String[] channelParts = channelId.split("#"); String forecastDay = channelParts[0]; String datapointName = channelParts[1]; if (channelParts.length != 2) { logger.debug("Skipped invalid channelId '{}'", channelId); return; } logger.debug("Updating channel '{}'", channelId); Forecast forecast = getForecast(forecastDay); if (forecast == null) { logger.debug("No forecast found for '{}'. Not updating.", forecastDay); return; } Object datapoint = forecast.getDatapoint(datapointName); logger.debug("Value for datapoint '{}' is '{}'", datapointName, datapoint); if (datapoint == null) { logger.debug("Couldn't get datapoint '{}' for '{}'. Not updating.", datapointName, forecastDay); return; } State state = null; if (datapoint instanceof Calendar) { state = new DateTimeType((Calendar) datapoint); } else if (datapoint instanceof Integer) { state = getStateForType(channel.getAcceptedItemType(), (Integer) datapoint); } else if (datapoint instanceof Number) { BigDecimal decimalValue = new BigDecimal(datapoint.toString()).setScale(2, RoundingMode.HALF_UP); state = getStateForType(channel.getAcceptedItemType(), decimalValue); } else if (datapoint instanceof String) { state = new StringType(datapoint.toString()); } else if (datapoint instanceof BufferedImage) { ImageItem item = new ImageItem("rain area"); state = new RawType(renderImage((BufferedImage) datapoint), "image/png"); item.setState(state); } else { logger.debug("Unsupported value type {}", datapoint.getClass().getSimpleName()); } if (state != null) { logger.trace("Updating channel with state value {}. (object type {})", state, datapoint.getClass().getSimpleName()); updateState(channelId, state); } }