From 0ae05e1b48c85f64fe4622a15742e03b2b311b98 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 26 May 2021 21:04:19 +0200 Subject: [PATCH] [miio] also refresh after custom commands (#10714) Signed-off-by: Marcel Verpaalen --- .../miio/internal/handler/MiIoBasicHandler.java | 16 ++++++++++------ .../miio/internal/handler/MiIoVacuumHandler.java | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java index a41be4897d1bd..101e7a7895f08 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoBasicHandler.java @@ -130,8 +130,8 @@ public void handleCommand(ChannelUID channelUID, Command receivedCommand) { } return; } - if (channelUID.getId().equals(CHANNEL_COMMAND)) { - cmds.put(sendCommand(command.toString()), command.toString()); + if (handleCommandsChannels(channelUID, command)) { + forceStatusUpdate(); return; } logger.debug("Locating action for {} channel '{}': '{}'", getThing().getUID(), channelUID.getId(), command); @@ -263,15 +263,19 @@ public void handleCommand(ChannelUID channelUID, Command receivedCommand) { } } } - updateDataCache.invalidateValue(); - miIoScheduler.schedule(() -> { - updateData(); - }, 3000, TimeUnit.MILLISECONDS); + forceStatusUpdate(); } else { logger.debug("Actions not loaded yet, or none available"); } } + private void forceStatusUpdate() { + updateDataCache.invalidateValue(); + miIoScheduler.schedule(() -> { + updateData(); + }, 3000, TimeUnit.MILLISECONDS); + } + private @Nullable JsonElement miotTransform(MiIoBasicChannel miIoBasicChannel, @Nullable JsonElement value) { JsonObject json = new JsonObject(); json.addProperty("did", miIoBasicChannel.getChannel()); diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java index f52e473bbfd43..e3b36f664e489 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/handler/MiIoVacuumHandler.java @@ -190,6 +190,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { return; } if (handleCommandsChannels(channelUID, command)) { + forceStatusUpdate(); return; } if (channelUID.getId().equals(CHANNEL_VACUUM)) {