Search in sources :

Example 1 with OmniUnknownMessageTypeException

use of com.digitaldan.jomnilinkII.OmniUnknownMessageTypeException 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)

Aggregations

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