mirror of
https://github.com/thekiwismarthome/shopping-list-manager.git
synced 2026-05-01 11:46:30 +00:00
Add files via upload
This commit is contained in:
@@ -3,35 +3,24 @@ Shopping List Manager - Home Assistant Custom Integration
|
|||||||
Clean-slate architecture with enforced invariants
|
Clean-slate architecture with enforced invariants
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.components import websocket_api
|
from homeassistant.components import websocket_api as ha_websocket
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .manager import ShoppingListManager
|
from .manager import ShoppingListManager
|
||||||
|
# Import websocket handler functions directly
|
||||||
|
from .websocket_api import (
|
||||||
|
websocket_add_product,
|
||||||
|
websocket_set_qty,
|
||||||
|
websocket_get_products,
|
||||||
|
websocket_get_active,
|
||||||
|
websocket_delete_product,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|
||||||
"""Set up the Shopping List Manager component."""
|
|
||||||
# Register frontend path for the card (updated for HA 2023+)
|
|
||||||
frontend_path = Path(__file__).parent / "frontend"
|
|
||||||
hass.http.async_register_static_paths(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"url_path": f"/hacsfiles/{DOMAIN}",
|
|
||||||
"path": str(frontend_path),
|
|
||||||
"cache_headers": False,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
_LOGGER.info(f"Registered frontend path: /hacsfiles/{DOMAIN}")
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Shopping List Manager from a config entry."""
|
"""Set up Shopping List Manager from a config entry."""
|
||||||
# Initialize the manager
|
# Initialize the manager
|
||||||
@@ -42,20 +31,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN]["manager"] = manager
|
hass.data[DOMAIN]["manager"] = manager
|
||||||
|
|
||||||
# Register WebSocket commands
|
# Register WebSocket commands using Home Assistant's websocket_api
|
||||||
from .websocket_api import (
|
ha_websocket.async_register_command(hass, websocket_add_product)
|
||||||
websocket_add_product,
|
ha_websocket.async_register_command(hass, websocket_set_qty)
|
||||||
websocket_set_qty,
|
ha_websocket.async_register_command(hass, websocket_get_products)
|
||||||
websocket_get_products,
|
ha_websocket.async_register_command(hass, websocket_get_active)
|
||||||
websocket_get_active,
|
ha_websocket.async_register_command(hass, websocket_delete_product)
|
||||||
websocket_delete_product,
|
|
||||||
)
|
|
||||||
|
|
||||||
websocket_api.async_register_command(hass, websocket_add_product)
|
|
||||||
websocket_api.async_register_command(hass, websocket_set_qty)
|
|
||||||
websocket_api.async_register_command(hass, websocket_get_products)
|
|
||||||
websocket_api.async_register_command(hass, websocket_get_active)
|
|
||||||
websocket_api.async_register_command(hass, websocket_delete_product)
|
|
||||||
|
|
||||||
_LOGGER.info("Shopping List Manager setup complete - registered 5 WebSocket commands")
|
_LOGGER.info("Shopping List Manager setup complete - registered 5 WebSocket commands")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"domain": "shopping_list_manager",
|
"domain": "shopping_list_manager",
|
||||||
"name": "Shopping List Manager",
|
"name": "Shopping List Manager",
|
||||||
"version": "1.1.0",
|
"version": "1.0.0",
|
||||||
"documentation": "https://github.com/thekiwismarthome/shopping-list-manager",
|
"documentation": "https://github.com/thekiwismarthome/shopping-list-manager",
|
||||||
"issue_tracker": "https://github.com/thekiwismarthome/shopping-list-manager/issues",
|
"issue_tracker": "https://github.com/thekiwismarthome/shopping-list-manager/issues",
|
||||||
"requirements": [],
|
"requirements": [],
|
||||||
|
|||||||
Reference in New Issue
Block a user