Search in sources :

Example 1 with CalDavBindingProvider

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);
    }
}
Also used : CalDavEvent(org.openhab.io.caldav.CalDavEvent) CalDavBindingProvider(org.openhab.binding.caldav_command.CalDavBindingProvider) CalDavQuery(org.openhab.io.caldav.CalDavQuery)

Example 2 with CalDavBindingProvider

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());
    }
}
Also used : OnOffType(org.openhab.core.library.types.OnOffType) CalDavBindingProvider(org.openhab.binding.caldav_command.CalDavBindingProvider)

Example 3 with CalDavBindingProvider

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);
    }
}
Also used : CalDavEvent(org.openhab.io.caldav.CalDavEvent) CalDavBindingProvider(org.openhab.binding.caldav_command.CalDavBindingProvider) CalDavQuery(org.openhab.io.caldav.CalDavQuery)

Aggregations

CalDavBindingProvider (org.openhab.binding.caldav_command.CalDavBindingProvider)3 CalDavEvent (org.openhab.io.caldav.CalDavEvent)2 CalDavQuery (org.openhab.io.caldav.CalDavQuery)2 OnOffType (org.openhab.core.library.types.OnOffType)1