Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also update background_color in web app manifest on theme change #116313

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions homeassistant/components/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
CONF_JS_VERSION = "javascript_version"

DEFAULT_THEME_COLOR = "#03A9F4"
DEFAULT_BACKGROUND_COLOR = "#FFFFFF"


DATA_PANELS = "frontend_panels"
Expand All @@ -67,6 +68,7 @@
VALUE_NO_THEME = "none"

PRIMARY_COLOR = "primary-color"
PRIMARY_BACKGROUND_COLOR = "primary-background-color"

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -151,7 +153,7 @@ def update_key(self, key: str, val: str) -> None:

MANIFEST_JSON = Manifest(
{
"background_color": "#FFFFFF",
"background_color": DEFAULT_BACKGROUND_COLOR,
"description": (
"Home automation platform that puts local control and privacy first."
),
Expand Down Expand Up @@ -436,7 +438,7 @@ async def _async_setup_themes(

@callback
def update_theme_and_fire_event() -> None:
"""Update theme_color in manifest."""
"""Update theme_color and background_color in manifest."""
name = hass.data[DATA_DEFAULT_THEME]
themes = hass.data[DATA_THEMES]
if name != DEFAULT_THEME:
Expand All @@ -447,8 +449,13 @@ def update_theme_and_fire_event() -> None:
themes[name].get(PRIMARY_COLOR, DEFAULT_THEME_COLOR),
),
)
MANIFEST_JSON.update_key(
"background_color",
themes[name].get(PRIMARY_BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR),
)
else:
MANIFEST_JSON.update_key("theme_color", DEFAULT_THEME_COLOR)
MANIFEST_JSON.update_key("background_color", DEFAULT_BACKGROUND_COLOR)
hass.bus.async_fire(EVENT_THEMES_UPDATED)

@callback
Expand Down