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");
}
}
}
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);
}
}
}
}
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;
}
}
}
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());
}
}
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());
}
}
Aggregations