ha-branding-overrides

ha-branding-overrides

ha-branding-overrides

Part of the Crooked Sentry universe Validate Codecov test coverage

Overview

ha-branding-overrides is the recommended extraction target for the global Home Assistant branding override module that currently lives in this repo.

This repo ships one HACS dashboard/plugin artifact: dist/ha-branding-overrides.js.

Runtime Model

This package is a global frontend module, not a Lovelace card.

HACS can distribute the JavaScript artifact, but Home Assistant still needs to load it through frontend.extra_module_url.

The package is intentionally BYOB:

The extracted implementation does these things:

Repo Layout

ha-branding-overrides/
  .github/
    workflows/
      validate.yml
  dist/
    ha-branding-overrides.js
  examples/
    branding-overrides-config.example.js
    frontend.extra_module_url.yaml
    example-assets/
      README.md
  scripts/
    build_plugin.mjs
  screenshots/
  src/
    ha-branding-overrides.js
  tests/
    validate-dist.mjs
  .gitignore
  README.md
  hacs.json
  package.json

Public Config Contract

The module reads window.ha_branding_overrides before it initializes.

Example:

window.ha_branding_overrides = {
  appName: "Example Home",
  homeAssistantName: "Home Assistant",
  icon32Url: "/local/branding/favicon-32.png",
  icon192Url: "/local/branding/favicon-192.png",
  logoUrl: "/local/branding/logo.svg",
  logoAlt: "Example Home",
  logoSelectors: [".header img"],
  removeSelectors: ['[data-default-brand-logo="1"]'],
  themeColor: "#365D49",
  titleReplacements: [
    { from: "Home Assistant", to: "Example Home" }
  ],
  textReplacements: [
    { from: "Home Assistant", to: "Example Home" }
  ],
  auth: {
    enabled: true,
    name: "Example Home",
    icon32Url: "/local/branding/favicon-32.png",
    icon192Url: "/local/branding/favicon-192.png",
    logoLightUrl: "/local/branding/auth-logo-light.svg",
    logoDarkUrl: "/local/branding/auth-logo-dark.svg",
    theme: {
      light: {
        primary: "#365D49",
        accent: "#FFDE3F"
      },
      dark: {
        primary: "#6D9B7B",
        accent: "#FFDE3F"
      }
    }
  }
};

Recommended supported values:

If appName is set and you do not provide custom replacement arrays, the module still defaults to replacing exact Home Assistant references in titles and text nodes.

Optional Auth Page Branding

Auth branding is opt-in and has no dependency on a specific OIDC, SSO, NetBird, or Authentik setup.

Set window.ha_branding_overrides.auth.enabled = true and load this same module on the auth page. When the current page looks like a Home Assistant auth page, the module will:

Supported auth values:

For compatibility with earlier Crooked Sentry auth work, the module also reads window.auth_oidc_branding as a fallback. New installs should prefer window.ha_branding_overrides.auth so branding remains independent from any auth package.

Loading note: Home Assistant frontend.extra_module_url is enough for normal frontend branding. Auth pages may be served by a separate auth provider or custom auth flow, so that provider must also load the config script and ha-branding-overrides.js if you want auth-page branding.

HACS Install

  1. Add the repository to HACS as a Dashboard.
  2. Install HA Branding Overrides.
  3. Create your own config script from examples/branding-overrides-config.example.js.
  4. Load the config script and the HACS-installed module from frontend.extra_module_url.

Example:

frontend:
  extra_module_url:
    - /local/branding-overrides-config.js
    - /hacsfiles/ha-branding-overrides/ha-branding-overrides.js

The config script must load first.

Manual Install

  1. Copy dist/ha-branding-overrides.js into your Home Assistant www/ directory.
  2. Create your own config script, for example /config/www/branding-overrides-config.js.
  3. Load both through frontend.extra_module_url:

    frontend:
      extra_module_url:
        - /local/branding-overrides-config.js
        - /local/ha-branding-overrides.js
    

Maintainer Workflow

  1. Edit src/ha-branding-overrides.js.
  2. Rebuild the install artifact:

    npm run build
    
  3. Run validation:

    npm run check
    npm test
    
  4. Commit both the source file and the generated dist/ha-branding-overrides.js.

The CI workflow fails if the built artifact is out of date.

Packaging Rules

Recommended public rename for the extracted module:

That applies to:

Extraction Mapping

Current source file in this monorepo maps to the extracted repo like this:

Current install automation in this repo also wires the script into frontend.extra_module_url in:

The extracted public repo should ship only the reusable frontend module and examples. Appliance-specific automation stays in this monorepo.

Notes