Search in sources :

Example 6 with RefreshType

use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.

the class CBusTemperatureHandler method handleCommand.

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
    // Read only thing - no commands to handle
    if (command instanceof RefreshType) {
        try {
            Group group = this.group;
            if (group != null) {
                int level = group.getLevel();
                logger.debug("handle RefreshType Command for Chanell {} Group {} level {}", channelUID, groupId, level);
                if (channelUID.getId().equals(CBusBindingConstants.CHANNEL_TEMP)) {
                    updateState(channelUID, new QuantityType<>(level, CELSIUS));
                }
            }
        } catch (CGateException e) {
            logger.debug("Failed to getLevel for group {}", groupId, e);
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Communication Error");
        }
    }
}
Also used : Group(com.daveoxley.cbus.Group) RefreshType(org.openhab.core.types.RefreshType) CGateException(com.daveoxley.cbus.CGateException)

Example 7 with RefreshType

use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.

the class DraytonWiserThingHandler method handleCommand.

@Override
public final void handleCommand(final ChannelUID channelUID, final Command command) {
    final HeatHubHandler heatHubHandler = getHeatHubHandler();
    if (heatHubHandler == null) {
        // if null status will be updated to offline
        return;
    }
    if (command instanceof RefreshType) {
        heatHubHandler.refresh();
    } else {
        final DraytonWiserApi api = this.api;
        if (api != null && data != null) {
            try {
                handleCommand(channelUID.getId(), command);
                // cancel previous refresh, but wait for it to finish, so no forced cancel
                disposehandleCommandRefreshFuture(false);
                // update the state after the heathub has had time to react
                handleCommandRefreshFuture = scheduler.schedule(heatHubHandler::refresh, 5, TimeUnit.SECONDS);
            } catch (final DraytonWiserApiException e) {
                logger.warn("Failed to handle command {} for channel {}: {}", command, channelUID, e.getMessage());
                logger.trace("DraytonWiserApiException", e);
            }
        }
    }
}
Also used : DraytonWiserApi(org.openhab.binding.draytonwiser.internal.api.DraytonWiserApi) DraytonWiserApiException(org.openhab.binding.draytonwiser.internal.api.DraytonWiserApiException) RefreshType(org.openhab.core.types.RefreshType)

Example 8 with RefreshType

use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.

the class DSCAlarmBaseBridgeHandler method handleCommand.

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
    logger.debug("handleCommand(): Command Received - {} {}.", channelUID, command);
    if (command instanceof RefreshType) {
        return;
    }
    if (isConnected()) {
        switch(channelUID.getId()) {
            case BRIDGE_RESET:
                if (command == OnOffType.OFF) {
                    disconnect();
                }
                break;
            case SEND_COMMAND:
                if (!command.toString().isEmpty()) {
                    String[] tokens = command.toString().split(",");
                    String cmd = tokens[0];
                    String data = "";
                    if (tokens.length > 1) {
                        data = tokens[1];
                    }
                    sendDSCAlarmCommand(cmd, data);
                    updateState(channelUID, new StringType(""));
                }
                break;
            default:
                break;
        }
    }
}
Also used : StringType(org.openhab.core.library.types.StringType) RefreshType(org.openhab.core.types.RefreshType)

Example 9 with RefreshType

use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.

the class FeedHandler method handleCommand.

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
    if (command instanceof RefreshType) {
        // safeguard for multiple REFRESH commands for different channels in a row
        if (isMinimumRefreshTimeExceeded()) {
            SyndFeed feed = fetchFeedData();
            updateFeedIfChanged(feed);
        }
        publishChannelIfLinked(channelUID);
    } else {
        logger.debug("Command {} is not supported for channel: {}. Supported command: REFRESH", command, channelUID.getId());
    }
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) RefreshType(org.openhab.core.types.RefreshType)

Example 10 with RefreshType

use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.

the class HeosChannelHandlerPlayURL method handleCommand.

private void handleCommand(Command command, String id) throws IOException, ReadException {
    if (command instanceof RefreshType) {
        return;
    }
    try {
        URL url = new URL(command.toString());
        getApi().playURL(id, url);
    } catch (MalformedURLException e) {
        logger.debug("Command '{}' is not a proper URL. Error: {}", command.toString(), e.getMessage());
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) RefreshType(org.openhab.core.types.RefreshType) URL(java.net.URL)

Aggregations

RefreshType (org.openhab.core.types.RefreshType)210 OnOffType (org.openhab.core.library.types.OnOffType)81 StringType (org.openhab.core.library.types.StringType)66 DecimalType (org.openhab.core.library.types.DecimalType)60 PercentType (org.openhab.core.library.types.PercentType)50 QuantityType (org.openhab.core.library.types.QuantityType)29 Channel (org.openhab.core.thing.Channel)26 State (org.openhab.core.types.State)26 IncreaseDecreaseType (org.openhab.core.library.types.IncreaseDecreaseType)25 IOException (java.io.IOException)22 Nullable (org.eclipse.jdt.annotation.Nullable)18 Bridge (org.openhab.core.thing.Bridge)18 ChannelUID (org.openhab.core.thing.ChannelUID)16 HSBType (org.openhab.core.library.types.HSBType)15 BigDecimal (java.math.BigDecimal)14 DateTimeType (org.openhab.core.library.types.DateTimeType)11 UpDownType (org.openhab.core.library.types.UpDownType)11 Temperature (javax.measure.quantity.Temperature)8 Thing (org.openhab.core.thing.Thing)8 Command (org.openhab.core.types.Command)8