diff --git a/bundles/org.openhab.binding.august/src/main/java/org/openhab/binding/august/internal/handler/AugustLockHandler.java b/bundles/org.openhab.binding.august/src/main/java/org/openhab/binding/august/internal/handler/AugustLockHandler.java index 78855dc334568..f33a75f269ef5 100644 --- a/bundles/org.openhab.binding.august/src/main/java/org/openhab/binding/august/internal/handler/AugustLockHandler.java +++ b/bundles/org.openhab.binding.august/src/main/java/org/openhab/binding/august/internal/handler/AugustLockHandler.java @@ -364,23 +364,27 @@ private void cancelUnlockedByUserFuture() { private void handleRemoteEventPushMessage(JsonElement message, JsonElement eventType) { switch (eventType.getAsInt()) { case 1: - RemoteOperateLockResponse remoteEvent = gson.fromJson(message, - new TypeToken() { - }.getType()); - if (remoteEvent.info != null) { - updateThingProperties(remoteEvent.info); - } - - if (remoteEvent.lockState != null && !"kAugLockState_Unlocking".equals(remoteEvent.lockState) - && !"kAugLockState_Locking".equals(remoteEvent.lockState)) { - State lockState = parseLockState(remoteEvent.lockState); - updateState(CHANNEL_LOCK_STATE, lockState); + if (!message.getAsJsonObject().get("error").isJsonNull()) { + logger.debug("Ignoring error message from bridge"); + } else { + RemoteOperateLockResponse remoteEvent = gson.fromJson(message, + new TypeToken() { + }.getType()); + if (remoteEvent.info != null) { + updateThingProperties(remoteEvent.info); + } + + if (remoteEvent.lockState != null && !"kAugLockState_Unlocking".equals(remoteEvent.lockState) + && !"kAugLockState_Locking".equals(remoteEvent.lockState)) { + State lockState = parseLockState(remoteEvent.lockState); + updateState(CHANNEL_LOCK_STATE, lockState); + + } + if (remoteEvent.doorState != null) { + updateState(CHANNEL_DOOR_STATE, parseDoorState(remoteEvent.doorState)); + } } - if (remoteEvent.doorState != null) { - updateState(CHANNEL_DOOR_STATE, parseDoorState(remoteEvent.doorState)); - } - break; // Other events may occur default: diff --git a/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/dto/SerializationDeserializationTest.java b/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/dto/SerializationDeserializationTest.java index 0322fabb050bb..500dc3f30b5d1 100644 --- a/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/dto/SerializationDeserializationTest.java +++ b/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/dto/SerializationDeserializationTest.java @@ -178,7 +178,7 @@ void testLockAndDoorPushMessage() throws IOException { }.getType(); final LockStatusDTO message = wireHelper - .deSerializeFromClasspathResource("/mock_responses/lock_status_unlocked_async.json", type); + .deSerializeFromClasspathResource("/mock_responses/pubnub/lock_status_unlocked_async.json", type); assertEquals("unlocked", message.lockStatus); assertEquals("closed", message.doorStatus); @@ -190,7 +190,7 @@ void testLockPushMessage() throws IOException { }.getType(); final LockStatusDTO message = wireHelper - .deSerializeFromClasspathResource("/mock_responses/lock_status_no_doorstate_async.json", type); + .deSerializeFromClasspathResource("/mock_responses/pubnub/lock_status_no_doorstate_async.json", type); assertEquals("unlocked", message.lockStatus); } diff --git a/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/handler/AugustLockHandlerTest.java b/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/handler/AugustLockHandlerTest.java index abe121bfb5bca..1f32e060b2679 100644 --- a/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/handler/AugustLockHandlerTest.java +++ b/bundles/org.openhab.binding.august/src/test/java/org/openhab/binding/august/internal/handler/AugustLockHandlerTest.java @@ -195,8 +195,8 @@ void testUnlockDoor() throws IOException, InterruptedException { lockHandler.handleCommand(new ChannelUID(thing.getUID(), BindingConstants.CHANNEL_LOCK_STATE), OnOffType.OFF); - lockHandler.onPushMessage("ignored", - JsonParser.parseString(getClasspathJSONContent("/mock_responses/lock_status_unlocked_async.json"))); + lockHandler.onPushMessage("ignored", JsonParser + .parseString(getClasspathJSONContent("/mock_responses/pubnub/lock_status_unlocked_async.json"))); verify(thingHandlerCallback).stateUpdated(new ChannelUID(thing.getUID(), BindingConstants.CHANNEL_LOCK_STATE), OnOffType.OFF); } diff --git a/bundles/org.openhab.binding.august/src/test/resources/mock_responses/lock_status_locked_async.json b/bundles/org.openhab.binding.august/src/test/resources/mock_responses/pubnub/lock_status_locked_async.json similarity index 100% rename from bundles/org.openhab.binding.august/src/test/resources/mock_responses/lock_status_locked_async.json rename to bundles/org.openhab.binding.august/src/test/resources/mock_responses/pubnub/lock_status_locked_async.json diff --git a/bundles/org.openhab.binding.august/src/test/resources/mock_responses/lock_status_no_doorstate_async.json b/bundles/org.openhab.binding.august/src/test/resources/mock_responses/pubnub/lock_status_no_doorstate_async.json similarity index 100% rename from bundles/org.openhab.binding.august/src/test/resources/mock_responses/lock_status_no_doorstate_async.json rename to bundles/org.openhab.binding.august/src/test/resources/mock_responses/pubnub/lock_status_no_doorstate_async.json diff --git a/bundles/org.openhab.binding.august/src/test/resources/mock_responses/lock_status_unlocked_async.json b/bundles/org.openhab.binding.august/src/test/resources/mock_responses/pubnub/lock_status_unlocked_async.json similarity index 100% rename from bundles/org.openhab.binding.august/src/test/resources/mock_responses/lock_status_unlocked_async.json rename to bundles/org.openhab.binding.august/src/test/resources/mock_responses/pubnub/lock_status_unlocked_async.json