Set Default Light & Dark Lovelace Theme

I’ve installed themes via HACS, but I actually like the Default theme. My problem is, I don’t know how to call it in an Automation.

If I, for example, install Google Theme, I can call it via frontend.set_theme. However, the Default theme is not an option. How do I get the Default theme to be an option I can select in an Automation?

Below is an Automation I created with the Google Theme. How do I get the Default theme as an option in this?

alias: Theme Change
description: ''
trigger:
  - platform: state
    entity_id: sun.sun
condition: []
action:
  - choose:
      - conditions:
          - condition: sun
            before: sunset
            after: sunrise
        sequence:
          - service: frontend.set_theme
            data:
              name: Google Theme
              mode: light
      - conditions:
          - condition: sun
            before: sunrise
            after: sunset
        sequence:
          - service: frontend.set_theme
            data:
              name: Google Theme
              mode: dark
    default: []
mode: single

There’s no need to automate the default theme.

Go to your profile and set the theme to Default, then set the mode to Auto. This will switch from light to dark and vice-versa depending on the sun.

That’s how I’ve had it set… It doesn’t auto change, and hasn’t for the ~4 years I’ve had HA. I just decided to get it to change.

Edit: This is a hassio VM on a Windows-based PC.

2 Likes

Oh actually it does not switch on the sun, it switches depending on the browsing device:

What are you viewing Home Assistant from, desktop PC, Phone?

It’s an Edge PWA on a Windows-based PC, but I don’t have the dark mode enabled for the browser.

Edit: As a test, I changed my default Edge browser theme to dark and yeah, the HA theme changed to dark. However, I don’t really like the browser dark theme. Is there anyway to call the Default Theme in an Automation?

I’m not 100% sure this will work but what happens if you try:

- service: frontend.set_theme
  data:
    mode: light # or dark

Thanks for the help. I can’t comment out ‘name:’ or leave it blank w/o HA throwing an error. :upside_down_face:

Edit: I was able to leave ‘name:’ blank and ‘default’ set as theme, but did not change. Oh well. Not a major drawback.

Interesting aspect I discovered… I don’t think it’s possible to change themes based on Sun condition anyway. I never did actually try the Google Theme change, but it does not work with the Automation. I’ve actually changed up the Automation and it will not fire; nothing in the logs. And, again, the theme will change if Auto selected and I changed browser theme.

Yeah it does work, but you must have “Backend-selected” selected in your profile.

You are probably going to have to recreate the default themes as there does not seem to be a way to switch them other than automatically by the device’s dark mode.

As of 2023, you can now force the default light mode, even if your system/browser normally prefers dark mode

Just go to your profile, select the ‘Default’ theme, then some radio buttons appear allowing you to select ‘Auto’, ‘Light’, ‘Dark’

1 Like

Even though the options ‘Auto’, ‘Light’, ‘Dark’ exist and I set the theme to Auto - it never ever changes to a dark theme at night.

Android Tablets with Chrome browser.
I want browser options to be disregarded and dark theme to be enforced based on sunsets.

1 Like

Hi everyone,
It’s my first post and since this aspect has been driving me crazy for a long time I would like to contribute with my experience.
I would like the appearance to always be Dark without any conditions.
For this reason I set “DARK” between the 3 options and at the precise moment in which I set it the theme correctly changes to DARK color, EVEN in broad daylight.
My problem is that it doesn’t keep this setting saved (… or maybe I didn’t understand if there is a SAVE button…?!?).
In fact, if I execute DISCONNECT and reopen HA I find the AUTO setting again, and in fact it reopens with the light color.
Is there anyone who can confirm that this is indeed an error?
In light mode, even if I want to perform the action manually from developer tools - services - frontend.set_theme - set Home Assistant theme - dark mode - call service - it doesn’t give me errors but visually the theme doesn’t change…
Thanks if anyone can give me some help.

same here: how can you keep Dark mode always ON even after logging out then logging in ?