Yes but sometimes I don’t see backend select!
That was the original problem!
How do you change theme from an automation if you can’t set it to backend select originally?
Yes but sometimes I don’t see backend select!
That was the original problem!
How do you change theme from an automation if you can’t set it to backend select originally?
well, I guess can simply use the automation to set the theme, I think that’s how it was set in my setup while I couldnt see it in the select itself.
this is what I setup, and never look back:
#homeassistant:
# customize:
##########################################################################################
# Groups
##########################################################################################
group:
theme_selector:
name: Theme selector
icon: mdi:palette
entities:
- input_select.set_sunrise_theme
- input_select.set_sunset_theme
- sensor.sun_based_theme
- automation.sun_based_theme_change
- input_select.theme
##########################################################################################
# Sensors
##########################################################################################
sensor:
- platform: template
sensors:
sun_based_theme:
friendly_name: Sun based theme
value_template: >
{% if is_state('sun.sun','above_horizon') %}
{{states('input_select.set_sunrise_theme')}}
{% else %}
{{states('input_select.set_sunset_theme')}}
{% endif %}
icon_template: >
{% if is_state('sun.sun', 'above_horizon') %}
mdi:weather-sunny
{% else %}
mdi:weather-night
{% endif %}
##########################################################################################
# Inputs
##########################################################################################
input_select:
theme:
name: 'Select Theme'
icon: mdi:palette
options:
- 'clear'
- 'darkblue'
- 'darkcyan'
- 'darkorange'
- 'darkred'
- 'default'
- 'done'
- 'matrix'
- 'midnight'
- 'minimal'
- 'PmxMononight'
- 'stormy_hues'
- 'teal'
- 'vintage'
# initial: 'teal'
set_sunset_theme:
name: 'Select Sunset theme'
icon: mdi:weather-night
options:
- 'clear'
- 'darkblue'
- 'darkcyan'
- 'darkorange'
- 'darkred'
- 'default'
- 'done'
- 'matrix'
- 'midnight'
- 'minimal'
- 'PmxMononight'
- 'stormy_hues'
- 'teal'
- 'vintage'
# initial: 'darkblue'
set_sunrise_theme:
name: 'Select Sunrise theme'
icon: mdi:weather-sunny
options:
- 'clear'
- 'darkblue'
- 'darkcyan'
- 'darkorange'
- 'darkred'
- 'default'
- 'done'
- 'matrix'
- 'midnight'
- 'minimal'
- 'PmxMononight'
- 'stormy_hues'
- 'teal'
- 'vintage'
# initial: 'darkblue'
##########################################################################################
# Automations
##########################################################################################
automation:
- alias: 'Change Current Theme'
id: 'Change Current Theme'
initial_state: 'on'
trigger:
platform: state
entity_id: input_select.theme
action:
service: frontend.set_theme
data_template:
name: >
{{states('input_select.theme')}}
- alias: 'Sun based theme change'
id: 'Sun based theme change'
initial_state: 'on'
trigger:
- platform: homeassistant
event: start
# - platform: state
# entity_id: input_select.set_sunset_theme
# - platform: state
# entity_id: input_select.set_sunrise_theme
- platform: state
entity_id: sensor.sun_based_theme
# - platform: sun
# event: sunrise
# - platform: sun
# event: sunset
# - platform: state
# entity_id: sun.sun
# to: above_horizon
# - platform: state
# entity_id: sun.sun
# to: below_horizon
condition: []
action:
# - delay:
# seconds: 3
- service_template: frontend.set_theme
data_template:
name: >
{{ states('sensor.sun_based_theme') }}
# {% if trigger.platform == 'sun' %}
# {{states('input_select.set_sunset_theme') if trigger.event == 'sunset' else
# states('input_select.set_sunrise_theme') }}
# {% else %}
# {{ states('sensor.sun_based_theme') }}
# {% endif %}
- condition: template
value_template: >
{{ is_state('input_boolean.notify_system', 'on')}}
- service: notify.system
data_template:
title: >
Ha Main: Sun set Theme
message: >
{{ as_timestamp(now()) | timestamp_custom("%X") }}:
Sun is {{states('sun.sun')}} and Frontend is set to '{{ states('sensor.sun_based_theme') }}'
I like your setup and might borrow some of it’s flexibility! But I’m still not sure this solves my problem.
I currently use this simple automation:
automation:
- alias: Set Theme
hide_entity: true
initial_state: true
trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: sun.sun
to: above_horizon
- platform: state
entity_id: sun.sun
to: below_horizon
action:
service: frontend.set_theme
data_template:
name: >
{% if states('sun.sun') == "above_horizon" %}
day
{% else %}
night
{% endif %}
But it seems to me that service: frontend.set_theme
only works if the theme is set to backend-selected
which I can’t get to on my mobile!
Do you mean that’s what would be expected, or did you in fact experience this? I seem to recall that by using these automation the selection is set to backend…But as said, I havent checked in a long time, so not really sure.
On my mobile I cannot set my theme to backend-selected
.
This means that calling the service will not change the theme when the automation runs.
Which actually raises a question. In the HA menu you set the theme on a per-user basis but this does not seem to get applied to all devices logged on as the same user.
Unless of course this is a cacheing issue, but then how do you force a full reload on a mobile device using Chrome when the webpage (in this case HA) has been saved as an ‘app’?
Im not sure if that’s true, at least, Ive never experienced that. For what I see, the theme is applied to the instance, not to the device it is displayed on. Even more, I have 3 users configured, and on all of these, the theme is automation theme does its job… Maybe it shouldn’t be on the user page after all, it was on the general strings page before.
Unless this is all based on the fact I havent ever set a user based theme, and the system simply hasn’t recorded any personal settings related to theme, and is still listening to the automation, as it has always done…
maybe ask one of the dev’s or architects on this subject, and while you have their attention, throw in the issue of the backend select not being visible at all times.
how do you even do that? I tried it just now, but only see the option of creating a bookmark, not save on desktop or something like that…
Top right three dot menu in Chrome, ‘Add to Home Screen’.
(This is on an Android phone)
Gives a shortcut on the Home screen that acts a bit like an app. i.e. it is really Chrome displaying the webpage but with no menus or address bars or any other screen ‘furniture’.
I’ve only used Discourse a few times to ask a question and never had a response. Which is fine if no one wants to reply or knows the answer but the problem with it is that the question then gets lost.
I prefer this forum…
Unless you can tell me I’m using Discourse wrongly. (Which I wouldn’t be surprised about as a lot of people love it!)
well, its not there on iOs… now the procedure, but nit with Chrome unfortunately…
only been on Discourse once, so wouldn’t be a fair judge. With you on this forum, and the history of posts we can revisit. Like this one
Even so, this doesn’t seem to bother people, though a nasty little bugger it is.
I’ve just discovered that if you go to the three dots menu then tick the desktop site box you can "reach"up to choose backend-selected. Hope this helps
After months of not understanding why I couldn’t find the “backend-selected” option on a particular device I decided to check the forums and since I’m not alone, here’s my experience…
The device had a manually selected theme, and the option for “backend-selected” was missing. Logging in on another device with the same user, it defaulted to “backend-selected” there, but on the problem device it remained the same (Service: frontend.set_theme had no effect - the theme could only be manually set)
Conclusion: the Theme setting from the User menu is cached with the logon session
Solution: Log out on device and then log back in.
bumping this as its still a problem.
using latest HA core. and latest ha official app.
Cant select backend-selected on mobile.
doesnt work unfortunately.
Logging out from User Profile should correct this. In the mobile app, you could also try clearing the app’s cache from Android’s App management.
Just tried that, it did change it back to backend selected. however, it didnt actually change to the right theme, I have the automatons where I can change the theme from a view and it will change on all my devices, which works, except for the mobile. Even with it on backend selected it was actually the default theme instead of the custom ones my other devices have. also, it wasn’t in the list anymore, so when i changed it again, its gone again.,
Good to hear it did work. Your issue would seem to be a separate matter, possibly related to the mobile app and/or automation specifically.
It didnt work though.
Its the same issue. Its been this way for months. It ueed to wprk fine. And thr automation works fine on every other browser.
Thing is. Some of us cannot select the backend-select theme option anymore. It used to sometimes work. Now. It just wont show up. Whoch i think started around the timr we got dark and light theme options.
Something changed and it wasnt on my end.
it is required to shrink the browser window several times, e.g. with “ctrl and -” so that the “Backend-selecte” theme appears, which allows you to change the theme using the “frontend.set_theme” service and in the mobile application I don’t know how to do it
But you did open an issue and now it will be on the list of things to be fixed.
Which you should have done three years ago @Mariusthvdb I’m surprised it has gone unreported for this long.
haha yes
tbh, I’ve never looked at that again, because my themes are working as expected, and use the backend select.
do have a (probably) related issue though: input_select dropdown wont show completely or scroll down · Issue #9416 · home-assistant/frontend · GitHub