Search in sources :

Example 16 with ThingStatusInfo

use of org.eclipse.smarthome.core.thing.ThingStatusInfo in project smarthome by eclipse.

the class FSInternetRadioHandlerJavaTest method verifyCommunicationError.

private void verifyCommunicationError(String exceptionMessage) {
    ArgumentCaptor<ThingStatusInfo> captor = ArgumentCaptor.forClass(ThingStatusInfo.class);
    verify(callback, atLeast(1)).statusUpdated(isA(Thing.class), captor.capture());
    ThingStatusInfo status = captor.getValue();
    assertThat(status.getStatus(), is(ThingStatus.OFFLINE));
    assertThat(status.getStatusDetail(), is(ThingStatusDetail.COMMUNICATION_ERROR));
    assertThat(status.getDescription().contains(exceptionMessage), is(true));
}
Also used : ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo) Thing(org.eclipse.smarthome.core.thing.Thing)

Example 17 with ThingStatusInfo

use of org.eclipse.smarthome.core.thing.ThingStatusInfo in project smarthome by eclipse.

the class MagicDimmableLightHandlerTest method initializeShouldCallTheCallback.

@Test
public void initializeShouldCallTheCallback() {
    handler.initialize();
    ArgumentCaptor<ThingStatusInfo> statusInfoCaptor = ArgumentCaptor.forClass(ThingStatusInfo.class);
    verify(callback).statusUpdated(eq(thing), statusInfoCaptor.capture());
    ThingStatusInfo thingStatusInfo = statusInfoCaptor.getValue();
    Assert.assertThat(thingStatusInfo.getStatus(), is(equalTo(ThingStatus.ONLINE)));
}
Also used : ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo) Test(org.junit.Test)

Example 18 with ThingStatusInfo

use of org.eclipse.smarthome.core.thing.ThingStatusInfo in project smarthome by eclipse.

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.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Circuit) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo)

Example 19 with ThingStatusInfo

use of org.eclipse.smarthome.core.thing.ThingStatusInfo in project smarthome by eclipse.

the class DeviceHandler method onDeviceAdded.

@Override
public synchronized void onDeviceAdded(GeneralDeviceInformation device) {
    if (device instanceof Device) {
        this.device = (Device) device;
        if (this.device.isPresent()) {
            ThingStatusInfo statusInfo = this.dssBridgeHandler.getThing().getStatusInfo();
            updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
            logger.debug("Set status to {}", getThing().getStatus());
            // load scene configurations persistently into the thing
            for (Short i : this.device.getSavedScenes()) {
                onSceneConfigAdded(i);
            }
            logger.debug("Load saved scene specification into device");
            this.device.saveConfigSceneSpecificationIntoDevice(getThing().getProperties());
            checkDeviceInfoProperties(this.device);
            // load sensor priorities into the device and load sensor channels of the thing
            if (!this.device.isShade()) {
                loadSensorChannels();
                // check and load output channel of the thing
                checkOutputChannel();
            } else if (this.device.isBlind()) {
                // load channel for set the angle of jalousie devices
                String channelTypeID = DsChannelTypeProvider.getOutputChannelTypeID(((Device) device).getFunctionalColorGroup(), ((Device) device).getOutputMode());
                loadOutputChannel(new ChannelTypeUID(BINDING_ID, channelTypeID), DsChannelTypeProvider.getItemType(channelTypeID));
            }
            // load first channel values
            onDeviceStateInitial(this.device);
            return;
        }
    }
    onDeviceRemoved(device);
}
Also used : ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) Device(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo)

Example 20 with ThingStatusInfo

use of org.eclipse.smarthome.core.thing.ThingStatusInfo in project smarthome by eclipse.

the class AutomaticInboxProcessorTest method testThingWhenNoRepresentationPropertySet.

@Test
public void testThingWhenNoRepresentationPropertySet() {
    inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).build());
    List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).collect(Collectors.toList());
    assertThat(results.size(), is(1));
    assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
    when(thing.getProperties()).thenReturn(Collections.emptyMap());
    when(thingStatusInfoChangedEvent.getStatusInfo()).thenReturn(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null));
    when(thingStatusInfoChangedEvent.getThingUID()).thenReturn(THING_UID);
    inboxAutoIgnore.receive(thingStatusInfoChangedEvent);
    results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).collect(Collectors.toList());
    assertThat(results.size(), is(0));
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo) Test(org.junit.Test)

Aggregations

ThingStatusInfo (org.eclipse.smarthome.core.thing.ThingStatusInfo)26 Test (org.junit.Test)8 DiscoveryResult (org.eclipse.smarthome.config.discovery.DiscoveryResult)5 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)4 Thing (org.eclipse.smarthome.core.thing.Thing)3 ThingStatusInfoBuilder (org.eclipse.smarthome.core.thing.binding.builder.ThingStatusInfoBuilder)3 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Duration (java.time.Duration)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Circuit (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Circuit)1 Device (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.Device)1 AbstractHueOSGiTest (org.eclipse.smarthome.binding.hue.test.AbstractHueOSGiTest)1 Bridge (org.eclipse.smarthome.core.thing.Bridge)1 ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)1 EnrichedThingDTO (org.eclipse.smarthome.io.rest.core.thing.EnrichedThingDTO)1