use of org.openhab.binding.homematic.internal.communicator.client.HomematicClientException in project openhab1-addons by openhab.
the class HomematicPublisher method execute.
/**
* Sends or delays a event to a Homematic server.
*/
public void execute(final Event event) throws HomematicClientException {
double delay = event.getDelay();
if (delay > 0.0) {
synchronized (this) {
logger.debug("Delaying event for {} seconds: {}", delay, event.getHmValueItem());
Timer timer = delayedEvents.get(event.getBindingConfig());
if (timer != null) {
timer.cancel();
}
timer = new Timer();
delayedEvents.put(event.getBindingConfig(), timer);
timer.schedule(new TimerTask() {
@Override
public void run() {
try {
delayedEvents.remove(event.getBindingConfig());
sendToClient(event);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
}
}, (long) (delay * 1000));
}
} else {
sendToClient(event);
}
}
use of org.openhab.binding.homematic.internal.communicator.client.HomematicClientException in project openhab1-addons by openhab.
the class RemoteControlOptionParser method getSymbols.
/**
* Returns all possible symbols from the remote control.
*/
private String[] getSymbols() throws HomematicClientException {
DatapointConfig dpConfig = new DatapointConfig(remoteControlAddress, "18", "SUBMIT");
HmDatapoint rcDatapoint = (HmDatapoint) context.getStateHolder().getState(dpConfig);
if (rcDatapoint == null) {
throw new HomematicClientException("Address " + remoteControlAddress + " is not a Homematic remote control with a display");
}
List<String> symbols = new ArrayList<String>();
for (HmDatapoint datapoint : rcDatapoint.getChannel().getDatapoints()) {
if (datapoint.isWriteable() && datapoint.getValueType() == 2 && !"SUBMIT".equals(datapoint.getName())) {
symbols.add(datapoint.getName());
}
}
return symbols.toArray(new String[0]);
}
Aggregations