use of org.openhab.core.io.transport.upnp.UpnpIOService in project openhab-addons by openhab.
the class WemoBaseThingHandler method removeSubscriptions.
private void removeSubscriptions() {
if (subscriptions.isEmpty()) {
return;
}
UpnpIOService service = this.service;
if (service == null) {
return;
}
if (!service.isRegistered(this)) {
logger.debug("Trying to remove GENA subscriptions for {}, but service is not registered", getThing().getUID());
return;
}
logger.debug("Removing GENA subscriptions for {}", getUDN());
subscriptions.forEach((serviceId, lastRenewed) -> {
logger.debug("Removing subscription for service {}", serviceId);
service.removeSubscription(this, serviceId);
});
subscriptions.clear();
}
use of org.openhab.core.io.transport.upnp.UpnpIOService in project openhab-addons by openhab.
the class WemoBaseThingHandler method initialize.
@Override
public void initialize() {
UpnpIOService service = this.service;
if (service != null) {
logger.debug("Registering UPnP participant for {}", getThing().getUID());
service.registerParticipant(this);
initializeHost();
}
}
use of org.openhab.core.io.transport.upnp.UpnpIOService in project openhab-addons by openhab.
the class WemoBaseThingHandler method addSubscription.
protected void addSubscription(String serviceId) {
if (subscriptions.containsKey(serviceId)) {
logger.debug("{} already subscribed to {}", getUDN(), serviceId);
return;
}
if (subscriptions.isEmpty()) {
logger.debug("Adding first GENA subscription for {}, scheduling renewal job", getUDN());
scheduleSubscriptionRenewalJob();
}
subscriptions.put(serviceId, Instant.ofEpochSecond(0));
UpnpIOService service = this.service;
if (service == null) {
return;
}
if (!service.isRegistered(this)) {
logger.debug("Registering UPnP participant for {}", getUDN());
service.registerParticipant(this);
}
if (!service.isRegistered(this)) {
logger.debug("Trying to add GENA subscription {} for {}, but service is not registered", serviceId, getUDN());
return;
}
logger.debug("Adding GENA subscription {} for {}", serviceId, getUDN());
service.addSubscription(this, serviceId, WemoBindingConstants.SUBSCRIPTION_DURATION_SECONDS);
}
use of org.openhab.core.io.transport.upnp.UpnpIOService in project openhab-addons by openhab.
the class WemoBaseThingHandler method removeSubscription.
protected void removeSubscription(String serviceId) {
UpnpIOService service = this.service;
if (service == null) {
return;
}
subscriptions.remove(serviceId);
if (subscriptions.isEmpty()) {
logger.debug("Removing last GENA subscription for {}, cancelling renewal job", getUDN());
cancelSubscriptionRenewalJob();
}
if (!service.isRegistered(this)) {
logger.debug("Trying to remove GENA subscription {} for {}, but service is not registered", serviceId, getUDN());
return;
}
logger.debug("Unsubscribing {} from service {}", getUDN(), serviceId);
service.removeSubscription(this, serviceId);
}
use of org.openhab.core.io.transport.upnp.UpnpIOService in project openhab-addons by openhab.
the class GenericWemoOSGiTest method setUpServices.
protected void setUpServices() throws IOException {
WemoUtil.serviceAvailableFunction = (host, port) -> true;
// StorageService is required from the ManagedThingProvider
VolatileStorageService volatileStorageService = new VolatileStorageService();
registerService(volatileStorageService);
// Mock the UPnP Service, that is required from the UPnP IO Service
mockUpnpService = new MockUpnpService(false, true);
mockUpnpService.startup();
registerService(mockUpnpService, UpnpService.class.getName());
managedThingProvider = getService(ManagedThingProvider.class);
assertThat(managedThingProvider, is(notNullValue()));
thingRegistry = getService(ThingRegistry.class);
assertThat(thingRegistry, is(notNullValue()));
// UPnP IO Service is required from the WemoDiscoveryService and WemoHandlerFactory
upnpIOService = getService(UpnpIOService.class);
assertThat(upnpIOService, is(notNullValue()));
mockCaller = Mockito.spy(new WemoHttpCall());
WemoHttpCallFactory wemoHttpCallFactory = () -> mockCaller;
registerService(wemoHttpCallFactory, WemoHttpCallFactory.class.getName());
ChannelTypeProvider channelTypeProvider = mock(ChannelTypeProvider.class);
when(channelTypeProvider.getChannelType(any(ChannelTypeUID.class), any(Locale.class))).thenReturn(ChannelTypeBuilder.state(DEFAULT_CHANNEL_TYPE_UID, "label", CoreItemFactory.SWITCH).build());
registerService(channelTypeProvider);
}
Aggregations