Make a Theme Stay After Reboot (Broke Again!)

I am sure this is very simple but as a noob to Hassio I am not sure how to get the theme I put on it to stay after a reboot. It goes back to the default each time. I setup a theme.yaml with my themes in it which are showing up under the user’s account to chose one. I chose say “dark_green” it says until I restart it… how do you make is permanent or at least until I change it?

Thanks ahead for any help

Here is an automation that will always make sure it uses dark_green theme after you restart.

automation:

  - alias: 'System - Set Custom Theme at Startup'
    initial_state: 'true'
    trigger:
      platform: homeassistant
      event: start
    action:
      service: frontend.set_theme
      data:
        name: dark_green
1 Like

could this be modified to set it to the last setting before restart with a template

Thank you @SeanM for the help

Chandler how would you go about doing that?

I’ve not tested this, but you can probably do something like this @gdreelin ;

input_text:
  default_theme:
    name: Default Theme

automation:
  - alias: 'Sync theme'
    trigger:
      - platform: homeassistant
        event: start
      - platform: state
        entity_id: input_text.default_theme
    action:
      service: frontend.set_theme
      data_template:
        name: '{{ states("input_text.default_theme") }}'

So I put the automation section in the automation.yaml but where does the input_text go in the configuration.yaml? Thanks @Jackwilsdon for all your help.

Assuming there’s already something like this in your configuration.yaml (which is there in the default configuration IIRC);

automation: !include automation.yaml

Then you want to put this in your automation.yaml;

- alias: 'Sync theme'
  trigger:
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: input_text.default_theme
  action:
    service: frontend.set_theme
    data_template:
      name: '{{ states("input_text.default_theme") }}'

And this in your configuration.yaml;

input_text:
  default_theme:
    name: Default Theme

If it doesn’t work I’ll set up a test instance of HASS and try this configuration out myself.

What about the state of my input selector with all my themes… although i think it goes back to default each time. But perhaps if made a sensor that would be the state of the last selected them and then that automation based off the state of that sensor… assuming the sensor didn’t change when you restart. I’m not sure

Have you set an initial value on your select? If so I don’t think Home Assistant will persist it.

You can probably just take my configuration from above, replacing the input_text entity with your drop-down.

Worked great!! Thanks

1 Like

@jackwilsdon - Well worked great until I rebooted host then it changed back… I am getting this “Theme Dark-Green is not defined.” I put in this on configuration.yaml:

input_text:
default_theme:
name: Dark - Green

And this in automation.yaml:

  • alias: ‘Sync theme’
    trigger:
    • platform: homeassistant
      event: start
    • platform: state
      entity_id: input_text.default_theme
      action:
      service: frontend.set_theme
      data_template:
      name: ‘{{ states(“input_text.default_theme”) }}’

Now in directory themes I have a “dark_green.yaml” which begins with this:

Dark - Green:

Main Interface Colors

primary-color: “#03B14B
light-primary-color: “#47FC92
primary-background-color: “#1F1F28
secondary-background-color: var(–primary-background-color)
divider-color: “#2F2F3D

Am I entering it in wrong?

Can you manually call the service frontend.set_theme with the data { "name": "Dark - Green" } using the services screen and see if that works? I don’t really know how theme names are used in frontend.set_theme.

I went to service screen but not sure what JSON to set for that. I just left it blank and got this:

Failed to call service frontend/set_theme. required key not provided @ data[‘name’]

You should use this JSON I provided in the reply above.

Nope it did not work trying it that way either… Now in your code above I used it as is which was correct right?

Yep, have you tried dark_green as the name instead? I don’t really know much about theming HASS.

Lol yep tried that too just in case but got nothing…oh well I will do it manual for now. Thanks for at least trying to help.

Ok the solution is what SeanM post but one minor change. I takes only the title name of the theme not the name of the yaml file. It will stay after reboot once you log in!

automation:

  - alias: 'System - Set Custom Theme at Startup'
    initial_state: 'true'
    trigger:
      platform: homeassistant
      event: start
    action:
      service: frontend.set_theme
      data:
        name: Dark - Green

I have to revisit this because something has cause this to stop working now. I still have the below but after rebooting now during the last two upgrades that automation is not being applied.

alias: Theme to Dark at Start
trigger:

  • event: start
    platform: homeassistant
    condition: []
    action:
  • data:
    name: Dark - Green
    service: frontend.set_theme

Any clues?