Search in sources :

Example 1 with ThingStatusInfo

use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.

the class FSInternetRadioHandlerJavaTest method verifyConfigurationError.

private void verifyConfigurationError() {
    ThingStatusInfoBuilder statusBuilder = ThingStatusInfoBuilder.create(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
    ThingStatusInfo statusInfo = statusBuilder.withDescription("Configuration incomplete").build();
    verify(callback, atLeast(1)).statusUpdated(radioThing, statusInfo);
}
Also used : ThingStatusInfoBuilder(org.openhab.core.thing.binding.builder.ThingStatusInfoBuilder) ThingStatusInfo(org.openhab.core.thing.ThingStatusInfo)

Example 2 with ThingStatusInfo

use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.

the class FSInternetRadioHandlerJavaTest method verifyOnlineStatusIsSet.

private void verifyOnlineStatusIsSet() {
    ThingStatusInfoBuilder statusBuilder = ThingStatusInfoBuilder.create(ThingStatus.ONLINE, ThingStatusDetail.NONE);
    ThingStatusInfo statusInfo = statusBuilder.withDescription(null).build();
    verify(callback, atLeast(1)).statusUpdated(radioThing, statusInfo);
}
Also used : ThingStatusInfoBuilder(org.openhab.core.thing.binding.builder.ThingStatusInfoBuilder) ThingStatusInfo(org.openhab.core.thing.ThingStatusInfo)

Example 3 with ThingStatusInfo

use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.

the class HDPowerViewHubHandler method updateUnknownShadeThing.

private void updateUnknownShadeThing(Thing thing) {
    String shadeId = thing.getUID().getId();
    logger.debug("Shade '{}' has no data in hub", shadeId);
    HDPowerViewShadeHandler thingHandler = ((HDPowerViewShadeHandler) thing.getHandler());
    if (thingHandler == null) {
        logger.debug("Shade '{}' handler not initialized", shadeId);
        pendingShadeInitializations.put(thing.getUID(), new ShadeData());
        return;
    }
    ThingStatus thingStatus = thingHandler.getThing().getStatus();
    switch(thingStatus) {
        case UNKNOWN:
        case ONLINE:
        case OFFLINE:
            thing.setStatusInfo(new ThingStatusInfo(ThingStatus.OFFLINE, ThingStatusDetail.GONE, "@text/offline.gone.shade-unknown-to-hub"));
            break;
        case UNINITIALIZED:
        case INITIALIZING:
            logger.debug("Shade '{}' handler not yet ready; status: {}", shadeId, thingStatus);
            pendingShadeInitializations.put(thing.getUID(), new ShadeData());
            break;
        case REMOVING:
        case REMOVED:
        default:
            logger.debug("Ignoring shade status update for shade '{}' in status {}", shadeId, thingStatus);
            break;
    }
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus) ThingStatusInfo(org.openhab.core.thing.ThingStatusInfo) ShadeData(org.openhab.binding.hdpowerview.internal.api.responses.Shades.ShadeData)

Example 4 with ThingStatusInfo

use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.

the class HyperionNgHandler method updateOnlineStatus.

private void updateOnlineStatus(ThingStatus status, ThingStatusDetail detail, String message) {
    ThingStatusInfo currentStatusInfo = thing.getStatusInfo();
    ThingStatus currentStatus = currentStatusInfo.getStatus();
    ThingStatusDetail currentDetail = currentStatusInfo.getStatusDetail();
    if (!currentStatus.equals(status) || !currentDetail.equals(detail)) {
        updateStatus(status, detail, message);
    }
}
Also used : ThingStatus(org.openhab.core.thing.ThingStatus) ThingStatusDetail(org.openhab.core.thing.ThingStatusDetail) ThingStatusInfo(org.openhab.core.thing.ThingStatusInfo)

Example 5 with ThingStatusInfo

use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.

the class CircuitHandler method onDeviceAdded.

@Override
public void onDeviceAdded(GeneralDeviceInformation device) {
    if (device instanceof Circuit) {
        this.circuit = (Circuit) device;
        if (this.circuit.isPresent()) {
            ThingStatusInfo statusInfo = this.dssBridgeHandler.getThing().getStatusInfo();
            updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
            logger.debug("Set status to {}", getThing().getStatus());
            checkCircuitInfoProperties(this.circuit);
            // load first channel values
            onCircuitStateInitial(this.circuit);
            return;
        }
    }
    onDeviceRemoved(device);
}
Also used : Circuit(org.openhab.binding.digitalstrom.internal.lib.structure.devices.Circuit) ThingStatusInfo(org.openhab.core.thing.ThingStatusInfo)

Aggregations

ThingStatusInfo (org.openhab.core.thing.ThingStatusInfo)101 Test (org.junit.jupiter.api.Test)58 JavaOSGiTest (org.openhab.core.test.java.JavaOSGiTest)33 Thing (org.openhab.core.thing.Thing)22 ThingHandler (org.openhab.core.thing.binding.ThingHandler)22 ThingHandlerCallback (org.openhab.core.thing.binding.ThingHandlerCallback)20 ThingTypeUID (org.openhab.core.thing.ThingTypeUID)17 ThingHandlerFactory (org.openhab.core.thing.binding.ThingHandlerFactory)15 Nullable (org.eclipse.jdt.annotation.Nullable)14 Configuration (org.openhab.core.config.core.Configuration)13 ThingUID (org.openhab.core.thing.ThingUID)13 InvocationOnMock (org.mockito.invocation.InvocationOnMock)12 Bridge (org.openhab.core.thing.Bridge)12 JavaTest (org.openhab.core.test.java.JavaTest)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 DiscoveryResult (org.openhab.core.config.discovery.DiscoveryResult)5 BaseThingHandler (org.openhab.core.thing.binding.BaseThingHandler)5 ArrayList (java.util.ArrayList)4 NonNullByDefault (org.eclipse.jdt.annotation.NonNullByDefault)4