Files
rikku-home-assistant/custom_components/dwains_dashboard/load_dashboard.py
T
2025-04-21 21:03:30 -04:00

37 lines
1.2 KiB
Python

import logging
from homeassistant.components.lovelace.dashboard import LovelaceYAML
from homeassistant.components.lovelace import _register_panel
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
def load_dashboard(hass, config_entry):
#_LOGGER.warning(config_entry.options)
#_LOGGER.warning(config_entry.options["sidepanel_title"])
sidepanel_title = "Dwains Dashboard"
sidepanel_icon = "mdi:alpha-d-box"
if("sidepanel_title" in config_entry.options):
sidepanel_title = config_entry.options["sidepanel_title"]
if("sidepanel_icon" in config_entry.options):
sidepanel_icon = config_entry.options["sidepanel_icon"]
dashboard_url = "dwains-dashboard"
dashboard_config = {
"mode": "yaml",
"icon": sidepanel_icon,
"title": sidepanel_title,
"filename": "custom_components/dwains_dashboard/lovelace/ui-lovelace.yaml",
"show_in_sidebar": True,
"require_admin": False,
}
hass.data["lovelace"].dashboards[dashboard_url] = LovelaceYAML(hass, dashboard_url, dashboard_config)
_register_panel(hass, dashboard_url, "yaml", dashboard_config, False)