[wemo] Improve GENA subscription reliability and error handling (#12148)
* Consolidate service subscriptions in base class. * Remove unsynchronized and unneeded cache of subscriptions. * Do not unregister participant when removing subscription. * Fix status wrongly set to ONLINE when exception is thrown. * Refactor error handling for WemoHttpCall. * Adjust log level for communication errors. * Add automatic subscription renewal. * Fix more ONLINE/OFFLINE status transition issues. * Adjust log level when getWemoURL fails because device is offline. * Remove redundant logging. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
@@ -50,7 +50,7 @@ public class WemoLinkDiscoveryServiceOSGiTest extends GenericWemoLightOSGiTestPa
|
||||
|
||||
@Test
|
||||
public void assertSupportedThingIsDiscovered()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
String model = WemoBindingConstants.THING_TYPE_MZ100.getId();
|
||||
addUpnpDevice(SERVICE_ID, SERVICE_NUMBER, model);
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WemoHandlerOSGiTest extends GenericWemoOSGiTest {
|
||||
|
||||
@Test
|
||||
public void assertThatThingHandlesOnOffCommandCorrectly()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Command command = OnOffType.OFF;
|
||||
|
||||
Thing thing = createThing(THING_TYPE_UID, DEFAULT_TEST_CHANNEL, DEFAULT_TEST_CHANNEL_TYPE);
|
||||
@@ -105,7 +105,7 @@ public class WemoHandlerOSGiTest extends GenericWemoOSGiTest {
|
||||
|
||||
@Test
|
||||
public void assertThatThingHandlesREFRESHCommandCorrectly()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Command command = RefreshType.REFRESH;
|
||||
|
||||
Thing thing = createThing(THING_TYPE_UID, DEFAULT_TEST_CHANNEL, DEFAULT_TEST_CHANNEL_TYPE);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
|
||||
|
||||
@Test
|
||||
public void handleONcommandForBRIGHTNESSchannel()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Command command = OnOffType.ON;
|
||||
String channelID = WemoBindingConstants.CHANNEL_BRIGHTNESS;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
|
||||
|
||||
@Test
|
||||
public void handlePercentCommandForBRIGHTNESSChannel()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
// Set brightness value to 20 Percent
|
||||
Command command = new PercentType(20);
|
||||
String channelID = WemoBindingConstants.CHANNEL_BRIGHTNESS;
|
||||
@@ -95,7 +95,7 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
|
||||
|
||||
@Test
|
||||
public void handleIncreaseCommandForBRIGHTNESSchannel()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
// The value is increased by 5 Percents by default
|
||||
Command command = IncreaseDecreaseType.INCREASE;
|
||||
String channelID = WemoBindingConstants.CHANNEL_BRIGHTNESS;
|
||||
@@ -110,7 +110,7 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
|
||||
|
||||
@Test
|
||||
public void handleDecreaseCommandForBRIGHTNESSchannel()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
// The value can not be decreased below 0
|
||||
Command command = IncreaseDecreaseType.DECREASE;
|
||||
String channelID = WemoBindingConstants.CHANNEL_BRIGHTNESS;
|
||||
@@ -123,7 +123,8 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleOnCommandForSTATEChannel() throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
public void handleOnCommandForSTATEChannel()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Command command = OnOffType.ON;
|
||||
String channelID = WemoBindingConstants.CHANNEL_STATE;
|
||||
|
||||
@@ -137,7 +138,7 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
|
||||
|
||||
@Test
|
||||
public void handleREFRESHCommandForChannelSTATE()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Command command = RefreshType.REFRESH;
|
||||
String channelID = WemoBindingConstants.CHANNEL_STATE;
|
||||
|
||||
@@ -149,7 +150,7 @@ public class WemoLightHandlerOSGiTest extends GenericWemoLightOSGiTestParent {
|
||||
}
|
||||
|
||||
private void assertRequestForCommand(String channelID, Command command, String action, String value,
|
||||
String capitability) throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
String capitability) throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Thing bridge = createBridge(BRIDGE_TYPE_UID);
|
||||
|
||||
Thing thing = createThing(THING_TYPE_UID, DEFAULT_TEST_CHANNEL, DEFAULT_TEST_CHANNEL_TYPE);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class WemoMakerHandlerOSGiTest extends GenericWemoOSGiTest {
|
||||
|
||||
@Test
|
||||
public void assertThatThingHandlesOnOffCommandCorrectly()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Command command = OnOffType.OFF;
|
||||
|
||||
Thing thing = createThing(THING_TYPE_UID, DEFAULT_TEST_CHANNEL, DEFAULT_TEST_CHANNEL_TYPE);
|
||||
@@ -106,7 +106,7 @@ public class WemoMakerHandlerOSGiTest extends GenericWemoOSGiTest {
|
||||
|
||||
@Test
|
||||
public void assertThatThingHandlesREFRESHCommand()
|
||||
throws MalformedURLException, URISyntaxException, ValidationException {
|
||||
throws MalformedURLException, URISyntaxException, ValidationException, IOException {
|
||||
Command command = RefreshType.REFRESH;
|
||||
|
||||
Thing thing = createThing(THING_TYPE_UID, DEFAULT_TEST_CHANNEL, DEFAULT_TEST_CHANNEL_TYPE);
|
||||
|
||||
Reference in New Issue
Block a user