From 23502fcb9b1198efb43df130d83808751af3e314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Sopp?= Date: Fri, 5 Apr 2024 21:10:32 +0200 Subject: [PATCH] [miio] Add Roborock S7/S7MaxV mop mode (#16608) * [miio] Add Roborock S7/S7MaxV mop mode Signed-off-by: Ruediger Sopp --- bundles/org.openhab.binding.miio/README.base.md | 1 + bundles/org.openhab.binding.miio/README.md | 1 + .../openhab/binding/miio/internal/MiIoCommand.java | 1 + .../miio/internal/handler/MiIoVacuumHandler.java | 8 ++++++++ .../miio/internal/robot/RobotCababilities.java | 1 + .../binding/miio/internal/robot/StatusDTO.java | 7 +++++++ .../src/main/resources/OH-INF/i18n/miio.properties | 4 ++++ .../src/main/resources/OH-INF/thing/vacuumThing.xml | 11 +++++++++++ 8 files changed, 34 insertions(+) diff --git a/bundles/org.openhab.binding.miio/README.base.md b/bundles/org.openhab.binding.miio/README.base.md index 454138ad94e..f672cd585ef 100644 --- a/bundles/org.openhab.binding.miio/README.base.md +++ b/bundles/org.openhab.binding.miio/README.base.md @@ -248,6 +248,7 @@ Additionally depending on the capabilities of your robot vacuum other channels m | Switch | status#water_box_status | Water Box Status | | Switch | status#lock_status | Lock Status | | Number | status#water_box_mode | Water Box Mode | +| Number | status#mop_mode | Mop Mode | | Switch | status#water_box_carriage_status | Water Box Carriage Status | | Switch | status#mop_forbidden_enable | Mop Forbidden | | Switch | status#is_locating | Robot is locating | diff --git a/bundles/org.openhab.binding.miio/README.md b/bundles/org.openhab.binding.miio/README.md index 761a80f3a2b..fcf6b242a2e 100644 --- a/bundles/org.openhab.binding.miio/README.md +++ b/bundles/org.openhab.binding.miio/README.md @@ -642,6 +642,7 @@ Additionally depending on the capabilities of your robot vacuum other channels m | Switch | status#water_box_status | Water Box Status | | Switch | status#lock_status | Lock Status | | Number | status#water_box_mode | Water Box Mode | +| Number | status#mop_mode | Mop Mode | | Switch | status#water_box_carriage_status | Water Box Carriage Status | | Switch | status#mop_forbidden_enable | Mop Forbidden | | Switch | status#is_locating | Robot is locating | diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCommand.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCommand.java index 15c01f234d6..f55083c6d4d 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCommand.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/MiIoCommand.java @@ -79,6 +79,7 @@ public enum MiIoCommand { SET_MODE("set_custom_mode"), GET_MODE("get_custom_mode"), SET_WATERBOX_MODE("set_water_box_custom_mode"), + SET_MOP_MODE("set_mop_mode"), TIMERZONE_SET("set_timezone"), TIMERZONE_GET("get_timezone"), 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 b0cb52ef819..de5da91fa50 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 @@ -250,6 +250,11 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler { forceStatusUpdate(); return; } + if (channelUID.getId().equals(RobotCababilities.MOP_MODE.getChannel())) { + sendCommand(MiIoCommand.SET_MOP_MODE, "[" + command.toString() + "]"); + forceStatusUpdate(); + return; + } if (channelUID.getId().equals(RobotCababilities.SEGMENT_CLEAN.getChannel()) && !command.toString().isEmpty() && !command.toString().contentEquals("-")) { sendCommand(MiIoCommand.START_SEGMENT, "[" + command.toString() + "]"); @@ -383,6 +388,9 @@ public class MiIoVacuumHandler extends MiIoAbstractHandler { if (deviceCapabilities.containsKey(RobotCababilities.WATERBOX_MODE)) { safeUpdateState(RobotCababilities.WATERBOX_MODE.getChannel(), statusInfo.getWaterBoxMode()); } + if (deviceCapabilities.containsKey(RobotCababilities.MOP_MODE)) { + safeUpdateState(RobotCababilities.MOP_MODE.getChannel(), statusInfo.getMopMode()); + } if (deviceCapabilities.containsKey(RobotCababilities.WATERBOX_STATUS)) { safeUpdateState(RobotCababilities.WATERBOX_STATUS.getChannel(), statusInfo.getWaterBoxStatus()); } diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RobotCababilities.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RobotCababilities.java index c61f8d72416..0f5c104b74f 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RobotCababilities.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/RobotCababilities.java @@ -26,6 +26,7 @@ public enum RobotCababilities { WATERBOX_STATUS("water_box_status", "status#water_box_status", "miio:water_box_status", ""), LOCKSTATUS("lock_status", "status#lock_status", "miio:lock_status", ""), WATERBOX_MODE("water_box_mode", "status#water_box_mode", "miio:water_box_mode", ""), + MOP_MODE("mop_mode", "status#mop_mode", "miio:mop_mode", ""), WATERBOX_CARRIAGE("water_box_carriage_status", "status#water_box_carriage_status", "miio:water_box_carriage_status", ""), MOP_FORBIDDEN("mop_forbidden_enable", "status#mop_forbidden_enable", "miio:mop_forbidden_enable", ""), diff --git a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/StatusDTO.java b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/StatusDTO.java index e600d393dee..bbb3ba883aa 100644 --- a/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/StatusDTO.java +++ b/bundles/org.openhab.binding.miio/src/main/java/org/openhab/binding/miio/internal/robot/StatusDTO.java @@ -79,6 +79,9 @@ public class StatusDTO { @SerializedName("water_box_mode") @Expose private Integer waterBoxMode; + @SerializedName("mop_mode") + @Expose + private Integer mopMode; @SerializedName("water_box_carriage_status") @Expose private Integer waterBoxCarriageStatus; @@ -171,6 +174,10 @@ public class StatusDTO { return waterBoxMode; } + public final Integer getMopMode() { + return mopMode; + } + public final Integer getWaterBoxCarriageStatus() { return waterBoxCarriageStatus; } diff --git a/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/i18n/miio.properties b/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/i18n/miio.properties index b841aa2926a..5e2d84798cd 100644 --- a/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/i18n/miio.properties +++ b/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/i18n/miio.properties @@ -179,6 +179,10 @@ channel-type.miio.total_clean_time.label = Total Cleaning Time channel-type.miio.vacuum.label = Vacuum On/Off channel-type.miio.water_box_carriage_status.label = Water Box Carriage State channel-type.miio.water_box_mode.label = Water Box Mode +channel-type.miio.mop_mode.label = Mop Mode +channel-type.miio.mop_mode.state.option.300 = Standard +channel-type.miio.mop_mode.state.option.301 = Deep +channel-type.miio.mop_mode.state.option.303 = Deep+ channel-type.miio.water_box_status.label = Water Box State # thing status descriptions diff --git a/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/thing/vacuumThing.xml b/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/thing/vacuumThing.xml index b5035df1a5d..6a9ff477cf5 100644 --- a/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/thing/vacuumThing.xml +++ b/bundles/org.openhab.binding.miio/src/main/resources/OH-INF/thing/vacuumThing.xml @@ -190,6 +190,17 @@ + + Number + + + + + + + + + Switch