Search in sources :

Example 1 with HorizonBindingProvider

use of org.openhab.binding.horizon.HorizonBindingProvider in project openhab1-addons by openhab.

the class HorizonBinding method internalReceiveCommand.

/**
     * {@inheritDoc}
     */
@Override
protected void internalReceiveCommand(String itemName, Command command) {
    logger.debug("internalReceiveCommand({},{}) is called!", itemName, command);
    HorizonBindingProvider horizonBindingProvider = findFirstMatchingBindingProvider(itemName, command);
    String horizonKeyWithHorizonId = horizonBindingProvider.getHorizonCommand(itemName, command.toString());
    String[] horizonKeyWithHorizonIdSplit = horizonKeyWithHorizonId.split(":");
    String horizonId = horizonKeyWithHorizonIdSplit[0];
    String horizonKey = horizonKeyWithHorizonIdSplit[1];
    HorizonBox horizonBox = deviceConfigCache.get(horizonId);
    if (horizonBox != null) {
        try {
            horizonBox.sendKey(Integer.valueOf(horizonKey));
        } catch (Exception e) {
            logger.error("Error sending key to device with device id '{}'", horizonId, e);
        }
    } else {
        logger.warn("Cannot find connection details for device id '{}'", horizonId);
    }
}
Also used : HorizonBindingProvider(org.openhab.binding.horizon.HorizonBindingProvider) HorizonBox(org.openhab.binding.horizon.internal.control.HorizonBox) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

ConfigurationException (javax.naming.ConfigurationException)1 HorizonBindingProvider (org.openhab.binding.horizon.HorizonBindingProvider)1 HorizonBox (org.openhab.binding.horizon.internal.control.HorizonBox)1