Skip to content

Commit

Permalink
Fix deprecated functions and neerslag-card loading
Browse files Browse the repository at this point in the history
Fix deprecated register_static_path #56
Fix deprecated non async call async_forward_entry_setup #55
Fix the neerslag-card not always loading correctly #59

Co-Authored-By: Bouwe Westerdijk <[email protected]>
  • Loading branch information
2 people authored and aex351 committed Dec 29, 2024
1 parent 2fb9018 commit ef9d2ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 2 additions & 5 deletions custom_components/neerslag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def options_update_listener(hass: HomeAssistant, config_entry: ConfigEntry
async def async_setup(hass: HomeAssistant, config_entry: dict):
"""Set up the Neerslag Sensor (Buienalarm / Buienradar) component."""
hass.data.setdefault(DOMAIN, {})
setup_view(hass)
await setup_view(hass)

return True

Expand All @@ -50,10 +50,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
hass_data["unsub_options_update_listener"] = unsub_options_update_listener
hass.data[DOMAIN][config_entry.entry_id] = hass_data

for platform in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, platform)
)
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)

return True

Expand Down
7 changes: 4 additions & 3 deletions custom_components/neerslag/load_frontend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from homeassistant.core import HomeAssistant
from homeassistant.components.frontend import add_extra_js_url
from homeassistant.components.http import StaticPathConfig
from aiohttp import web
import logging
import os
Expand All @@ -9,13 +10,13 @@
_LOGGER = logging.getLogger(__name__)


def setup_view(hass: HomeAssistant):
async def setup_view(hass: HomeAssistant):
dir_path = os.path.dirname(os.path.realpath(__file__))
path_to_file = "{}/home-assistant-neerslag-card/neerslag-card.js".format(dir_path)
should_cache = False

timestamp = str(time.time())
frontend_script_url_with_parameter = FRONTEND_SCRIPT_URL+"?cache="+timestamp
add_extra_js_url(hass, frontend_script_url_with_parameter , es5=False)

hass.http.register_static_path(FRONTEND_SCRIPT_URL, str(path_to_file), should_cache)
add_extra_js_url(hass, frontend_script_url_with_parameter , es5=False)
await hass.http.async_register_static_paths([StaticPathConfig(FRONTEND_SCRIPT_URL, str(path_to_file), should_cache)])
2 changes: 1 addition & 1 deletion custom_components/neerslag/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"@aex351"
],
"iot_class" : "cloud_polling",
"version": "2024.05.05.0"
"version": "2024.12.29.0"
}

0 comments on commit ef9d2ea

Please sign in to comment.