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
|
||||
"""
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
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 .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__)
|
||||
|
||||
|
||||
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:
|
||||
"""Set up Shopping List Manager from a config entry."""
|
||||
# Initialize the manager
|
||||
@@ -42,20 +31,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN]["manager"] = manager
|
||||
|
||||
# Register WebSocket commands
|
||||
from .websocket_api import (
|
||||
websocket_add_product,
|
||||
websocket_set_qty,
|
||||
websocket_get_products,
|
||||
websocket_get_active,
|
||||
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)
|
||||
# Register WebSocket commands using Home Assistant's websocket_api
|
||||
ha_websocket.async_register_command(hass, websocket_add_product)
|
||||
ha_websocket.async_register_command(hass, websocket_set_qty)
|
||||
ha_websocket.async_register_command(hass, websocket_get_products)
|
||||
ha_websocket.async_register_command(hass, websocket_get_active)
|
||||
ha_websocket.async_register_command(hass, websocket_delete_product)
|
||||
|
||||
_LOGGER.info("Shopping List Manager setup complete - registered 5 WebSocket commands")
|
||||
|
||||
@@ -65,4 +46,4 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload Shopping List Manager."""
|
||||
hass.data[DOMAIN].pop("manager", None)
|
||||
return True
|
||||
return True
|
||||
@@ -2199,4 +2199,4 @@ window.customCards.push({
|
||||
name: 'Shopping List',
|
||||
description: 'A shopping list card with search, categories, and product images.',
|
||||
preview: false
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"domain": "shopping_list_manager",
|
||||
"name": "Shopping List Manager",
|
||||
"version": "1.1.0",
|
||||
"version": "1.0.0",
|
||||
"documentation": "https://github.com/thekiwismarthome/shopping-list-manager",
|
||||
"issue_tracker": "https://github.com/thekiwismarthome/shopping-list-manager/issues",
|
||||
"requirements": [],
|
||||
@@ -9,4 +9,4 @@
|
||||
"codeowners": ["@thekiwismarthome"],
|
||||
"config_flow": true,
|
||||
"iot_class": "local_polling"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user