Search in sources :

Example 1 with PilightBindingProvider

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);
                    }
                }
            });
        }
    }
}
Also used : PilightBindingProvider(org.openhab.binding.pilight.PilightBindingProvider) State(org.openhab.core.types.State)

Example 2 with PilightBindingProvider

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);
    }
}
Also used : PilightBindingProvider(org.openhab.binding.pilight.PilightBindingProvider) Action(org.openhab.binding.pilight.internal.communication.Action)

Aggregations

PilightBindingProvider (org.openhab.binding.pilight.PilightBindingProvider)2 Action (org.openhab.binding.pilight.internal.communication.Action)1 State (org.openhab.core.types.State)1