use of org.openhab.binding.oceanic.OceanicValueSelector in project openhab1-addons by openhab.
the class OceanicBinding method internalReceiveCommand.
@Override
protected void internalReceiveCommand(String itemName, Command command) {
OceanicBindingProvider provider = findFirstMatchingBindingProvider(itemName);
String serialPort = provider.getSerialPort(itemName);
OceanicValueSelector valueSelector = OceanicValueSelector.getValueSelector(provider.getValueSelector(itemName), ValueSelectorType.SET);
SerialDevice serialDevice = serialDevices.get(serialPort);
if (valueSelector.name().contains("set")) {
String commandAsString = command.toString();
switch(valueSelector) {
case setSV1:
commandAsString = valueSelector.name() + commandAsString;
default:
commandAsString = valueSelector.name();
break;
}
String response = serialDevice.requestResponse(commandAsString);
if (response.equals("ERR")) {
logger.error("An error occurred while setting '{}' to {}", valueSelector.toString(), command.toString());
}
} else {
// can not set the value of a read-only "get" variable
logger.warn("An error occurred while trying to set the read-only variable '{}' to {}", valueSelector.toString(), command.toString());
}
}
Aggregations