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;
}
}
Aggregations