mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2025-11-12 16:01:54 +00:00
fix: resolve error when lua file is none
This commit is contained in:
@@ -304,11 +304,11 @@ class MeijuCloud(MideaCloud):
|
|||||||
return appliances
|
return appliances
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def get_device_status(self, appliance_code: int) -> dict | None:
|
async def get_device_status(self, appliance_code: int, query: dict) -> dict | None:
|
||||||
data = {
|
data = {
|
||||||
"applianceCode": str(appliance_code),
|
"applianceCode": str(appliance_code),
|
||||||
"command": {
|
"command": {
|
||||||
"query": {}
|
"query": query
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if response := await self._api_request(
|
if response := await self._api_request(
|
||||||
|
|||||||
@@ -167,13 +167,14 @@ class MiedaDevice(threading.Thread):
|
|||||||
# 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)
|
||||||
|
|
||||||
try:
|
if self._lua_runtime is not None:
|
||||||
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
|
try:
|
||||||
await self._build_send(set_cmd)
|
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
|
||||||
return
|
await self._build_send(set_cmd)
|
||||||
except Exception as e:
|
return
|
||||||
MideaLogger.debug(f"LuaRuntimeError in set_attribute {nested_status}: {repr(e)}")
|
except Exception as e:
|
||||||
traceback.print_exc()
|
MideaLogger.debug(f"LuaRuntimeError in set_attribute {nested_status}: {repr(e)}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
cloud = self._cloud
|
cloud = self._cloud
|
||||||
if cloud and hasattr(cloud, "send_device_control"):
|
if cloud and hasattr(cloud, "send_device_control"):
|
||||||
@@ -193,13 +194,14 @@ class MiedaDevice(threading.Thread):
|
|||||||
nested_status = self._convert_to_nested_structure(new_status)
|
nested_status = self._convert_to_nested_structure(new_status)
|
||||||
|
|
||||||
if has_new:
|
if has_new:
|
||||||
try:
|
if self._lua_runtime is not None:
|
||||||
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
|
try:
|
||||||
await self._build_send(set_cmd)
|
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
|
||||||
return
|
await self._build_send(set_cmd)
|
||||||
except Exception as e:
|
return
|
||||||
MideaLogger.debug(f"LuaRuntimeError in set_attributes {nested_status}: {repr(e)}")
|
except Exception as e:
|
||||||
traceback.print_exc()
|
MideaLogger.debug(f"LuaRuntimeError in set_attributes {nested_status}: {repr(e)}")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
cloud = self._cloud
|
cloud = self._cloud
|
||||||
if cloud and hasattr(cloud, "send_device_control"):
|
if cloud and hasattr(cloud, "send_device_control"):
|
||||||
@@ -267,8 +269,13 @@ class MiedaDevice(threading.Thread):
|
|||||||
|
|
||||||
async def refresh_status(self):
|
async def refresh_status(self):
|
||||||
for query in self._queries:
|
for query in self._queries:
|
||||||
if query_cmd := self._lua_runtime.build_query(query):
|
if self._lua_runtime is not None:
|
||||||
await self._build_send(query_cmd)
|
if query_cmd := self._lua_runtime.build_query(query):
|
||||||
|
await self._build_send(query_cmd)
|
||||||
|
else:
|
||||||
|
cloud = self._cloud
|
||||||
|
if cloud and hasattr(cloud, "get_device_status"):
|
||||||
|
await cloud.get_device_status(self._device_id, query=query)
|
||||||
|
|
||||||
def _parse_cloud_message(self, decrypted):
|
def _parse_cloud_message(self, decrypted):
|
||||||
# MideaLogger.debug(f"Received: {decrypted}")
|
# MideaLogger.debug(f"Received: {decrypted}")
|
||||||
|
|||||||
Reference in New Issue
Block a user