Skip to content

Commit 00ddb6a

Browse files
authored
Merge branch 'dev' into main
2 parents 33035ee + 5c05318 commit 00ddb6a

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

custom_components/view_assist/core/javascript.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from pathlib import Path
77

88
from homeassistant.components.http import StaticPathConfig
9-
from homeassistant.components.lovelace import LovelaceData
9+
from homeassistant.components.lovelace import MODE_STORAGE, LovelaceData
10+
from homeassistant.const import MAJOR_VERSION, MINOR_VERSION
1011
from homeassistant.core import HomeAssistant
1112
from homeassistant.helpers.event import async_call_later
1213

@@ -27,19 +28,25 @@ def __init__(self, hass: HomeAssistant, config: VAConfigEntry) -> None:
2728
self.config = config
2829
self.lovelace: LovelaceData = self.hass.data.get("lovelace")
2930

31+
# Fix for change to name of mode to resource_mode in 2026.2
32+
if MAJOR_VERSION >= 2026 and MINOR_VERSION >= 2:
33+
self.resource_mode = self.lovelace.resource_mode
34+
else:
35+
self.resource_mode = self.lovelace.mode
36+
3037
async def async_setup(self) -> bool:
3138
"""Register view_assist path."""
3239
# Remove previous registration - can be removed after this version
3340
await self.async_unregister(URL_BASE)
3441

3542
await self._async_register_path()
36-
if self.lovelace.mode == "storage":
43+
if self.resource_mode == MODE_STORAGE:
3744
await self._async_wait_for_lovelace_resources()
3845
return True
3946

4047
async def async_unload(self) -> bool:
4148
"""Unload javascript module registration."""
42-
if self.lovelace.mode == "storage":
49+
if self.resource_mode == MODE_STORAGE:
4350
await self.async_unregister()
4451
return True
4552

@@ -129,13 +136,16 @@ def _get_resource_path(self, url: str):
129136
return url.split("?")[0]
130137

131138
def _get_resource_version(self, url: str):
132-
if version := url.split("?")[1].replace("v=", ""):
133-
return version
139+
try:
140+
if version := url.split("?")[1].replace("v=", ""):
141+
return version
142+
except IndexError:
143+
pass
134144
return 0
135145

136146
async def async_unregister(self, url: str = JS_URL):
137147
"""Unload lovelace module resource."""
138-
if self.hass.data["lovelace"].mode == "storage":
148+
if self.resource_mode == MODE_STORAGE:
139149
for module in JSMODULES:
140150
url = f"{url}/{module.get('filename')}"
141151
resources = [

custom_components/view_assist/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"iot_class": "calculated",
1010
"issue_tracker": "https://github.com/dinki/view_assist_integration/issues",
1111
"requirements": ["wordtodigits==1.0.2", "beautifulsoup4>=4.11.0"],
12-
"version": "2026.1.1"
12+
"version": "2026.2.0"
1313
}

0 commit comments

Comments
 (0)