/* (non-Javadoc) * @see org.openhab.core.binding.AbstractBinding#addBindingProvider(org.openhab.core.binding.BindingProvider) */ @Override public void addBindingProvider(EBusBindingProvider provider) { super.addBindingProvider(provider); if (commandProcessor == null) { commandProcessor = new EBusCommandProcessor(); commandProcessor.setConfigurationProvider(configurationProvider); } if (provider.providesBinding()) { // items already processed, so too late for this listener. do it manually commandProcessor.allBindingsChanged(provider); } provider.addBindingChangeListener(commandProcessor); }
/* (non-Javadoc) * @see org.openhab.binding.ebus.connection.EBusConnectorEventListener#onTelegramReceived(org.openhab.binding.ebus.EbusTelegram) */ @Override public void onTelegramReceived(EBusTelegram telegram) { // parse the raw telegram to a key/value map final Map<String, Object> results = parser.parse(telegram); if (results == null) { logger.debug("No valid parser result for raw telegram!"); return; } for (Entry<String, Object> entry : results.entrySet()) { State state = StateUtils.convertToState(entry.getValue()); // process if the state is set if (state != null) { // loop over all items to update the state for (EBusBindingProvider provider : providers) { for (String itemName : provider.getItemNames(entry.getKey())) { Byte telegramSource = provider.getTelegramSource(itemName); Byte telegramDestination = provider.getTelegramDestination(itemName); // check if this item has a src or dst defined if (telegramSource == null || telegram.getSource() == telegramSource) { if (telegramDestination == null || telegram.getDestination() == telegramDestination) { eventPublisher.postUpdate(itemName, state); } } } } // for } // if } }
/* (non-Javadoc) * @see org.openhab.core.binding.AbstractBinding#removeBindingProvider(org.openhab.core.binding.BindingProvider) */ @Override public void removeBindingProvider(EBusBindingProvider provider) { super.removeBindingProvider(provider); provider.removeBindingChangeListener(commandProcessor); }