Skip to content

Commit f93802e

Browse files
committed
fix: Fix deprecation warning for register_static_path
1 parent 8c0d8fe commit f93802e

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

custom_components/scene_presets/view.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .const import NAME, DOMAIN, PANEL_URL
22
from .file_utils import VERSION, PRESET_DATA, BASE_PATH
3-
from homeassistant.components.http import HomeAssistantView
3+
from homeassistant.components.http import HomeAssistantView, StaticPathConfig
44
from homeassistant.components.frontend import async_remove_panel, async_register_built_in_panel
55

66
# Adapted from https://github.com/hacs/integration/blob/7d46a52de0df2466aa65e446458b952150398f4c/custom_components/hacs/frontend.py#L58
@@ -23,12 +23,13 @@ async def get(self, request):
2323
)
2424

2525
async def async_setup_view(hass):
26-
hass.http.register_static_path(
27-
PANEL_URL,
28-
hass.config.path(f'{BASE_PATH}/frontend/scene_presets_panel.js'),
29-
)
26+
await hass.http.async_register_static_paths([
27+
StaticPathConfig(PANEL_URL, hass.config.path(f'{BASE_PATH}/frontend/scene_presets_panel.js'), True),
28+
StaticPathConfig(f'/assets/{DOMAIN}/iconset.js', hass.config.path(f'{BASE_PATH}/res/iconset.js'), True)
29+
])
3030

3131
hass.http.register_view(ScenePresetDataView)
32+
add_extra_js_url(hass, f"/assets/{DOMAIN}/iconset.js?{VERSION}")
3233

3334
await bind_preset_images(hass)
3435

@@ -47,18 +48,13 @@ async def async_setup_view(hass):
4748
"version": VERSION
4849
},
4950
)
50-
51-
# Custom iconset
52-
hass.http.register_static_path(
53-
f'/assets/{DOMAIN}/iconset.js',
54-
hass.config.path(f'{BASE_PATH}/res/iconset.js'),
55-
)
56-
add_extra_js_url(hass, f"/assets/{DOMAIN}/iconset.js?{VERSION}")
5751

5852
async def async_remove_view(hass):
5953
async_remove_panel(hass, "scene_presets")
6054

6155
async def bind_preset_images(hass):
56+
static_paths = []
57+
6258
for preset in PRESET_DATA.get("presets", []):
6359
img_filename = preset.get("img")
6460
is_custom = preset.get("custom")
@@ -68,7 +64,12 @@ async def bind_preset_images(hass):
6864
if is_custom is not None and is_custom:
6965
path = f"{BASE_PATH}/userdata/custom/assets/{img_filename}"
7066

71-
hass.http.register_static_path(
72-
f'/assets/{DOMAIN}/{img_filename}',
73-
hass.config.path(path),
74-
)
67+
static_paths.append(
68+
StaticPathConfig(
69+
f'/assets/{DOMAIN}/{img_filename}',
70+
hass.config.path(path),
71+
True
72+
)
73+
)
74+
75+
await hass.http.async_register_static_paths(static_paths)

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "Scene presets",
33
"persistent_directory": "userdata",
4-
"homeassistant": "2024.4.0b0"
4+
"homeassistant": "2024.7.0"
55
}

0 commit comments

Comments
 (0)