Skip to content

Commit

Permalink
Merge pull request #7 from biofects/Update-paths
Browse files Browse the repository at this point in the history
fixed path issue in init script
  • Loading branch information
biofects authored Aug 24, 2024
2 parents 308ad73 + 1d204d5 commit 331aeaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions custom_components/simple_sticky_note/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from homeassistant.helpers.typing import ConfigType
from homeassistant.const import Platform
from homeassistant.helpers import config_validation as cv

from .const import DOMAIN

PLATFORMS: list[Platform] = [Platform.SENSOR]
Expand All @@ -12,27 +11,32 @@

async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Simple Sticky Note component."""
# This registers your JavaScript file to be served by Home Assistant
# Register the static path for your JavaScript file
hass.http.register_static_path(
f"/custom_components/{DOMAIN}/js/sticky_note_card.js",
hass.config.path(f"custom_components/{DOMAIN}/js/sticky_note_card.js"),
True
)

# Register as a Lovelace resource
hass.components.frontend.add_resources([f"/local/custom_components/{DOMAIN}/js/sticky_note_card.js"])
# Add the resource to Lovelace
resource_url = f"/custom_components/{DOMAIN}/js/sticky_note_card.js"
if not any(resource["url"] == resource_url for resource in hass.data["lovelace"]["resources"].async_items()):
await hass.data["lovelace"]["resources"].async_create_item({"res_type": "module", "url": resource_url})

return True

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Simple Sticky Note from a config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = entry.data

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

return True

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok
4 changes: 2 additions & 2 deletions custom_components/simple_sticky_note/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"name": "Simple Sticky Note",
"codeowners": ["@biofects"],
"config_flow": true,
"dependencies": [],
"dependencies": ["frontend", "lovelace"],
"documentation": "https://github.com/biofects/simple_sticky_note",
"iot_class": "local_push",
"issue_tracker": "https://github.com/biofects/simple_sticky_note/issues",
"requirements": [],
"version": "1.3.1"
"version": "1.3.6"
}

0 comments on commit 331aeaf

Please sign in to comment.