So pulling my hair out here. when trying to call frontend.set_theme using {"name":"default"} using services tab under developer tools i can not get the theme to revert back to default, or any other theme for that matter. i can use the configuration tool and manual select it from a drop down, and everything looks good, but automation or direct call will not work. I am getting no warnings or errors, am i crazy or did i miss something.
the code i am using for the automations is below
# automations.yaml
- alias: "Set dark theme for the night"
initial_state: on
trigger:
- platform: time
at: '21:00'
action:
- service: frontend.set_theme
data:
name: darkcyan
- alias: "Set light theme for day"
initial_state: on
trigger:
- platform: time
at: '9:00'
action:
- service: frontend.set_theme
data:
name: default
#configurations.yaml
frontend:
javascript_version: latest
themes: !include_dir_merge_named themes/
#dark_cyan.yaml in themes folder
darkcyan:
# Main colors that can be changed
primary-color: "#00bcd4"
disabled-text-color: "#545454"
divider-color: "rgba(255, 255, 255, 0.12)"
paper-card-background-color: "#4e4e4e"
paper-grey-200: "#191919"
paper-item-icon-color: "#d3d3d3"
paper-listbox-background-color: "#202020"
paper-listbox-color: "#FFFFFF"
primary-background-color: "#303030"
primary-text-color: "#cfcfcf"
secondary-background-color: "#2b2b2b"
secondary-text-color: "#04a7bc"
# Colors based on variables, see above
label-badge-background-color: "var(--secondary-background-color)"
label-badge-text-color: "var(--text-primary-color)"
paper-card-header-color: "#var(--paper-item-icon-color)"
paper-grey-50: "var(--primary-text-color)"
paper-item-icon-active-color: "var(--primary-color)"
paper-item-icon_-_color: "var(--primary-text-color)"
paper-slider-active-color: "var(--primary-color)"
paper-slider-knob-color: "var(--primary-color)"
paper-slider-knob-start-color: "var(--primary-color)"
paper-slider-pin-color: "var(--primary-color)"
paper-slider-secondary-color: "var(--light-primary-color)"
paper-toggle-button-checked-ink-color: "var(--dark-primary-color)"
paper-toggle-button-checked-button-color: "var(--primary-color)"
paper-toggle-button-checked-bar-color: "var(--light-primary-color)"
paper-toggle-button-unchecked-bar-color: "var(--primary-text-color)"
Not sure why this isn’t working. Here’s what I have and it works just fine. I use an input_select to change the theme. Also have an automation to change at sunset/sunrise between light and dark modes. You’ll just have to edit for the themes that you have. Cheers
theme:
name: Current Theme
icon: mdi:theme-light-dark
options:
- Dark Red
- Dark Orange
- Dark Blue
- Dark Green
- Dark Cyan
- Dark Custom
- Light Gray
- Light Blue
- Light Cyan
- Light Monochrome
dark_theme:
name: Dark Mode Theme
icon: mdi:palette
initial: Dark Blue
options:
- Dark Red
- Dark Orange
- Dark Blue
- Dark Green
- Dark Cyan
- Dark Custom
light_theme:
name: Light Mode Theme
icon: mdi:palette
initial: Light Blue
options:
- Light Gray
- Light Blue
- Light Cyan
- Light Monochrome
Input Boolean
switch_theme:
name: Auto Switch Dark and Light Modes
icon: mdi:weather-night
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.
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:
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.
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?
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.
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…
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.