Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static path config for HA 2024.7+ #723

Merged
merged 5 commits into from
Sep 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
await static_path_config
  • Loading branch information
hmmbob committed Jul 2, 2024
commit fc24c6cbd718dee36b0912741096a065b8566a7e
20 changes: 18 additions & 2 deletions custom_components/webrtc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,30 @@ async def async_setup(hass: HomeAssistant, config: dict):
# 1. Serve lovelace card
path = Path(__file__).parent / "www"
for name in ("video-rtc.js", "webrtc-camera.js", "digital-ptz.js"):
hass.http.register_static_path("/webrtc/" + name, str(path / name))
await hass.http.async_register_static_paths(
[
StaticPathConfig(
"/webrtc/" + name,
str(path / name),
True,
)
]
)

# 2. Add card to resources
version = getattr(hass.data["integrations"][DOMAIN], "version", 0)
await utils.init_resource(hass, "/webrtc/webrtc-camera.js", str(version))

# 3. Serve html page
hass.http.register_static_path("/webrtc/embed", str(path / "embed.html"))
await hass.http.async_register_static_paths(
[
StaticPathConfig(
"/webrtc/embed",
"/config/custom_components/webrtc/www/embed.html",
True,
)
]
)

# 4. Serve WebSocket API
hass.http.register_view(WebSocketView)
Expand Down