Set theme not working

I has something to do with my firefox browser, chrome picked up the manual call just fine, i am going to see if the automation works tonight, i have a feeling it will.

now just need to chase down why firefox wolnt.

I don’t use Firefox with HA, but I wonder if it has something to do with 0.58 update which had a JavaScript update. Try updating your config with this:

frontend:
  javascript_version: latest

hi sorry to bump this, but im in desperate need of assistance.

Ive tried anything to get my computer back to Backend-select, (because i use automations to switch automatically) but it won’t work, and the option is not within reach in the configuration page, all other themes i have are.

therefor i tried something like your settings:

input_select:
  set_current_theme:
    name: 'Set Current Theme'
    options:
     - 'Backend-selected'
     - 'default'
     - 'teal'
     - 'darkorange'
     - 'darkred'
     - 'darkcyan'
     - 'minimal'
     - 'vintage'
    initial: 'Backend-selected'
    icon: 'mdi:palette'


automation:
  - id: '1511601488032'
    alias: 'Change Current Theme'
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: input_select.set_current_theme
    action:
      - service: frontend.set_theme
        data_template:
          name: '{{states.input_select.set_current_theme.state}}'

this seems to kill my setup however, taking it into some loop it won’t get out off. And no theme switching at all.

So, a twofold question:

What could be wrong in this code
How to get back to Backend-selected

Code looks like mine and it works, how does your Backend-selected looks like?

not really sure what you mean? I cant see it in this list:

its above the default, and won’t get there…

i have one simple automation that sets the theme depending on sunset/rise, and works just fine. Unless one has set a theme on a device of course.

- alias: Automatic Theme Change
  id: '1511601488029'
  initial_state: 'on' 
  trigger:
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: sun.sun
      to: above_horizon
    - platform: state
      entity_id: sun.sun
      to: below_horizon
  condition: []
  action:
    - service_template: frontend.set_theme
      data_template:
        name: >
          {% if states.sun.sun.state == "above_horizon" %}
            default
          {% else %}
            darkred
          {% endif %}
    - delay: 00:00:02
    - service: notify.notify
      data_template:
        message: 'It is {{ as_timestamp(now()) | timestamp_custom("%X") }}, 
                   Sun is {{states.sun.sun.state}} and
                  Frontend is set.'

I’ve tried to set i in the dev tools, but not sure of the correct json to use there. Can we set the Backend-selected by means of an automation? or input-select at all?

You have a theme in your configuration or themes.yaml called Backend-selected?

Like this Share your Themes

Also, in your code, is there anything in your conditions?

ah ok,
no i don’t . there shouldn’t be one should there? its whatever the backend selects…
no conditions. I have empty [] just to remind where they might have to come if ever… basic template i use to be safe.

Im pretty sure you cannot have a none existing selection.

Also im curious if you have any conditions condition: [] or if you not wanted to show them?

no noting to hide :wink: just empty.
This cause no issues though i have them in many automations, and they all work fine.

about the Backend-selected: how can we set it to that, if i cant reach it anywhere. Should be some setting? Can you see it in the configuration page?

If you try to replace with below and see how that goes?

input_select:
  set_current_theme:
    name: 'Set Current Theme'
    options:
     - 'default'
     - 'teal'
     - 'darkorange'
     - 'darkred'
     - 'darkcyan'
     - 'minimal'
     - 'vintage'
    initial: 'default'
    icon: 'mdi:palette'

i just did and rebooting as we type;-) will report back. Still i would need to find Backend-selected somehow…

I havent heard about backend-selected before.

This is my input:select without backend-selected:

  utseende:
    name: 'Utseende'
    icon: 'mdi:palette'
    initial: default
    options:
     - 'default'
     - 'solarized'
     - 'PmxDefault'
     - 'wood'
     - 'minimal'
     - 'stormy_hues'
     - 'teal'
     - 'PmxMononight'
     - 'PmxMonolight'
     - 'Night_Theme'
     - 'midnight'
     - 'material_dark_green'
     - 'Night'
     - 'darkcyan'
     - 'darkred'
     - 'Matrix_Theme'

But in the backend i have the option anyway:

1 Like

well, taking out Backend-selected makes Hassio boot fine again, and the selector show fine too. It doesn’t work though.
Also, one would expect the selector to ‘see’ the set state of the configuration page, or vice versa. I don’t think they correspond ? What happens in your setting when changing themes?

And yes, the Backend should show up there, cant get it to show up…

When i select for example solarized in frontend it shows what i selected and theme change.
But the backend doesn’t show the theme i selected.

at least we have that in common then :wink:
i take it you have custom-ui installed?

No i am not using custom-ui.

not sure whats happening, but I’ve changed the automation into this:

   - alias: 'Switch Theme'
    id: '1511601488033'
    initial_state: on
    trigger:
      - platform: state
        entity_id: input_select.theme
#      - platform: homeassistant
#        event: start
    action:
      - service: frontend.set_theme
        data_template:
          name: >-
            {% if is_state('input_select.theme', 'default')%}default
            {% elif is_state('input_select.theme', 'teal')%}teal
            {% elif is_state('input_select.theme', 'darkorange')%}darkorange
            {% elif is_state('input_select.theme', 'darkred')%}darkred
            {% elif is_state('input_select.theme', 'darkcyan')%}darkcyan
            {% elif is_state('input_select.theme', 'minimal')%}minimal
            {% elif is_state('input_select.theme', 'vintage')%}vintage
            {% endif %}

this works!
Also, to circumvent any add blocker or other security tool i have installed, I’ve tested with a private browsing session. I can now see Backend-selected in the configuration page …

Needs further investigating which caused what… regular Safari (with and without adblovkers etc) doesn’t work, private mode does. As does Chrome, with all security in place. Hate Firefox…keeps relocating before i have entered the url…

btw, the original automation i posted above also seems to work in private mode. So it must be that. Now have to figure out whats causing this strange browser behavior. Maybe its just Safari :-0. Hope it is a setting or adding in Safari…

enabling the selector/automation in private mode in Safari somehow brought back the Backend-selected on the configuration page/themes setting. Clicking that still doesn’t show the option, while all other themes are available. So something isn’t right just yet. This goes for Chrome as well, not able to select the option, though showing when entering the page.

Anyways thanks!
Marius

Im only using chrome so i cant tell :slight_smile:

This is my automation:

- id: change_current_theme
  alias: 'Change Current Theme'
  initial_state: 'on'
  trigger:
      - platform: state
        entity_id: input_select.utseende
  action:
      - service: frontend.set_theme
        data_template:
          name: '{{states.input_select.utseende.state}}'
2 Likes

Just to make that simple and clear:

frontend.set_theme will ONLY work, if you have chosen theme “Backend-selected” under your profile in HA.
If you have selected any other theme there, it is NOT possible to change that theme through automations.

1 Like

Thanks for clarifying that. I wish this was mentioned in the Frontend documentation.
However, I observe different behaviour (HA 0.112.1) between Firefox and Chrome. In Firefox indeed the theme should be set to “Backend-selected” for frontend.set_theme to work but in Chrome that seems to work even if a specific theme is selected in your profile.