use of org.openhab.core.types.RefreshType in project omatic by seaside1.
the class OMaticMachineThingHandler method handleCommand.
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logDebug("Handling command = {} for channel = {}", command.getClass(), channelUID);
String channelId = channelUID.getIdWithoutGroup();
OMaticChannel channel = OMaticChannel.fromString(channelId);
if (command instanceof RefreshType) {
refreshChannel(channel, channelId);
return;
}
if (command instanceof OnOffType) {
updateOnOffChannel(channel, channelId, (OnOffType) command);
return;
}
}
use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.
the class BenqProjectorHandler method handleCommand.
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
String channelId = channelUID.getId();
if (command instanceof RefreshType) {
Channel channel = this.thing.getChannel(channelUID);
if (channel != null && getThing().getStatus() == ThingStatus.ONLINE) {
updateChannelState(channel);
}
} else {
BenqProjectorCommandType benqCommand = BenqProjectorCommandType.getCommandType(channelId);
sendDataToDevice(benqCommand, command);
}
}
use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.
the class Cm11aLampHandler method handleCommand.
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("**** Cm11aLampHandler handleCommand command = {}, channelUID = {}", command.toString(), channelUID.getAsString());
x10Function = 0;
Bridge bridge = getBridge();
if (bridge == null) {
logger.debug("Unable to handle command. Bridge is null.");
return;
}
this.channelUID = channelUID;
Cm11aBridgeHandler cm11aHandler = (Cm11aBridgeHandler) bridge.getHandler();
if (cm11aHandler != null && cm11aHandler.getThing().getStatus().equals(ThingStatus.ONLINE)) {
if (OnOffType.ON.equals(command)) {
desiredState = OnOffType.ON;
} else if (OnOffType.OFF.equals(command)) {
desiredState = OnOffType.OFF;
} else if (command instanceof PercentType) {
desiredState = (PercentType) command;
} else if (command instanceof RefreshType) {
// Refresh is triggered by framework during startup.
// Force the lamp off by indicating it is currently on and we want it off
// Start with it off
desiredState = PercentType.ZERO;
logger.info("Received REFRESH command for switch {}", houseUnitCode);
} else {
logger.error("Ignoring unknown command received for device: {}", houseUnitCode);
}
if (!(desiredState instanceof UnDefType)) {
X10Interface x10Interface = cm11aHandler.getX10Interface();
x10Interface.scheduleHWUpdate(this);
}
} else {
logger.error("Attempted to change switch {} cm11a is not online", houseUnitCode);
}
}
use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.
the class ComfoAirHandler method handleCommand.
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
String channelId = channelUID.getId();
if (comfoAirConnector != null) {
boolean isActive = !comfoAirConnector.getIsSuspended();
if (isActive || channelId.equals(ACTIVATE_CHANNEL_ID)) {
if (command instanceof RefreshType) {
Channel channel = this.thing.getChannel(channelUID);
if (channel != null) {
updateChannelState(channel);
}
} else {
ComfoAirCommand changeCommand = ComfoAirCommandType.getChangeCommand(channelId, command);
if (changeCommand != null) {
Set<String> keysToUpdate = getThing().getChannels().stream().map(Channel::getUID).filter(this::isLinked).map(ChannelUID::getId).collect(Collectors.toSet());
sendCommand(changeCommand, channelId);
Collection<ComfoAirCommand> affectedReadCommands = ComfoAirCommandType.getAffectedReadCommands(channelId, keysToUpdate);
if (!affectedReadCommands.isEmpty()) {
Runnable updateThread = new AffectedItemsUpdateThread(affectedReadCommands, keysToUpdate);
affectedItemsPoller = scheduler.schedule(updateThread, 3, TimeUnit.SECONDS);
}
} else {
logger.warn("Unhandled command type: {}, channelId: {}", command.toString(), channelId);
}
}
} else {
logger.debug("Binding control is currently not active.");
}
}
}
use of org.openhab.core.types.RefreshType in project openhab-addons by openhab.
the class CBusDaliHandler method handleCommand.
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
Group group = this.group;
if (group == null) {
return;
}
if (command instanceof RefreshType) {
try {
int level = group.getLevel();
logger.debug("handle RefreshType Command for Chanell {} Group {} level {}", channelUID, groupId, level);
if (channelUID.getId().equals(CBusBindingConstants.CHANNEL_LEVEL)) {
updateState(channelUID, new PercentType((int) (level * 100 / 255.0)));
}
} catch (CGateException e) {
logger.debug("Failed to getLevel for group {}", groupId, e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Communication Error");
}
} else {
if (channelUID.getId().equals(CBusBindingConstants.CHANNEL_LEVEL)) {
logger.debug("Channel Level command for {}: {}", channelUID, command);
try {
if (command instanceof OnOffType) {
if (command == OnOffType.ON) {
group.on();
} else if (command == OnOffType.OFF) {
group.off();
}
} else if (command instanceof PercentType) {
PercentType value = (PercentType) command;
group.ramp((int) Math.round(value.doubleValue() / 100 * 255), 0);
} else if (command instanceof IncreaseDecreaseType) {
int level = group.getLevel();
if (command == IncreaseDecreaseType.DECREASE) {
level = Math.max(level - 1, 0);
} else if (command == IncreaseDecreaseType.INCREASE) {
level = Math.min(level + 1, 255);
}
group.ramp(level, 0);
logger.debug("Change group level to {}", level);
}
} catch (CGateException e) {
logger.debug("Cannot send command {} to {}", command, group, e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Communication Error");
}
}
}
}
Aggregations