def setup(hass, config): """Initialize custom panel.""" success = False for panel in config.get(DOMAIN): name = panel.get(CONF_COMPONENT_NAME) panel_path = panel.get(CONF_WEBCOMPONENT_PATH) if panel_path is None: panel_path = hass.config.path(PANEL_DIR, '{}.html'.format(name)) if not os.path.isfile(panel_path): _LOGGER.error('Unable to find webcomponent for %s: %s', name, panel_path) continue register_panel( hass, name, panel_path, sidebar_title=panel.get(CONF_SIDEBAR_TITLE), sidebar_icon=panel.get(CONF_SIDEBAR_ICON), url_path=panel.get(CONF_URL_PATH), config=panel.get(CONF_CONFIG), ) success = True return success
def test_panel_with_url(hass): """Test panel registration without file path.""" register_panel(hass, 'test_component', None, url='some_url') assert hass.data[DATA_PANELS] == { 'test_component': { 'component_name': 'test_component', 'url': 'some_url', 'url_path': 'test_component' } }
def setup(hass, config): """Initialize custom panel.""" title = config.get(DOMAIN, {}).get('title') config = None if title is None else {'title': title} register_panel(hass, 'react', PANEL_PATH, title='TodoMVC', icon='mdi:checkbox-marked-outline', config=config) return True
def maybe_load_panel(hass, conf_panel): """Maybe load CustomUI panel. Async friendly.""" if conf_panel is True and MINOR_VERSION <= 52: frontend.register_panel( hass, "custom-ui", hass.config.path('panels/ha-panel-custom-ui.html'), sidebar_title="Custom UI", sidebar_icon="mdi:domain") elif conf_panel is not None: _LOGGER.error( '%s setting is deprecated.' 'Starting from HA 0.53 it is auto-added to config panel', CONF_PANEL)
def test_panel_without_path(hass): """Test panel registration without file path.""" register_panel(hass, 'test_component', 'nonexistant_file') assert hass.data[DATA_PANELS] == {}