From 0fedc103425844971004ead9afaac0f79366dc11 Mon Sep 17 00:00:00 2001 From: sususweet Date: Wed, 4 Feb 2026 23:42:16 +0800 Subject: [PATCH] fix: file encoding misread. Fix #103. --- custom_components/midea_auto_cloud/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/midea_auto_cloud/__init__.py b/custom_components/midea_auto_cloud/__init__.py index c58d933..26b7ac2 100644 --- a/custom_components/midea_auto_cloud/__init__.py +++ b/custom_components/midea_auto_cloud/__init__.py @@ -156,7 +156,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType): from .const import CJSON_LUA cjson_lua = base64.b64decode(CJSON_LUA.encode("utf-8")).decode("utf-8") try: - with open(cjson, "wt") as fp: + with open(cjson, "wt", encoding="utf-8") as fp: fp.write(cjson_lua) except PermissionError as e: MideaLogger.error(f"Failed to create cjson.lua at {cjson}: {e}") @@ -164,7 +164,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType): import tempfile temp_dir = tempfile.gettempdir() cjson = os.path.join(temp_dir, "cjson.lua") - with open(cjson, "wt") as fp: + with open(cjson, "wt", encoding="utf-8") as fp: fp.write(cjson_lua) MideaLogger.warning(f"Using temporary file for cjson.lua: {cjson}")