1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-12 16:22:22 +01:00

[animation] Allow loading external url at build time (#6876)

This commit is contained in:
Landon Rohatensky
2024-06-11 15:56:27 -07:00
committed by GitHub
parent 3a97244b83
commit c723fd1f80
2 changed files with 53 additions and 6 deletions

View File

@@ -68,7 +68,7 @@ def _compute_local_icon_path(value: dict) -> Path:
return base_dir / f"{value[CONF_ICON]}.svg"
def _compute_local_image_path(value: dict) -> Path:
def compute_local_image_path(value: dict) -> Path:
url = value[CONF_URL]
h = hashlib.new("sha256")
h.update(url.encode())
@@ -117,7 +117,7 @@ def download_mdi(value):
def download_image(value):
url = value[CONF_URL]
path = _compute_local_image_path(value)
path = compute_local_image_path(value)
download_content(url, path)
@@ -295,7 +295,7 @@ async def to_code(config):
path = _compute_local_icon_path(conf_file).as_posix()
elif conf_file[CONF_SOURCE] == SOURCE_WEB:
path = _compute_local_image_path(conf_file).as_posix()
path = compute_local_image_path(conf_file).as_posix()
try:
with open(path, "rb") as f: