|
20 | 20 | from homeassistant.helpers.network import get_url |
21 | 21 | from homeassistant.helpers.template import Template |
22 | 22 |
|
23 | | -try: |
24 | | - from homeassistant.components.http import StaticPathConfig |
25 | | - HA_VERSION_BEFORE_2024_7 = False |
26 | | -except ImportError: |
27 | | - HA_VERSION_BEFORE_2024_7 = True |
28 | | - |
29 | 23 | from . import utils |
30 | 24 | from .utils import DOMAIN, Server |
31 | 25 |
|
@@ -66,36 +60,14 @@ async def async_setup(hass: HomeAssistant, config: dict): |
66 | 60 | # 1. Serve lovelace card |
67 | 61 | path = Path(__file__).parent / "www" |
68 | 62 | for name in ("video-rtc.js", "webrtc-camera.js", "digital-ptz.js"): |
69 | | - if HA_VERSION_BEFORE_2024_7: |
70 | | - hass.http.register_static_path("/webrtc/" + name, str(path / name)) |
71 | | - else: |
72 | | - await hass.http.async_register_static_paths( |
73 | | - [ |
74 | | - StaticPathConfig( |
75 | | - "/webrtc/" + name, |
76 | | - str(path / name), |
77 | | - True, |
78 | | - ) |
79 | | - ] |
80 | | - ) |
| 63 | + await utils.register_static_path(hass, "/webrtc/" + name, str(path / name)) |
81 | 64 |
|
82 | 65 | # 2. Add card to resources |
83 | 66 | version = getattr(hass.data["integrations"][DOMAIN], "version", 0) |
84 | 67 | await utils.init_resource(hass, "/webrtc/webrtc-camera.js", str(version)) |
85 | 68 |
|
86 | 69 | # 3. Serve html page |
87 | | - if HA_VERSION_BEFORE_2024_7: |
88 | | - hass.http.register_static_path("/webrtc/embed", str(path / "embed.html")) |
89 | | - else: |
90 | | - await hass.http.async_register_static_paths( |
91 | | - [ |
92 | | - StaticPathConfig( |
93 | | - "/webrtc/embed", |
94 | | - "/config/custom_components/webrtc/www/embed.html", |
95 | | - True, |
96 | | - ) |
97 | | - ] |
98 | | - ) |
| 70 | + await utils.register_static_path(hass, "/webrtc/embed", str(path / "embed.html")) |
99 | 71 |
|
100 | 72 | # 4. Serve WebSocket API |
101 | 73 | hass.http.register_view(WebSocketView) |
|
0 commit comments