Search in sources :

Example 1 with Value

use of org.openremote.protocol.zwave.model.commandclasses.channel.value.Value in project openremote by openremote.

the class ZWaveProtocol method doUnlinkAttribute.

@Override
protected synchronized void doUnlinkAttribute(String assetId, Attribute<?> attribute, ZWaveAgentLink agentLink) {
    if (network == null) {
        return;
    }
    AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
    Consumer<Value> sensorValueConsumer = sensorValueConsumerMap.remove(attributeRef);
    network.removeSensorValueConsumer(sensorValueConsumer);
}
Also used : AttributeRef(org.openremote.model.attribute.AttributeRef) Value(org.openremote.protocol.zwave.model.commandclasses.channel.value.Value)

Example 2 with Value

use of org.openremote.protocol.zwave.model.commandclasses.channel.value.Value in project openremote by openremote.

the class ZWaveProtocol method doLinkAttribute.

@Override
protected synchronized void doLinkAttribute(String assetId, Attribute<?> attribute, ZWaveAgentLink agentLink) {
    if (network == null) {
        return;
    }
    int nodeId = agentLink.getDeviceNodeId().orElse(0);
    int endpoint = agentLink.getDeviceEndpoint().orElse(0);
    String linkName = agentLink.getDeviceValue().orElse("");
    AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
    Class<?> clazz = (attribute == null ? null : attribute.getType().getType());
    Consumer<Value> sensorValueConsumer = value -> updateLinkedAttribute(new AttributeState(attributeRef, toAttributeValue(value, clazz)));
    sensorValueConsumerMap.put(attributeRef, sensorValueConsumer);
    network.addSensorValueConsumer(nodeId, endpoint, linkName, sensorValueConsumer);
}
Also used : AssetTreeNode(org.openremote.model.asset.AssetTreeNode) AttributeState(org.openremote.model.attribute.AttributeState) ConnectionStatus(org.openremote.model.asset.agent.ConnectionStatus) ColourRGB(org.openremote.model.value.impl.ColourRGB) AttributeRef(org.openremote.model.attribute.AttributeRef) ProtocolAssetDiscovery(org.openremote.model.protocol.ProtocolAssetDiscovery) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Value(org.openremote.protocol.zwave.model.commandclasses.channel.value.Value) Logger(java.util.logging.Logger) AbstractProtocol(org.openremote.agent.protocol.AbstractProtocol) Container(org.openremote.model.Container) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Consumer(java.util.function.Consumer) List(java.util.List) Future(java.util.concurrent.Future) Attribute(org.openremote.model.attribute.Attribute) AttributeEvent(org.openremote.model.attribute.AttributeEvent) Map(java.util.Map) AgentLink.getOrThrowAgentLinkProperty(org.openremote.model.asset.agent.AgentLink.getOrThrowAgentLinkProperty) SyslogCategory(org.openremote.model.syslog.SyslogCategory) AttributeState(org.openremote.model.attribute.AttributeState) AttributeRef(org.openremote.model.attribute.AttributeRef) Value(org.openremote.protocol.zwave.model.commandclasses.channel.value.Value)

Aggregations

AttributeRef (org.openremote.model.attribute.AttributeRef)2 Value (org.openremote.protocol.zwave.model.commandclasses.channel.value.Value)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Future (java.util.concurrent.Future)1 Consumer (java.util.function.Consumer)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 AbstractProtocol (org.openremote.agent.protocol.AbstractProtocol)1 Container (org.openremote.model.Container)1 AssetTreeNode (org.openremote.model.asset.AssetTreeNode)1 AgentLink.getOrThrowAgentLinkProperty (org.openremote.model.asset.agent.AgentLink.getOrThrowAgentLinkProperty)1 ConnectionStatus (org.openremote.model.asset.agent.ConnectionStatus)1 Attribute (org.openremote.model.attribute.Attribute)1 AttributeEvent (org.openremote.model.attribute.AttributeEvent)1 AttributeState (org.openremote.model.attribute.AttributeState)1 ProtocolAssetDiscovery (org.openremote.model.protocol.ProtocolAssetDiscovery)1