Search in sources :

Example 1 with OmniLinkBindingProvider

use of org.openhab.binding.omnilink.OmniLinkBindingProvider in project openhab1-addons by openhab.

the class OmniLinkBinding method internalReceiveCommand.

/**
     * @{inheritDoc
     */
@Override
protected void internalReceiveCommand(String itemName, Command command) {
    // the code being executed when a command was sent on the openHAB
    // event bus goes here. This method is only called if one of the
    // BindingProviders provide a binding for the given 'itemName'.
    logger.debug("internalReceiveCommand() is called!!! {} {} ", itemName, command);
    if (omniWorker != null && omniWorker.isConnected()) {
        for (OmniLinkBindingProvider provider : providers) {
            OmniLinkBindingConfig config = provider.getOmniLinkBindingConfig(itemName);
            Item item = provider.getItem(itemName);
            List<OmniLinkControllerCommand> commands = OmniLinkCommandMapper.getCommand(item, config, command);
            /*
                 * send each command we get back
                 */
            for (OmniLinkControllerCommand cmd : commands) {
                try {
                    logger.debug("Sending command {}/{}/{}", new Object[] { cmd.getCommand(), cmd.getParameter1(), cmd.getParameter2() });
                    omniWorker.getOmniConnection().controllerCommand(cmd.getCommand(), cmd.getParameter1(), cmd.getParameter2());
                    // little hack to get audio updates faster.
                    if (config.getObjectType() == OmniLinkItemType.AUDIOZONE_KEY) {
                        audioUpdateLock.notifyAll();
                    }
                } catch (IOException e) {
                    logger.error("Could not send command", e);
                } catch (OmniNotConnectedException e) {
                    logger.error("Could not send command", e);
                } catch (OmniInvalidResponseException e) {
                    logger.error("Could not send command", e);
                } catch (OmniUnknownMessageTypeException e) {
                    logger.error("Could not send command", e);
                }
            }
        }
    } else {
        logger.debug("Could not send message, connection not established {}", omniWorker == null);
    }
// get the
}
Also used : Item(org.openhab.core.items.Item) OmniInvalidResponseException(com.digitaldan.jomnilinkII.OmniInvalidResponseException) OmniLinkBindingProvider(org.openhab.binding.omnilink.OmniLinkBindingProvider) OmniNotConnectedException(com.digitaldan.jomnilinkII.OmniNotConnectedException) IOException(java.io.IOException) OmniUnknownMessageTypeException(com.digitaldan.jomnilinkII.OmniUnknownMessageTypeException)

Example 2 with OmniLinkBindingProvider

use of org.openhab.binding.omnilink.OmniLinkBindingProvider in project openhab1-addons by openhab.

the class OmniLinkBinding method updateItemsForDevice.

/**
     * Update any items linked to a Omni device.
     *
     * @param device
     */
protected void updateItemsForDevice(OmnilinkDevice device) {
    for (OmniLinkBindingProvider provider : providers) {
        for (String itemName : provider.getItemNames()) {
            OmniLinkBindingConfig bindingConfig = provider.getOmniLinkBindingConfig(itemName);
            OmnilinkDevice itemDevice = bindingConfig.getDevice();
            Item item = provider.getItem(itemName);
            if (itemDevice != null && itemDevice == device) {
                device.updateItem(item, bindingConfig, eventPublisher);
            }
        }
    }
}
Also used : Item(org.openhab.core.items.Item) OmniLinkBindingProvider(org.openhab.binding.omnilink.OmniLinkBindingProvider) OmnilinkDevice(org.openhab.binding.omnilink.internal.model.OmnilinkDevice)

Example 3 with OmniLinkBindingProvider

use of org.openhab.binding.omnilink.OmniLinkBindingProvider in project openhab1-addons by openhab.

the class OmniLinkBinding method allBindingsChanged.

/**
     * {@inheritDoc}
     */
@Override
public void allBindingsChanged(BindingProvider provider) {
    if (provider instanceof OmniLinkBindingProvider) {
        OmniLinkBindingProvider omniProvider = (OmniLinkBindingProvider) provider;
        populateRefreshMapFromProvider(omniProvider);
        logger.debug("all binding changed");
    }
}
Also used : OmniLinkBindingProvider(org.openhab.binding.omnilink.OmniLinkBindingProvider)

Example 4 with OmniLinkBindingProvider

use of org.openhab.binding.omnilink.OmniLinkBindingProvider in project openhab1-addons by openhab.

the class OmniLinkBinding method bindingChanged.

/**
     * {@inheritDoc}
     */
@Override
public void bindingChanged(BindingProvider provider, String itemName) {
    if (provider instanceof OmniLinkBindingProvider) {
        OmniLinkBindingProvider omniProvider = (OmniLinkBindingProvider) provider;
        logger.debug("binding changed");
        OmniLinkBindingConfig config = omniProvider.getOmniLinkBindingConfig(itemName);
        refreshMap.put(itemName, config);
    }
}
Also used : OmniLinkBindingProvider(org.openhab.binding.omnilink.OmniLinkBindingProvider)

Aggregations

OmniLinkBindingProvider (org.openhab.binding.omnilink.OmniLinkBindingProvider)4 Item (org.openhab.core.items.Item)2 OmniInvalidResponseException (com.digitaldan.jomnilinkII.OmniInvalidResponseException)1 OmniNotConnectedException (com.digitaldan.jomnilinkII.OmniNotConnectedException)1 OmniUnknownMessageTypeException (com.digitaldan.jomnilinkII.OmniUnknownMessageTypeException)1 IOException (java.io.IOException)1 OmnilinkDevice (org.openhab.binding.omnilink.internal.model.OmnilinkDevice)1