Automation to change Theme on start is failing (Solved)

Hi
I have a fresh install of Hassio on a Raspberry pi 3+. running Home Assistant 0.92.2.
I am trying to have the theme change to a custom theme when HA starts up.

So far all that I have done in this installation is add the IDE addon and made the following changes to Configuration.yaml

frontend:
  themes: !include themes.yaml

and created themes.yaml with code copied from the forum and posted below…

I have also added the following code to the automation.yaml

- id: a_start_theme
  alias: 'Set theme at startup'
  trigger:
    platform: homeassistant
    event: start
  action:
    service: frontend.set_theme
    data:
      name: midnight

I can change the theme manually and it works.The log shows that the code runs on startup and I have also tried to run it by using the Trigger on the automation card but nothing happens. I have checked the logs but there are no entries being logged except in the Logbook which shows that the automation was run. I am at a loss of where to look now so any help would be appreciated.

Peter

Theme code

midnight:
  # Main colors
  primary-color: '#5294E2'                                                        # Header
  accent-color: '#E45E65'                                                         # Accent color
  dark-primary-color: 'var(--accent-color)'                                       # Hyperlinks                                         
  light-primary-color: 'var(--accent-color)'                                      # Horizontal line in about
                                                                               
  # Text colors                                                                  
  primary-text-color: '#FFFFFF'                                                   # Primary text colour, here is referencing dark-primary-color
  text-primary-color: 'var(--primary-text-color)'                                 # Primary text colour
  secondary-text-color: '#5294E2'                                                 # For secondary titles in more info boxes etc.
  disabled-text-color: '#7F848E'                                                  # Disabled text colour
  label-badge-border-color: 'green'                                               # Label badge border, just a reference value   
  
  # Background colors                                                            
  primary-background-color: '#383C45'                                             # Settings background
  secondary-background-color: '#383C45'                                           # Main card UI background  
  divider-color: 'rgba(0, 0, 0, .12)'                                             # Divider 
    
  # Table rows                                                                   
  table-row-background-color: '#353840'                                           # Table row
  table-row-alternative-background-color: '#3E424B'                               # Table row alternative
                                                                               
  # Nav Menu                                                                   
  paper-listbox-color: 'var(--primary-color)'                                     # Navigation menu selection hoover
  paper-listbox-background-color: '#2E333A'                                       # Navigation menu background
  paper-grey-50: 'var(--primary-text-color)'                                   
  paper-grey-200: '#414A59'                                                       # Navigation menu selection
                                                                               
  # Paper card                                                               
  paper-card-header-color: 'var(--accent-color)'                                  # Card header text colour
  paper-card-background-color: '#434954'                                          # Card background colour
  paper-dialog-background-color: '#434954'                                        # Card dialog background colour
  paper-item-icon-color: 'var(--primary-text-color)'                              # Icon color
  paper-item-icon-active-color: '#F9C536'                                         # Icon color active
  paper-item-icon_-_color: 'green'           
  paper-item-selected_-_background-color: '#434954'                               # Popup item select                      
  paper-tabs-selection-bar-color: 'green'
  
  # Labels 
  label-badge-red: 'var(--accent-color)'                                          # References the brand colour label badge border
  label-badge-text-color: 'var(--primary-text-color)'                             # Now same as label badge border but that's a matter of taste
  label-badge-background-color: '#2E333A'                                         # Same, but can also be set to transparent here
  
  # Switches
  paper-toggle-button-checked-button-color: 'var(--accent-color)'
  paper-toggle-button-checked-bar-color: 'var(--accent-color)'
  paper-toggle-button-checked-ink-color: 'var(--accent-color)'
  paper-toggle-button-unchecked-button-color: 'var(--disabled-text-color)'
  paper-toggle-button-unchecked-bar-color: 'var(--disabled-text-color)'
  paper-toggle-button-unchecked-ink-color: 'var(--disabled-text-color)'  
  
  # Sliders
  paper-slider-knob-color: 'var(--accent-color)'
  paper-slider-knob-start-color: 'var(--accent-color)'
  paper-slider-pin-color: 'var(--accent-color)'
  paper-slider-active-color: 'var(--accent-color)'
  paper-slider-container-color: 'linear-gradient(var(--primary-background-color), var(--secondary-background-color)) no-repeat'
  paper-slider-secondary-color: 'var(--secondary-background-color)'
  paper-slider-disabled-active-color: 'var(--disabled-text-color)'
  paper-slider-disabled-secondary-color: 'var(--disabled-text-color)'
  
  # Google colors
  google-red-500: '#E45E65'
  google-green-500: '#39E949'

Are you setting the theme to backend-selected in your user config on the frontend?

Just set to default under Themes in profile. I was expecting it to change from default to the selected custom theme when the automation runs. Not sure what the Back-end selected does though.
I was starting here as a simple change with the thought of changing themes by events later.

Peter

the backend-selected is the what is chosen by HA, ie theme automation. The default theme is just the basic generic blue theme that comes with HA

1 Like

So in affect I can only change themes if themes are set to back end?
I will copy some more themes and try to change using more events :slight_smile:
Thanks for the pointer

Yes, That is how automated themes are handled.

Thanks, I have it working now.

Peter

Hi Peter, how did you get this to work? Could you please share your updated automations? thanks!

nevermind I got it to work. I had the wrong theme name. corrected it and it now works!