use of org.openremote.agent.protocol.velbus.device.DevicePropertyValue in project openremote by openremote.
the class AbstractVelbusProtocol method doLinkAttribute.
@Override
protected void doLinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {
Pair<VelbusNetwork, Consumer<ConnectionStatus>> velbusNetworkConsumerPair = networkConfigurationMap.get(protocolConfiguration.getReferenceOrThrow());
if (velbusNetworkConsumerPair == null) {
LOG.info("Protocol Configuration doesn't have a valid VelbusNetwork so cannot link");
return;
}
VelbusNetwork velbusNetwork = velbusNetworkConsumerPair.key;
// Get the device that this attribute is linked to
int deviceAddress = getVelbusDeviceAddress(attribute);
// Get the property that this attribute is linked to
String property = getVelbusDevicePropertyLink(attribute);
AttributeRef attributeRef = attribute.getReferenceOrThrow();
ValueType valueType = attribute.getType().orElse(AttributeType.STRING).getValueType();
LOG.fine("Linking attribute to device '" + deviceAddress + "' and property '" + property + "': " + attributeRef);
Consumer<DevicePropertyValue> propertyValueConsumer = propertyValue -> updateLinkedAttribute(new AttributeState(attributeRef, propertyValue != null ? propertyValue.toValue(valueType) : null));
attributePropertyValueConsumers.put(attributeRef, propertyValueConsumer);
velbusNetwork.addPropertyValueConsumer(deviceAddress, property, propertyValueConsumer);
}
Aggregations