Search in sources :

Example 6 with ThingStatusInfo

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

the class ThingEventFactory method createStatusInfoEvent.

private Event createStatusInfoEvent(String topic, String payload) throws Exception {
    String[] topicElements = getTopicElements(topic);
    if (topicElements.length != 4) {
        throw new IllegalArgumentException("ThingStatusInfoEvent creation failed, invalid topic: " + topic);
    }
    ThingUID thingUID = new ThingUID(topicElements[2]);
    ThingStatusInfo thingStatusInfo = deserializePayload(payload, ThingStatusInfo.class);
    return new ThingStatusInfoEvent(topic, payload, thingUID, thingStatusInfo);
}
Also used : ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo)

Example 7 with ThingStatusInfo

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

the class ThingEventFactory method createStatusInfoChangedEvent.

private Event createStatusInfoChangedEvent(String topic, String payload) throws Exception {
    String[] topicElements = getTopicElements(topic);
    if (topicElements.length != 4) {
        throw new IllegalArgumentException("ThingStatusInfoChangedEvent creation failed, invalid topic: " + topic);
    }
    ThingUID thingUID = new ThingUID(topicElements[2]);
    ThingStatusInfo[] thingStatusInfo = deserializePayload(payload, ThingStatusInfo[].class);
    return new ThingStatusInfoChangedEvent(topic, payload, thingUID, thingStatusInfo[0], thingStatusInfo[1]);
}
Also used : ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo)

Example 8 with ThingStatusInfo

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

the class SceneHandler method onSceneAdded.

@Override
public void onSceneAdded(InternalScene scene) {
    logger.debug("Scene {} added", scene.getID());
    if (this.bridgeHandler != null) {
        ThingStatusInfo statusInfo = this.bridgeHandler.getThing().getStatusInfo();
        updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
        logger.debug("Set status on {}", getThing().getStatus());
    }
    this.scene = scene;
    onSceneStateChanged(scene.isActive());
}
Also used : ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo)

Example 9 with ThingStatusInfo

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

the class MagicColorLightHandlerTest 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 10 with ThingStatusInfo

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

the class MagicOnOffLightHandlerTest 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)

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