mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2026-02-11 06:13:49 +00:00
fix: file encoding misread. Fix #103.
This commit is contained in:
@@ -156,7 +156,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType):
|
|||||||
from .const import CJSON_LUA
|
from .const import CJSON_LUA
|
||||||
cjson_lua = base64.b64decode(CJSON_LUA.encode("utf-8")).decode("utf-8")
|
cjson_lua = base64.b64decode(CJSON_LUA.encode("utf-8")).decode("utf-8")
|
||||||
try:
|
try:
|
||||||
with open(cjson, "wt") as fp:
|
with open(cjson, "wt", encoding="utf-8") as fp:
|
||||||
fp.write(cjson_lua)
|
fp.write(cjson_lua)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
MideaLogger.error(f"Failed to create cjson.lua at {cjson}: {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
|
import tempfile
|
||||||
temp_dir = tempfile.gettempdir()
|
temp_dir = tempfile.gettempdir()
|
||||||
cjson = os.path.join(temp_dir, "cjson.lua")
|
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)
|
fp.write(cjson_lua)
|
||||||
MideaLogger.warning(f"Using temporary file for cjson.lua: {cjson}")
|
MideaLogger.warning(f"Using temporary file for cjson.lua: {cjson}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user