Search in sources :

Example 6 with DSCAlarmBindingProvider

use of org.openhab.binding.dscalarm.DSCAlarmBindingProvider in project openhab1-addons by openhab.

the class DSCAlarmActiveBinding method bindingChanged.

/**
     * {@inheritDoc}
     */
@Override
public void bindingChanged(BindingProvider provider, String itemName) {
    logger.debug("bindingChanged(): Item Name: {}", itemName);
    boolean itemRemoved = false;
    int icount = provider.getItemNames().size();
    if (icount < itemCount) {
        itemRemoved = true;
    }
    if (itemRemoved) {
        dscAlarmUpdateMap.clear();
    } else {
        DSCAlarmBindingProvider dscAlarmBindingProvider = (DSCAlarmBindingProvider) provider;
        if (dscAlarmBindingProvider != null) {
            DSCAlarmBindingConfig dscAlarmBindingConfig = dscAlarmBindingProvider.getDSCAlarmBindingConfig(itemName);
            if (dscAlarmBindingConfig != null) {
                dscAlarmUpdateMap.put(itemName, dscAlarmBindingConfig);
            }
        }
    }
    itemCount = provider.getItemNames().size();
    itemHasChanged = true;
}
Also used : DSCAlarmBindingProvider(org.openhab.binding.dscalarm.DSCAlarmBindingProvider) DSCAlarmBindingConfig(org.openhab.binding.dscalarm.DSCAlarmBindingConfig)

Example 7 with DSCAlarmBindingProvider

use of org.openhab.binding.dscalarm.DSCAlarmBindingProvider in project openhab1-addons by openhab.

the class DSCAlarmActiveBinding method processUpdateMap.

/**
     * Processes the Update Items Map
     */
private void processUpdateMap() {
    if (dscAlarmUpdateMap.size() == 0) {
        logger.debug("processUpdateMap(): Nothing to update.");
        return;
    }
    Map<String, DSCAlarmBindingConfig> itemsMap = new HashMap<String, DSCAlarmBindingConfig>(dscAlarmUpdateMap);
    for (String itemName : itemsMap.keySet()) {
        DSCAlarmBindingConfig dscAlarmBindingConfig = itemsMap.get(itemName);
        dscAlarmUpdateMap.remove(itemName);
        Item item = null;
        for (DSCAlarmBindingProvider provider : providers) {
            item = provider.getItem(itemName);
        }
        if (dscAlarmBindingConfig.getDSCAlarmItemType().equals(DSCAlarmItemType.PANEL_COMMAND)) {
            dscAlarmItemUpdate.updateDeviceItem(item, dscAlarmBindingConfig, eventPublisher, null, -1, "");
        } else {
            dscAlarmItemUpdate.updateDeviceItem(item, dscAlarmBindingConfig, eventPublisher, null, 0, "");
        }
        logger.debug("processUpdateMap(): Updated item: {}", itemName);
    }
}
Also used : Item(org.openhab.core.items.Item) DSCAlarmBindingProvider(org.openhab.binding.dscalarm.DSCAlarmBindingProvider) HashMap(java.util.HashMap) DSCAlarmBindingConfig(org.openhab.binding.dscalarm.DSCAlarmBindingConfig)

Aggregations

DSCAlarmBindingConfig (org.openhab.binding.dscalarm.DSCAlarmBindingConfig)7 DSCAlarmBindingProvider (org.openhab.binding.dscalarm.DSCAlarmBindingProvider)7 Item (org.openhab.core.items.Item)3 HashMap (java.util.HashMap)1 DSCAlarmDeviceType (org.openhab.binding.dscalarm.internal.model.DSCAlarmDeviceType)1 APIMessage (org.openhab.binding.dscalarm.internal.protocol.APIMessage)1 OnOffType (org.openhab.core.library.types.OnOffType)1