Search in sources :

Example 1 with OneWireDevicePropertyExecutableBindingConfig

use of org.openhab.binding.onewire.internal.deviceproperties.OneWireDevicePropertyExecutableBindingConfig in project openhab1-addons by openhab.

the class OneWireBinding method internalReceiveCommand.

@Override
protected void internalReceiveCommand(String pvItemName, Command pvCommand) {
    logger.debug("received command {} for item {}", pvCommand, pvItemName);
    OneWireBindingConfig lvBindigConfig = getBindingConfig(pvItemName);
    if (lvBindigConfig instanceof OneWireDevicePropertyExecutableBindingConfig) {
        // This Binding implements a special behavior
        logger.debug("call execute for item " + pvItemName);
        ((OneWireDevicePropertyExecutableBindingConfig) lvBindigConfig).execute(pvCommand);
    } else if (lvBindigConfig instanceof AbstractOneWireDevicePropertyWritableBindingConfig) {
        logger.debug("write to item " + pvItemName);
        AbstractOneWireDevicePropertyWritableBindingConfig lvWritableBindingConfig = (AbstractOneWireDevicePropertyWritableBindingConfig) lvBindigConfig;
        // Standard Write Operation
        String lvStringValue = lvWritableBindingConfig.convertTypeToString(pvCommand);
        OneWireConnection.writeToOneWire(lvWritableBindingConfig.getDevicePropertyPath(), lvStringValue);
    } else if (lvBindigConfig instanceof AbstractOneWireControlBindingConfig) {
        logger.debug("call executeControl for item " + pvItemName);
        AbstractOneWireControlBindingConfig lvControlBindingConfig = (AbstractOneWireControlBindingConfig) lvBindigConfig;
        lvControlBindingConfig.executeControl(this, pvCommand);
    } else {
        logger.debug("received command {} for item {} which is not writable or executable", pvCommand, pvItemName);
    }
}
Also used : AbstractOneWireControlBindingConfig(org.openhab.binding.onewire.internal.control.AbstractOneWireControlBindingConfig) OneWireDevicePropertyExecutableBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.OneWireDevicePropertyExecutableBindingConfig) AbstractOneWireDevicePropertyWritableBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyWritableBindingConfig)

Aggregations

AbstractOneWireControlBindingConfig (org.openhab.binding.onewire.internal.control.AbstractOneWireControlBindingConfig)1 AbstractOneWireDevicePropertyWritableBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyWritableBindingConfig)1 OneWireDevicePropertyExecutableBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.OneWireDevicePropertyExecutableBindingConfig)1