mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2026-02-27 14:16:35 +00:00
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.
This commit is contained in:
@@ -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 = {}
|
||||
|
||||
Reference in New Issue
Block a user