ERROR when trying to switch themes via Services

I am getting an error when I try to run the service frontend.reload_themes

2019-12-23 08:38:29 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140332076830544] 'frontend'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/frontend/__init__.py", line 368, in reload_themes
    new_themes = load_yaml_config_file(path)[DOMAIN].get(CONF_THEMES, {})
KeyError: 'frontend'

Any help would be greatly appreciated

That error looks like it can’t read the frontend section from your configuration.yaml file. For me the section looks like this:

frontend:
  themes: !include themes.yaml

What does yours look like?

If you have a valid frontend section like that, I’d try checking the config (Configuration > Server Controls > Check Config) and see if it finds any errors which may prevent it from being read correctly.

It seems to be reading the frontend section just fine. I can switch themes via the user settings page:38 AM

And the Check Config has never given me an issue with the frontend

I am having the exact same problem.

So now I seem to be getting a different error.

2020-01-13 17:59:02 ERROR (MainThread) [frontend.js.latest.201912041] https://seabitt.duckdns.org/frontend_latest/app.714f6631.js:2:87671 Uncaught SecurityError: Blocked a frame with origin "https://seabitt.duckdns.org" from accessing a cross-origin frame.
2020-01-13 17:59:04 INFO (MainThread) [homeassistant.components.frontend] Theme Dark set as default

The last line indicates that the them has changed although it did not change.

I’m getting similar error and can’t find a way to solve it. Also several updates of Home Assistant in the past didn’t solve the error. It occurs when I try to use a Theme from HACS. The normal “dark mode” I can select without problems.

Logger: homeassistant.core
Source: components/frontend/init.py:468
First occurred: 22:05:26 (2 occurrences)
Last logged: 22:06:38

Error executing service: <ServiceCall frontend.reload_themes (c:3a56d98e44a93e7a2d1b007bdf56e1fc)>
Error executing service: <ServiceCall frontend.reload_themes (c:9dead53fda6d714bb182dbde3c8dd34f)>
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/core.py”, line 1648, in catch_exceptions
await coro_or_task
File “/usr/src/homeassistant/homeassistant/core.py”, line 1667, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 738, in admin_handler
await result
File “/usr/src/homeassistant/homeassistant/components/frontend/init.py”, line 468, in reload_themes
new_themes = config[DOMAIN].get(CONF_THEMES, {})
KeyError: ‘frontend’

Update 06.03.2022

My problem was solved here: Switching to HACS themes not possible - #3 by ryzn