From d8690d03106e8c82222d4e681876cbb9e474a281 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Wed, 14 Aug 2024 09:50:42 +0200 Subject: [PATCH] Correctly catch HttpException when retrieving item Fixes #3779 Signed-off-by: Danny Baumann --- .../habdroid/background/ItemsControlsProviderService.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/org/openhab/habdroid/background/ItemsControlsProviderService.kt b/mobile/src/main/java/org/openhab/habdroid/background/ItemsControlsProviderService.kt index 134a86e9c1..6ff21f4e89 100644 --- a/mobile/src/main/java/org/openhab/habdroid/background/ItemsControlsProviderService.kt +++ b/mobile/src/main/java/org/openhab/habdroid/background/ItemsControlsProviderService.kt @@ -120,7 +120,13 @@ class ItemsControlsProviderService : ControlsProviderService() { } val state = when (action) { is BooleanAction -> { - val item = ItemClient.loadItem(connection, itemName) ?: return ControlAction.RESPONSE_FAIL + val item = try { + ItemClient.loadItem(connection, itemName) + } catch (e: HttpClient.HttpException) { + Log.e(TAG, "Could not determine item type for boolean action", e) + null + } ?: return ControlAction.RESPONSE_FAIL + if (item.isOfTypeOrGroupType(Item.Type.Player)) { if (action.newState) "PLAY" else "PAUSE" } else {