From 39cc28b4dd733e5a0d1365b065f0838bc9ef295c Mon Sep 17 00:00:00 2001 From: sususweet Date: Fri, 31 Oct 2025 23:21:39 +0800 Subject: [PATCH] fix: lua base library location error. --- custom_components/midea_auto_cloud/__init__.py | 7 +++++-- custom_components/midea_auto_cloud/core/lua_runtime.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/custom_components/midea_auto_cloud/__init__.py b/custom_components/midea_auto_cloud/__init__.py index 9ceee27..47cc4d6 100644 --- a/custom_components/midea_auto_cloud/__init__.py +++ b/custom_components/midea_auto_cloud/__init__.py @@ -145,8 +145,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType): config_dir = hass.config.path(DOMAIN) os.makedirs(config_dir, exist_ok=True) - cjson = os.path.join(config_dir, "cjson.lua") - bit = os.path.join(config_dir, "bit.lua") + os.makedirs(hass.config.path(STORAGE_PATH), exist_ok=True) + lua_path = hass.config.path(STORAGE_PATH) + + cjson = os.path.join(lua_path, "cjson.lua") + bit = os.path.join(lua_path, "bit.lua") # 只有文件不存在时才创建 if not os.path.exists(cjson): diff --git a/custom_components/midea_auto_cloud/core/lua_runtime.py b/custom_components/midea_auto_cloud/core/lua_runtime.py index e4036d5..8212564 100644 --- a/custom_components/midea_auto_cloud/core/lua_runtime.py +++ b/custom_components/midea_auto_cloud/core/lua_runtime.py @@ -19,12 +19,12 @@ class LuaRuntime: self._runtimes.execute('require "cjson"') except Exception as e: MideaLogger.warning(f"Failed to load cjson: {e}") - + try: self._runtimes.execute('require "bit"') except Exception as e: MideaLogger.warning(f"Failed to load bit: {e}") - + # 加载设备特定的Lua文件 string = f'dofile("{file}")' self._runtimes.execute(string)