Search in sources :

Example 1 with DiscoveryResultFlag

use of org.eclipse.smarthome.config.discovery.DiscoveryResultFlag in project smarthome by eclipse.

the class PersistentInbox method matchFilter.

private boolean matchFilter(DiscoveryResult discoveryResult, InboxFilterCriteria criteria) {
    if (criteria != null) {
        String bindingId = criteria.getBindingId();
        if ((bindingId != null) && (!bindingId.isEmpty())) {
            if (!discoveryResult.getBindingId().equals(bindingId)) {
                return false;
            }
        }
        ThingTypeUID thingTypeUID = criteria.getThingTypeUID();
        if (thingTypeUID != null) {
            if (!discoveryResult.getThingTypeUID().equals(thingTypeUID)) {
                return false;
            }
        }
        ThingUID thingUID = criteria.getThingUID();
        if (thingUID != null) {
            if (!discoveryResult.getThingUID().equals(thingUID)) {
                return false;
            }
        }
        DiscoveryResultFlag flag = criteria.getFlag();
        if (flag != null) {
            if (discoveryResult.getFlag() != flag) {
                return false;
            }
        }
    }
    return true;
}
Also used : DiscoveryResultFlag(org.eclipse.smarthome.config.discovery.DiscoveryResultFlag) InboxPredicates.forThingUID(org.eclipse.smarthome.config.discovery.inbox.InboxPredicates.forThingUID) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID)

Example 2 with DiscoveryResultFlag

use of org.eclipse.smarthome.config.discovery.DiscoveryResultFlag in project smarthome by eclipse.

the class InboxConsoleCommandExtension method clearInboxEntries.

private void clearInboxEntries(Console console, List<DiscoveryResult> discoveryResults) {
    if (discoveryResults.isEmpty()) {
        console.println("No inbox entries found.");
    }
    for (DiscoveryResult discoveryResult : discoveryResults) {
        ThingTypeUID thingTypeUID = discoveryResult.getThingTypeUID();
        ThingUID thingUID = discoveryResult.getThingUID();
        String label = discoveryResult.getLabel();
        DiscoveryResultFlag flag = discoveryResult.getFlag();
        ThingUID bridgeId = discoveryResult.getBridgeUID();
        Map<String, Object> properties = discoveryResult.getProperties();
        console.println(String.format("REMOVED [%s]: %s [label=%s, thingId=%s, bridgeId=%s, properties=%s]", flag.name(), thingTypeUID, label, thingUID, bridgeId, properties));
        inbox.remove(thingUID);
    }
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) DiscoveryResultFlag(org.eclipse.smarthome.config.discovery.DiscoveryResultFlag) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID)

Example 3 with DiscoveryResultFlag

use of org.eclipse.smarthome.config.discovery.DiscoveryResultFlag in project smarthome by eclipse.

the class InboxConsoleCommandExtension method printInboxEntries.

private void printInboxEntries(Console console, List<DiscoveryResult> discoveryResults) {
    if (discoveryResults.isEmpty()) {
        console.println("No inbox entries found.");
    }
    for (DiscoveryResult discoveryResult : discoveryResults) {
        ThingTypeUID thingTypeUID = discoveryResult.getThingTypeUID();
        ThingUID thingUID = discoveryResult.getThingUID();
        String label = discoveryResult.getLabel();
        DiscoveryResultFlag flag = discoveryResult.getFlag();
        ThingUID bridgeId = discoveryResult.getBridgeUID();
        Map<String, Object> properties = discoveryResult.getProperties();
        String representationProperty = discoveryResult.getRepresentationProperty();
        String timestamp = new Date(discoveryResult.getTimestamp()).toString();
        String timeToLive = discoveryResult.getTimeToLive() == DiscoveryResult.TTL_UNLIMITED ? "UNLIMITED" : "" + discoveryResult.getTimeToLive();
        console.println(String.format("%s [%s]: %s [thingId=%s, bridgeId=%s, properties=%s, representationProperty=%s, timestamp=%s, timeToLive=%s]", flag.name(), thingTypeUID, label, thingUID, bridgeId, properties, representationProperty, timestamp, timeToLive));
    }
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) DiscoveryResultFlag(org.eclipse.smarthome.config.discovery.DiscoveryResultFlag) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) Date(java.util.Date)

Aggregations

DiscoveryResultFlag (org.eclipse.smarthome.config.discovery.DiscoveryResultFlag)3 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)3 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)3 DiscoveryResult (org.eclipse.smarthome.config.discovery.DiscoveryResult)2 Date (java.util.Date)1 InboxPredicates.forThingUID (org.eclipse.smarthome.config.discovery.inbox.InboxPredicates.forThingUID)1