Best method for default theme?

What I’d like to do is set a default theme so when guests log in it doesn’t blind them. I tried the automation method and it didn’t seem to work. Is there an easier method I am overlooking?

3 Likes

You can attach a theme to the user

so you need to create a Guess user

I know how to change themes but this does not show me how to attach a theme to a user. I want it to be a specific theme on a certain user when they log in. In this case the guest user. If I log into this user on a different device it does not keep the dark theme I chose on my desktop.

1 Like

Bumping for help.

I set up an automation that sets the frontend theme on HA start.

- id: '...'
  alias: Set Theme on HA Start
  description: ''
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - data:
      name: <theme_name>
    service: frontend.set_theme
3 Likes

This I’ve tried as well, but it does not change the default log in screen, which is still blindingly white.

did you find a solution ?

I’m also curious if a solution was found :slight_smile:

I am interested as well. I need to set up specific theme for kiosk mode (where is no option to adjust “user” settings)

not sure if this is what you want - but to set a default theme that any device will see when they open HASS, this worked for me…

in automations.yaml

- alias: 'Set theme at startup'
  trigger:
    platform: homeassistant
    event: start
  action:
    service: frontend.set_theme
    data:
      name: THEME_YOU_WANT
2 Likes

based on the docs:

and the info given above, I built this automation which triggers at HA start and sun up/down to switch themes:

alias: "Theme: Auto Change"
description: trigger at HA startup / sun up / sun down
trigger:
  - event: start
    platform: homeassistant
  - entity_id: sun.sun
    platform: state
    to: above_horizon
    id: up
  - entity_id: sun.sun
    platform: state
    to: below_horizon
    id: down
action:
  - choose:
      - conditions:
          - condition: trigger
            id: down
        sequence:
          - service: frontend.set_theme
            data:
              mode: dark
              name: day_and_night
      - conditions:
          - condition: trigger
            id: up
        sequence:
          - service: frontend.set_theme
            data:
              mode: light
              name: day_and_night
    default:
      - service: frontend.set_theme
        data:
          mode: light
          name: day_and_night
mode: single
``
2 Likes

Updated to the latest automations format if anyone needs it.

alias: set theme 
description: ""
triggers:
  - trigger: event
    event_type: homeassistant 
    event_data:
      event: start
conditions: []
actions:
  - action: frontend.set_theme
  metadata: {}
  data:
    name: <THEME NAME HERE>
mode: single
1 Like

The answer I’m missing here is the way to set the default theme by using an Action.
Go into the developer tab, then into actions and search for set default theme.
There you can set the default theme that gets used when the user has “use default theme” configured in their user settings.

4 Likes

Thanks!
I googled hard for that one :joy:

Couldn’t get this to work - even after clearing the cache and restarting HA, always reverts to a default theme. In Studio Code Server, I had to revise some of your indentations to get the following automation, which is also trying to set the dark/light mode in the default setting:

- alias: set theme
  description: ""
  triggers:
    - trigger: event
      event_type: homeassistant
      event_data:
        event: start
  conditions: []
  actions:
    - action: frontend.set_theme
      metadata: {}
      data:
         mode: dark
         name: whatsapp_theme

Also, checked this option under the Developer Tools/Actions as YAML-UI:

action: frontend.set_theme
data:
  mode: dark
  name: whatsapp_theme

So, this seems to be the code you want to “somehow” implement, but again, after logging out and back into HA, the theme is always reverts to some default theme.
Posty-Scripty: I could have saved a copy of the theme and (possibly?) “hard-wired” the yaml code to “dark” but I find, if possible, using the mode option is more elegant & flexible.