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