mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2025-12-23 04:47:11 +00:00
feat: add multi-tub support for T0xD9.
This commit is contained in:
@@ -166,6 +166,22 @@ class MiedaDevice(threading.Thread):
|
||||
new_status[attr] = self._attributes.get(attr)
|
||||
new_status[attribute] = value
|
||||
|
||||
# 针对T0xD9复式洗衣机,当切换筒选择时,立即刷新状态以显示新筒的状态
|
||||
if self._device_type == 0xD9 and attribute == "db_location_selection":
|
||||
# 更新属性
|
||||
self._attributes[attribute] = value
|
||||
# 立即刷新状态以显示新筒的状态
|
||||
await self.refresh_status()
|
||||
return
|
||||
|
||||
# 针对T0xD9复式洗衣机,根据选择的筒添加db_location参数
|
||||
if self._device_type == 0xD9 and attribute != "db_location_selection":
|
||||
location_selection = self._attributes.get("db_location_selection", "left")
|
||||
if location_selection == "left":
|
||||
new_status["db_location"] = 1
|
||||
elif location_selection == "right":
|
||||
new_status["db_location"] = 2
|
||||
|
||||
# Convert dot-notation attributes to nested structure for transmission
|
||||
nested_status = self._convert_to_nested_structure(new_status)
|
||||
|
||||
@@ -193,6 +209,16 @@ class MiedaDevice(threading.Thread):
|
||||
await cloud.send_device_control(self._device_id, control=nested_status, status=self._attributes)
|
||||
|
||||
async def set_attributes(self, attributes):
|
||||
# 针对T0xD9复式洗衣机,当切换筒选择时,立即刷新状态以显示新筒的状态
|
||||
if self._device_type == 0xD9 and "db_location_selection" in attributes:
|
||||
# 更新属性
|
||||
for attribute, value in attributes.items():
|
||||
if attribute in self._attributes.keys():
|
||||
self._attributes[attribute] = value
|
||||
# 立即刷新状态以显示新筒的状态
|
||||
await self.refresh_status()
|
||||
return
|
||||
|
||||
new_status = {}
|
||||
for attr in self._centralized:
|
||||
new_status[attr] = self._attributes.get(attr)
|
||||
@@ -202,6 +228,14 @@ class MiedaDevice(threading.Thread):
|
||||
has_new = True
|
||||
new_status[attribute] = value
|
||||
|
||||
# 针对T0xD9复式洗衣机,根据选择的筒添加db_location参数
|
||||
if self._device_type == 0xD9 and "db_location_selection" not in attributes:
|
||||
location_selection = self._attributes.get("db_location_selection", "left")
|
||||
if location_selection == "left":
|
||||
new_status["db_location"] = 1
|
||||
elif location_selection == "right":
|
||||
new_status["db_location"] = 2
|
||||
|
||||
# Convert dot-notation attributes to nested structure for transmission
|
||||
nested_status = self._convert_to_nested_structure(new_status)
|
||||
|
||||
@@ -291,6 +325,15 @@ class MiedaDevice(threading.Thread):
|
||||
|
||||
async def refresh_status(self):
|
||||
for query in self._queries:
|
||||
# 针对T0xD9复式洗衣机,根据选择的筒动态添加db_location参数
|
||||
actual_query = query.copy() if isinstance(query, dict) else query
|
||||
if self._device_type == 0xD9 and isinstance(actual_query, dict):
|
||||
location_selection = self._attributes.get("db_location_selection", "left")
|
||||
if location_selection == "left":
|
||||
actual_query["db_location"] = 1
|
||||
elif location_selection == "right":
|
||||
actual_query["db_location"] = 2
|
||||
|
||||
cloud = self._cloud
|
||||
if cloud and hasattr(cloud, "get_device_status"):
|
||||
if isinstance(cloud, MSmartHomeCloud):
|
||||
@@ -300,23 +343,23 @@ class MiedaDevice(threading.Thread):
|
||||
sn=self.sn,
|
||||
model_number=self.subtype,
|
||||
manufacturer_code=self._manufacturer_code,
|
||||
query=query
|
||||
query=actual_query
|
||||
):
|
||||
self._parse_cloud_message(status)
|
||||
else:
|
||||
if self._lua_runtime is not None:
|
||||
if query_cmd := self._lua_runtime.build_query(query):
|
||||
if query_cmd := self._lua_runtime.build_query(actual_query):
|
||||
await self._build_send(query_cmd)
|
||||
|
||||
elif isinstance(cloud, MeijuCloud):
|
||||
if status := await cloud.get_device_status(
|
||||
appliance_code=self._device_id,
|
||||
query=query
|
||||
query=actual_query
|
||||
):
|
||||
self._parse_cloud_message(status)
|
||||
else:
|
||||
if self._lua_runtime is not None:
|
||||
if query_cmd := self._lua_runtime.build_query(query):
|
||||
if query_cmd := self._lua_runtime.build_query(actual_query):
|
||||
await self._build_send(query_cmd)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user