From 97724a8dbaa23de57d6193f5f78d4b123fbe99de Mon Sep 17 00:00:00 2001 From: Cyborg2017 Date: Sun, 28 Dec 2025 11:42:48 +0800 Subject: [PATCH] feat: Allow both drums to share the `db_control_status` switch * Note: Ensures the shared control status (`db_control_status`) reflects the operational state of the currently active silo. - If the selected silo is not running (`db_running_status`), the control status is set to 'pause'. - This synchronization allows multiple silos to safely share a single control switch during switching operations. --- .../midea_auto_cloud/core/device.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/custom_components/midea_auto_cloud/core/device.py b/custom_components/midea_auto_cloud/core/device.py index d156ec3..9e10c81 100644 --- a/custom_components/midea_auto_cloud/core/device.py +++ b/custom_components/midea_auto_cloud/core/device.py @@ -83,6 +83,14 @@ class MiedaDevice(threading.Thread): self._lua_runtime = MideaCodec(lua_file, device_type=self._attributes.get("device_type"), sn=sn, subtype=subtype) if lua_file is not None else None self._cloud = cloud + def _determine_control_status_based_on_running(self, running_status): + # 根据运行状态确定控制状态, 只有当运行状态是"start"时,控制状态才为"start" + if running_status == "start": + return "start" + # 其他所有情况(包括standby、pause、off、error等),控制状态应为pause + else: + return "pause" + @property def device_name(self): return self._device_name @@ -180,6 +188,15 @@ class MiedaDevice(threading.Thread): # 立即刷新状态以显示新筒的状态 await self.refresh_status() + # 获取当前运行状态 + running_status = self._attributes.get("db_running_status") + if running_status is not None: + # 根据运行状态确定控制状态 + control_status = self._determine_control_status_based_on_running(running_status) + # 更新本地属性 + self._attributes["db_control_status"] = control_status + # 添加到要发送的状态中(如果需要发送到云端) + new_status["db_control_status"] = control_status # return # 发送到云端,所以注释teturn # 针对T0xD9复式洗衣机,根据选择的筒添加db_location参数 @@ -232,6 +249,14 @@ class MiedaDevice(threading.Thread): # 立即刷新状态以显示新筒的状态 await self.refresh_status() + + # 获取当前运行状态 + running_status = self._attributes.get("db_running_status") + if running_status is not None: + # 根据运行状态确定控制状态 + control_status = self._determine_control_status_based_on_running(running_status) + # 更新本地属性 + self._attributes["db_control_status"] = control_status # return # 发送到云端,所以注释teturn new_status = {}