use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class WemoHandler method removeSubscription.
private synchronized void removeSubscription() {
logger.debug("Removing WeMo GENA subscription for '{}'", this);
if (service.isRegistered(this)) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
String subscription = "basicevent1";
if ((subscriptionState.get(subscription) != null) && subscriptionState.get(subscription).booleanValue()) {
logger.debug("WeMo {}: Unsubscribing from service {}...", getUDN(), subscription);
service.removeSubscription(this, subscription);
}
if (thingTypeUID.equals(THING_TYPE_INSIGHT)) {
subscription = "insight1";
if ((subscriptionState.get(subscription) != null) && subscriptionState.get(subscription).booleanValue()) {
logger.debug("WeMo {}: Unsubscribing from service {}...", getUDN(), subscription);
service.removeSubscription(this, subscription);
}
}
subscriptionState = new HashMap<String, Boolean>();
service.unregisterParticipant(this);
}
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class FirmwareUpdateConsoleCommandExtension method listFirmwares.
private void listFirmwares(Console console, String[] args) {
if (args.length != 2) {
console.println("Specify the thing type id to get its available firmwares: firmware list <thingTypeUID>");
return;
}
ThingTypeUID thingTypeUID = new ThingTypeUID(args[1]);
Collection<Firmware> firmwares = firmwareRegistry.getFirmwares(thingTypeUID);
if (firmwares.isEmpty()) {
console.println("No firmwares found.");
}
for (Firmware firmware : firmwares) {
console.println(firmware.toString());
}
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class ThingDTOMapper method map.
/**
* Maps thing DTO into thing
*
* @param thingDTO the thingDTO
* @return the corresponding thing
*/
public static Thing map(ThingDTO thingDTO) {
ThingUID thingUID = new ThingUID(thingDTO.UID);
ThingTypeUID thingTypeUID = thingDTO.thingTypeUID == null ? new ThingTypeUID("") : new ThingTypeUID(thingDTO.thingTypeUID);
Thing thing = ThingBuilder.create(thingTypeUID, thingUID).build();
return ThingHelper.merge(thing, thingDTO);
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class FirmwareUpdateServiceTest method testUpdateFirmware_wrongModel.
@Test
public void testUpdateFirmware_wrongModel() {
FirmwareProvider firmwareProvider2 = mock(FirmwareProvider.class);
when(firmwareProvider2.getFirmware(eq(FWALPHA_RESTRICTED_TO_MODEL2.getUID()), any(Locale.class))).thenReturn(FWALPHA_RESTRICTED_TO_MODEL2);
when(firmwareProvider2.getFirmwares(any(ThingTypeUID.class), any(Locale.class))).thenAnswer(invocation -> {
ThingTypeUID thingTypeUID = (ThingTypeUID) invocation.getArguments()[0];
if (THING_TYPE_UID1.equals(thingTypeUID)) {
return Collections.singleton(FWALPHA_RESTRICTED_TO_MODEL2);
} else {
return Collections.emptySet();
}
});
firmwareRegistry.addFirmwareProvider(firmwareProvider2);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(equalTo(String.format("Firmware with UID %s is not suitable for thing with UID %s.", FWALPHA_RESTRICTED_TO_MODEL2.getUID(), THING1_UID)));
firmwareUpdateService.updateFirmware(THING1_UID, FWALPHA_RESTRICTED_TO_MODEL2.getUID(), null);
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class FirmwareUpdateServiceTest method testPrerequisiteVersionCheck_illegalVersion.
@Test
public void testPrerequisiteVersionCheck_illegalVersion() {
FirmwareProvider firmwareProvider2 = mock(FirmwareProvider.class);
when(firmwareProvider2.getFirmware(any(FirmwareUID.class), any(Locale.class))).thenAnswer(invocation -> {
FirmwareUID firmwareUID = (FirmwareUID) invocation.getArguments()[0];
if (FW111_FIX_EN.getUID().equals(firmwareUID)) {
return FW111_FIX_EN;
} else if (FW113_EN.getUID().equals(firmwareUID)) {
return FW113_EN;
} else {
return null;
}
});
when(firmwareProvider2.getFirmwares(any(ThingTypeUID.class), any(Locale.class))).thenAnswer(invocation -> {
ThingTypeUID thingTypeUID = (ThingTypeUID) invocation.getArguments()[0];
if (THING_TYPE_UID_WITHOUT_FW.equals(thingTypeUID) || THING_TYPE_UID2.equals(thingTypeUID)) {
return Collections.emptySet();
} else {
return Stream.of(FW111_FIX_EN, FW113_EN).collect(Collectors.toSet());
}
});
firmwareRegistry.addFirmwareProvider(firmwareProvider2);
assertThat(firmwareUpdateService.getFirmwareStatusInfo(THING1_UID), is(updateExecutableInfoFw113));
try {
firmwareUpdateService.updateFirmware(THING1_UID, FW113_EN.getUID(), null);
fail("Expeced an IllegalArgumentException, but it was not thrown.");
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), is(String.format("Firmware with UID %s requires at least firmware version %s to get installed. But the current firmware version of the thing with UID %s is %s.", FW113_EN.getUID(), FW113_EN.getPrerequisiteVersion(), THING1_UID, V111)));
}
}
Aggregations