use of org.openhab.binding.pilight.PilightBindingProvider in project openhab1-addons by openhab.
the class PilightBinding method checkItemState.
/**
* Synchronize itemName with the current state in pilight.
*
* @param provider The PilightBindingProvider
* @param itemName The itemName in openHAB
*/
private void checkItemState(BindingProvider provider, final String itemName) {
PilightBindingProvider pilightProvider = (PilightBindingProvider) provider;
final PilightBindingConfig config = pilightProvider.getBindingConfig(itemName);
if (config != null) {
PilightConnection connection = connections.get(config.getInstance());
if (connection.isConnected()) {
connection.getConnector().refreshConfig(new IPilightConfigReceivedCallback() {
@Override
public void configReceived(PilightConnection connection) {
State state = getStateFromConfig(connection.getConfig(), config);
if (state != null) {
eventPublisher.postUpdate(itemName, state);
}
}
});
}
}
}
use of org.openhab.binding.pilight.PilightBindingProvider in project openhab1-addons by openhab.
the class PilightBinding method internalReceiveCommand.
/**
* @{inheritDoc}
*/
@Override
protected void internalReceiveCommand(String itemName, Command command) {
PilightBindingProvider provider = findFirstMatchingBindingProvider(itemName);
PilightBindingConfig config = provider.getBindingConfig(itemName);
PilightConnection connection = connections.get(config.getInstance());
Action action = createUpdateCommand(command, config);
if (action != null) {
sendUpdate(action, connection);
}
}
Aggregations