Search in sources :

Example 1 with DeviceBindingConfig

use of org.openhab.binding.mios.internal.config.DeviceBindingConfig in project openhab1-addons by openhab.

the class MiosBinding method invokeMiosAction.

/**
     * {@inheritDoc}
     */
@Override
public boolean invokeMiosAction(String itemName, String actionName, List<Entry<String, Object>> params) {
    try {
        logger.debug("invokeMiosAction item {}, action {}, params {}", new Object[] { itemName, actionName, Integer.valueOf((params == null) ? 0 : params.size()) });
        boolean sent = false;
        // Lookup the MiOS Unit name and property for this item
        String unitName = getMiosUnitName(itemName);
        MiosUnitConnector connector = getMiosConnector(unitName);
        if (connector == null) {
            logger.warn("invokeMiosAction: Action call for item '{}' but no connector found for MiOS Unit '{}', ignoring", itemName, unitName);
            return false;
        }
        if (!connector.isConnected()) {
            logger.warn("invokeMiosAction: Action call for item '{}' but the connection to the MiOS Unit '{}' is down, ignoring", itemName, unitName);
            return false;
        }
        for (BindingProvider provider : providers) {
            if (provider instanceof MiosBindingProvider) {
                MiosBindingProviderImpl miosProvider = (MiosBindingProviderImpl) provider;
                MiosBindingConfig config = miosProvider.getMiosBindingConfig(itemName);
                if ((config != null) && (config instanceof DeviceBindingConfig)) {
                    connector.invokeAction((DeviceBindingConfig) config, actionName, params);
                    sent = true;
                } else {
                    logger.error("invokeMiosAction: Missing BindingConfig for item '{}', or not bound to a MiOS Device.", itemName);
                }
            }
        }
        return sent;
    } catch (Exception e) {
        logger.error("invokeMiosScene: Error handling command", e);
        return false;
    }
}
Also used : MiosBindingConfig(org.openhab.binding.mios.internal.config.MiosBindingConfig) MiosBindingProvider(org.openhab.binding.mios.MiosBindingProvider) MiosBindingProvider(org.openhab.binding.mios.MiosBindingProvider) BindingProvider(org.openhab.core.binding.BindingProvider) DeviceBindingConfig(org.openhab.binding.mios.internal.config.DeviceBindingConfig) ConfigurationException(org.osgi.service.cm.ConfigurationException)

Aggregations

MiosBindingProvider (org.openhab.binding.mios.MiosBindingProvider)1 DeviceBindingConfig (org.openhab.binding.mios.internal.config.DeviceBindingConfig)1 MiosBindingConfig (org.openhab.binding.mios.internal.config.MiosBindingConfig)1 BindingProvider (org.openhab.core.binding.BindingProvider)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1