mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2026-02-27 14:16:35 +00:00
feat: Sync the attribute status of the selected drum with M-Smart app
This commit is contained in:
@@ -170,9 +170,17 @@ class MiedaDevice(threading.Thread):
|
|||||||
if self._device_type == 0xD9 and attribute == "db_location_selection":
|
if self._device_type == 0xD9 and attribute == "db_location_selection":
|
||||||
# 更新属性
|
# 更新属性
|
||||||
self._attributes[attribute] = value
|
self._attributes[attribute] = value
|
||||||
|
|
||||||
|
# 更新db_location(用于查询)
|
||||||
|
if value == "left":
|
||||||
|
self._attributes["db_location"] = 1
|
||||||
|
elif value == "right":
|
||||||
|
self._attributes["db_location"] = 2
|
||||||
|
|
||||||
# 立即刷新状态以显示新筒的状态
|
# 立即刷新状态以显示新筒的状态
|
||||||
await self.refresh_status()
|
await self.refresh_status()
|
||||||
return
|
|
||||||
|
# return # 发送到云端,所以注释teturn
|
||||||
|
|
||||||
# 针对T0xD9复式洗衣机,根据选择的筒添加db_location参数
|
# 针对T0xD9复式洗衣机,根据选择的筒添加db_location参数
|
||||||
if self._device_type == 0xD9 and attribute != "db_location_selection":
|
if self._device_type == 0xD9 and attribute != "db_location_selection":
|
||||||
@@ -209,16 +217,23 @@ class MiedaDevice(threading.Thread):
|
|||||||
await cloud.send_device_control(self._device_id, control=nested_status, status=self._attributes)
|
await cloud.send_device_control(self._device_id, control=nested_status, status=self._attributes)
|
||||||
|
|
||||||
async def set_attributes(self, attributes):
|
async def set_attributes(self, attributes):
|
||||||
# 针对T0xD9复式洗衣机,当切换筒选择时,立即刷新状态以显示新筒的状态
|
# 针对T0xD9复式洗衣机,当切换筒选择时
|
||||||
if self._device_type == 0xD9 and "db_location_selection" in attributes:
|
if self._device_type == 0xD9 and "db_location_selection" in attributes:
|
||||||
# 更新属性
|
location_selection = attributes["db_location_selection"]
|
||||||
for attribute, value in attributes.items():
|
|
||||||
if attribute in self._attributes.keys():
|
# 更新本地属性
|
||||||
self._attributes[attribute] = value
|
self._attributes["db_location_selection"] = location_selection
|
||||||
|
|
||||||
|
# 更新db_location(用于查询)
|
||||||
|
if location_selection == "left":
|
||||||
|
self._attributes["db_location"] = 1
|
||||||
|
elif location_selection == "right":
|
||||||
|
self._attributes["db_location"] = 2
|
||||||
|
|
||||||
# 立即刷新状态以显示新筒的状态
|
# 立即刷新状态以显示新筒的状态
|
||||||
await self.refresh_status()
|
await self.refresh_status()
|
||||||
return
|
# return # 发送到云端,所以注释teturn
|
||||||
|
|
||||||
new_status = {}
|
new_status = {}
|
||||||
for attr in self._centralized:
|
for attr in self._centralized:
|
||||||
new_status[attr] = self._attributes.get(attr)
|
new_status[attr] = self._attributes.get(attr)
|
||||||
@@ -227,15 +242,26 @@ class MiedaDevice(threading.Thread):
|
|||||||
if attribute in self._attributes.keys():
|
if attribute in self._attributes.keys():
|
||||||
has_new = True
|
has_new = True
|
||||||
new_status[attribute] = value
|
new_status[attribute] = value
|
||||||
|
|
||||||
# 针对T0xD9复式洗衣机,根据选择的筒添加db_location参数
|
# 针对T0xD9复式洗衣机,确保发送到云端的控制命令包含筒位置信息
|
||||||
if self._device_type == 0xD9 and "db_location_selection" not in attributes:
|
if self._device_type == 0xD9:
|
||||||
location_selection = self._attributes.get("db_location_selection", "left")
|
# 如果attributes中有db_location_selection,确保new_status也有
|
||||||
if location_selection == "left":
|
if "db_location_selection" in attributes:
|
||||||
new_status["db_location"] = 1
|
location_selection = attributes["db_location_selection"]
|
||||||
elif location_selection == "right":
|
new_status["db_location_selection"] = location_selection
|
||||||
new_status["db_location"] = 2
|
# 添加对应的db_location
|
||||||
|
if location_selection == "left":
|
||||||
|
new_status["db_location"] = 1
|
||||||
|
elif location_selection == "right":
|
||||||
|
new_status["db_location"] = 2
|
||||||
|
# 如果没有db_location_selection,但当前有选择,添加db_location
|
||||||
|
elif "db_location_selection" not in attributes and self._attributes.get("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
|
# Convert dot-notation attributes to nested structure for transmission
|
||||||
nested_status = self._convert_to_nested_structure(new_status)
|
nested_status = self._convert_to_nested_structure(new_status)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user