Open and7ey opened 8 months ago
Hey there @home-assistant/frontend, mind taking a look at this issue as it has been labeled with an integration (frontend
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
frontend documentation frontend source (message by IssueLinks)
The set_theme
service set the defined theme for the selected mode. It doesn't force the mode of the theme to your current device. Only the device controls which mode is used according to your profile settings.
@piitaya thanks for prompt answer.
It is not quite clear how it works then. If it changes the theme for the selected mode, then why mode
parameter is optional? If you mean "for selected in user interface mode", then what is the purpose of mode
parameter?
The main question is how to change the mode based on the time. I've given links where some solutions are given, but it doesn't work with 2023.12.3.
By settings auto, the mode will follow your device mode (that can be based on time most of the time). There is no way to force the mode using service because services are handled by the back-end and mode is a front-end settings that depends on the device. Does the auto mode works for you?
You can continue the discussion in the community forum. GitHub is for tracking issues. I will look to update the screenshot in the documentation.
The auto
mode doesn't work in my case. It is not clear when new mode is applied - HA is always opened in my browser and when Firefox mode is changed to dark, HA interface is not changed. Does it require page refresh?
it's not a new issue, it is not working for a long time (since theme selection is possible from profile).....
set_theme
service do nothing in context of mode.
Neither if you specify any mode, nor, if you specify name: Home Assistant
, nor if you use name: default
, nor name: none
....
The profile settings always overwrite the global settings and It uses your profile settings: auto/light/dark as @piitaya showed on the screenshot. 'Auto' usually a static state which "follows" your device, which most of the times is static. :)
'Auto' is based on the theme of the OS/browser. It can be automatically changed on mobile devices (I really hate this feature so it is turned off and the theme is static on mobile too), but it is really rare to changing theme of the browser on time base on a PC... - In this context 'auto' is meaning and useless (and unnecessarily overwrites the global theme mode of HA.
-> so as of now, there is no possibility to change the mode by service as it is documented. Which is definitely a bug
I read some discussions about first selecting the "Backend-selected" option from the themes drop-down on the HA profile page. When this is done, frontend.set_theme service should work properly.
My problem is that there is no "Backend-selected" option available on my PC or mobile... even after deleting cache, logging off/on, OR trying different browser, I still only have my themes loaded and a default one. Nothing else. Therefore frontend.set_theme service cannot be used. Did anyone have a similar issue?
"backend-selected" is old terminology. I believe that was renamed to "Use default theme".
So that top option there is the one that is supposed to use the one set by frontend.set_theme.
Yes, in my case only default theme is available, so the dropdown is grayed out. that's why it is curious the service with the mode parameter is not working...
Got it, I must have missed it. I switched to "Use default theme" and I am now able to run different themes using my automation. Thanks @karwosts!
so let me confirm, the mode parameter is still not working for the default theme, as the ticket is about.
@cociweb It is not. I can confirm that. I wanted to double check it also on my side, but I first needed to unblock myself using the "Use default theme". The only way how I got my scenario working, was to create two separate themes.
The service does not do what you think it does.
You cannot change the light/dark mode with this service.
Calling set_theme with mode: dark
means that it changes what theme is displayed when the browser is in a dark mode.
There is no service that can change a browser's mode from light to dark or vice versa.
Um, yes. that is the current (incorrect) working method. And also a partly wrong theory:
Calling set_theme with mode: dark means that it changes what theme is displayed when the browser is in a dark mode.
It is not a conditional service call: it always changes between themes not required for the device to be in dark mode, since if a theme does not supports dark mode it will shows the light. - it covers what you (and the doc) says, but it has no real usecase since profile setting can overrule.
In the past (until the selector was not implemented in the profile) not this way was the intended. Furthermore, the documentation is not super clear for the argued working methods. We can see clues that the theme selector based on the profile is a 'newly' inserted feature into the docs too:
'The backend theme settings will be saved and restored on a restart of Home Assistant.'
Currently it is also not satisfied because:
' This (theme from user profile page) will overrule the theme settings set by the above service calls, and will only be applied to the current device.'
Anyways, the service is not intended to change the browser mode. (It is not requested) the service is intended to change the dark/light mode of the theme, since HA theme change is intended, not the skin of the browser...
What is only happening here that the user profile (mistakenly) overrules it: To resolve this buggy behavior I recommend: there should be a 4th option: 'backend selected' or something like this beside the auto. (and also 'auto' is better to be renamed as browser/device selected)
Calling set_theme with
mode: dark
means that it changes what theme is displayed when the browser is in a dark mode.
Looks like it works only when the HA page is reloaded. If I loaded the page, then browser changes to the dark mode, the page is not refreshed automatically and remains light.
To resolve this buggy behavior I recommend: there should be a 4th option: 'backend selected' or something like this beside the auto. (and also 'auto' is better to be renamed as browser/device selected)
I agree I think that would be a nice thing if it existed.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
bump
Every response from the developers on this topic was something like, "It's not supposed to work this way." and then goes on to describe a use case (for the current bugged behavior) that makes no sense while trying to convince everyone that no one really wants to be able to switch the default mode from auto to light or dark. 😄
The problem
should change current (=default) theme mode to dark, but it doesn't work - nothing happens (it doesn't work neither with
mode: light
)What version of Home Assistant Core has the issue?
core-2023.12.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
No response
Link to integration documentation on our website
https://www.home-assistant.io/integrations/frontend/#defining-themes
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
https://community.home-assistant.io/t/change-dark-light-mode-of-default-theme-based-on-automation/516181/2 https://community.home-assistant.io/t/day-night-theme-switching-automation/24887/17 https://community.home-assistant.io/t/set-default-light-dark-lovelace-theme/412486