Don't load themes in safe mode (#102683)

This commit is contained in:
Bram Kragten 2023-10-24 23:00:14 +02:00 committed by GitHub
parent 0b8f48205a
commit f5a6c88051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 12 deletions

View File

@ -666,18 +666,13 @@ def websocket_get_themes(
hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any] hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any]
) -> None: ) -> None:
"""Handle get themes command.""" """Handle get themes command."""
if hass.config.recovery_mode: if hass.config.recovery_mode or hass.config.safe_mode:
connection.send_message( connection.send_message(
websocket_api.result_message( websocket_api.result_message(
msg["id"], msg["id"],
{ {
"themes": { "themes": {},
"recovery_mode": { "default_theme": "default",
"primary-color": "#db4437",
"accent-color": "#ffca28",
}
},
"default_theme": "recovery_mode",
}, },
) )
) )

View File

@ -180,10 +180,17 @@ async def test_themes_api(hass: HomeAssistant, themes_ws_client) -> None:
await themes_ws_client.send_json({"id": 6, "type": "frontend/get_themes"}) await themes_ws_client.send_json({"id": 6, "type": "frontend/get_themes"})
msg = await themes_ws_client.receive_json() msg = await themes_ws_client.receive_json()
assert msg["result"]["default_theme"] == "recovery_mode" assert msg["result"]["default_theme"] == "default"
assert msg["result"]["themes"] == { assert msg["result"]["themes"] == {}
"recovery_mode": {"primary-color": "#db4437", "accent-color": "#ffca28"}
} # safe mode
hass.config.recovery_mode = False
hass.config.safe_mode = True
await themes_ws_client.send_json({"id": 7, "type": "frontend/get_themes"})
msg = await themes_ws_client.receive_json()
assert msg["result"]["default_theme"] == "default"
assert msg["result"]["themes"] == {}
async def test_themes_persist( async def test_themes_persist(