Search in sources :

Example 1 with FS20BindingProvider

use of org.openhab.binding.fs20.FS20BindingProvider in project openhab1-addons by openhab.

the class FS20Binding method internalReceiveCommand.

/**
     * @{inheritDoc
     */
@Override
protected void internalReceiveCommand(String itemName, Command command) {
    FS20BindingConfig bindingConfig = null;
    for (FS20BindingProvider provider : super.providers) {
        bindingConfig = provider.getConfigForItemName(itemName);
        if (bindingConfig != null) {
            break;
        }
    }
    if (bindingConfig != null) {
        logger.debug("Received command " + command.toString() + " for item " + itemName);
        try {
            FS20Command fs20Command = FS20CommandHelper.convertHABCommandToFS20Command(command);
            culHandlerLifecycle.getCul().send("F" + bindingConfig.getAddress() + fs20Command.getHexValue());
        } catch (CULCommunicationException e) {
            logger.error("An exception occured while sending a command", e);
        }
    }
}
Also used : FS20BindingConfig(org.openhab.binding.fs20.FS20BindingConfig) FS20BindingProvider(org.openhab.binding.fs20.FS20BindingProvider) CULCommunicationException(org.openhab.io.transport.cul.CULCommunicationException)

Example 2 with FS20BindingProvider

use of org.openhab.binding.fs20.FS20BindingProvider in project openhab1-addons by openhab.

the class FS20Binding method handleReceivedMessage.

private void handleReceivedMessage(String message) {
    String houseCode = (message.substring(1, 5));
    String address = (message.substring(5, 7));
    String command = message.substring(7, 9);
    String fullAddress = houseCode + address;
    FS20BindingConfig config = null;
    for (FS20BindingProvider provider : providers) {
        config = provider.getConfigForAddress(fullAddress);
        if (config != null) {
            break;
        }
    }
    if (config != null) {
        FS20Command fs20Command = FS20Command.getFromHexValue(command);
        logger.debug("Received command " + fs20Command.toString() + " for device " + config.getAddress());
        eventPublisher.postUpdate(config.getItem().getName(), FS20CommandHelper.getStateFromFS20Command(fs20Command));
    } else {
        logger.debug("Received message for unknown device " + fullAddress);
    }
}
Also used : FS20BindingConfig(org.openhab.binding.fs20.FS20BindingConfig) FS20BindingProvider(org.openhab.binding.fs20.FS20BindingProvider)

Aggregations

FS20BindingConfig (org.openhab.binding.fs20.FS20BindingConfig)2 FS20BindingProvider (org.openhab.binding.fs20.FS20BindingProvider)2 CULCommunicationException (org.openhab.io.transport.cul.CULCommunicationException)1