use of org.openhab.binding.caldav_command.CalDavBindingProvider in project openhab1-addons by openhab.
the class CalDavBinding method bindingChanged.
@Override
public void bindingChanged(BindingProvider provider, String itemName) {
if (provider.getItemNames().contains(itemName)) {
final CalDavNextEventConfig config = ((CalDavBindingProvider) provider).getConfig(itemName);
List<CalDavEvent> events = calDavLoader.getEvents(new CalDavQuery(this.readCalendars, DateTime.now()));
this.updateItemState(config, events);
}
}
use of org.openhab.binding.caldav_command.CalDavBindingProvider in project openhab1-addons by openhab.
the class CalDavBinding method internalReceiveCommand.
@Override
protected void internalReceiveCommand(String itemName, Command command) {
if (!(command instanceof OnOffType)) {
logger.trace("invalid command for DISABLE (just SwitchItems allowed)");
return;
}
// get binding provider
CalDavBindingProvider provider = getCalDavBindingProvider();
if (provider == null) {
logger.error("cannot find any provider");
return;
}
CalDavNextEventConfig config = provider.getConfig(itemName);
if (config == null) {
logger.error("no config found for item {}", itemName);
return;
}
if (config.getType() != CalDavType.DISABLE) {
logger.trace("can just use commands for type=DISABLE");
return;
}
if (command == OnOffType.ON) {
logger.info("execution for '{}' disabled", config.getItemNameToListenTo());
this.disabledItems.add(config.getItemNameToListenTo());
} else if (command == OnOffType.OFF) {
logger.info("execution for '{}' enabled", config.getItemNameToListenTo());
this.disabledItems.remove(config.getItemNameToListenTo());
}
}
use of org.openhab.binding.caldav_command.CalDavBindingProvider in project openhab1-addons by openhab.
the class CalDavBinding method handleForEventPreview.
private synchronized void handleForEventPreview() {
CalDavBindingProvider provider = getCalDavBindingProvider();
if (provider == null) {
logger.error("cannot find any provider");
return;
}
List<CalDavEvent> events = calDavLoader.getEvents(new CalDavQuery(this.readCalendars, DateTime.now()));
for (String configItemName : provider.getItemNames()) {
final CalDavNextEventConfig config = provider.getConfig(configItemName);
this.updateItemState(config, events);
}
}
Aggregations