frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Misleading behaviour of frontend's theme change service

Open cociweb opened this issue 1 year ago • 5 comments

Checklist

  • [X] I have updated to the latest available Home Assistant version.
  • [X] I have cleared the cache of my browser.
  • [X] I have tried a different browser to see if it is related to my browser.
  • [X] I have tried reproducing the issue in safe mode to rule out problems with unsupported custom resources.

Describe the issue you are experiencing

service: frontend.set_theme
data:
  name: default
  mode: dark

should change current (=default) theme mode to dark, but it doesn't work - nothing happens (it doesn't work neither with mode: light)

Unfortunatelly, in the users's (GUI) profile only auto/light/dark modes are available. The light/dark options are a manual option to forcefully override the ha's default mode of default theme settings. In our case the 'auto' is based on the user's browser/OS settings and does not lies on the control of HA-core. (eg service call for automations)

Describe the behavior you expected

I would recommend to (re-)introduce/revert a 4th option, (eg the old "backend selected") where the theme mode is based on the ha-core (service call / automations) and not on the users/browser(/OS) preferences. Please note that the above mentioned service call was worked before the redesigned profile layout (years ago). [off] I don't really know which version, but it was years ago.... I don't think it does matter now...

Steps to reproduce the issue

  1. set the theme to default in the configuration.yaml.
  2. set the theme option to any in the user's profile
  3. set the opposite mode by a frontend.set_theme service call of the default theme as it is used currently. ...

What version of Home Assistant Core has the issue?

2020.01.0?

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

No response

Which operating system are you using to run this browser?

No response

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

This ticket is a frontend related successor of https://github.com/home-assistant/core/issues/106040 Also, there are many topics by the community, eg:

  • https://community.home-assistant.io/t/scripts-to-load-themes-have-stopped-working/520625/3
  • https://community.home-assistant.io/t/frontend-set-theme-with-mode-not-working/518800
  • https://community.home-assistant.io/t/change-dark-light-mode-of-default-theme-based-on-automation/516181
  • https://community.home-assistant.io/t/set-default-light-dark-lovelace-theme/412486

If this is considered as a 'Let's go' implementation, I would also suggest to rename the misleading 'auto' option something like 'browser/os select' option, since the behavior is not clear enough from it's name.

cociweb avatar Jun 03 '24 20:06 cociweb

There is feedback from multiple developers on that thread stating that the purpose of mode in set_theme is not to change the client's light/dark mode setting.

If what you're asking for here is a 4th "backend selected" darkmode, that is a new feature request.

Honestly I don't think that makes that much sense to have it. I could imagine wanting to have dynamic control over light/dark mode (e.g. a wallpanel in a room that could go to darkmode based on a lux sensor in the room), but that's not really scalable as you only have one backend selected mode which is shared by all your clients. If the backend was going to control the mode that would be something I think you'd want on a per-client level, not globally for everyone.

So I couldn't think of a good use case why you'd want to have backend switch light/dark mode that would make me want to suggest adding it.

karwosts avatar Jun 03 '24 21:06 karwosts

Actually, I'm the only one single user on my instance with multiple devices, with multiple usecases on bases of the time's plane... (Basically, the single user will stay until LDAP is not added....) Anyways, the 'backend selected' option should still be a user property but on lower level on the priority line, since the current user settings forcefully override everything according to the current working method.

Actually this is bug report, since it was a working feature in the past (and now it is not working) and furthermore there is an inbuilt service call in the core, which has no effect on this anymore according to it's documentation.

Honestly I don't think that makes that much sense to have it.

Personally.

As you can see on the attached links, not only I am the helicopter it's a very annoying bug for multiple users (so maybe there are other usefull usecases which was not questioned). - Of corse, there are workarounds with browser_mod, or multiple custom templates, but those are not the solutions and requires additional configurations/installations/maintenance. (Especially, I do not use browser_mod, because it makes my installation instable and significantly slow, but that's another user voice with another report....)

cociweb avatar Jun 04 '24 06:06 cociweb

I second this. Being able to change the theme mode (light/dark/auto) is incredibly useful and the fact it has this odd behavior is very misleading. What are next steps? Do we need a feature request or this would be considered a bug?

ncd7 avatar Jun 05 '24 12:06 ncd7

The current behavior also breaks the map-card to auto switch from light to dark, as it now relies on theme mode to be in dark setting. https://github.com/home-assistant/frontend/pull/20606

Means: there is no way to set the map to dark, as "mode" is browser controlled. Everything turns dark, except the map, if you set a dark colored theme. That is, not using modes: dark-yaml to actually force the browser to show something dark.

PulsarFX avatar Aug 06 '24 23:08 PulsarFX

also would love a feature that allows a dynamic change from light to dark mode similar to the current ability to change between themes. Either automatically based on daytime/brightness/... or base on a button press. If there is a action to call similar to setting the theme, then all this would be possible via automations!

regarding

Honestly I don't think that makes that much sense to have it. I could imagine wanting to have dynamic control over light/dark mode (e.g. a wallpanel in a room that could go to darkmode based on a lux sensor in the room), but that's not really scalable as you only have one backend selected mode which is shared by all your clients. If the backend was going to control the mode that would be something I think you'd want on a per-client level, not globally for everyone.

absolutely! there would probably need to be some additional data regarding which user/device to change this for with a default value of all. e.g. when doing time-dependant mode switches I'd want to do this for all users (i.e. day/night), this would apply to all users. But another use case is if you want to make it as easy as possible for users to choose their own mode. My SO always uses light mode, I always use dark mode. Rather than explaining to every family member where to switch this, I'd love to put a button/toggle in my Dashboard that allows for easy switch between the two. Then you can also use this to switch in bright environments on the fly, maybe even with sensor data from your phone.

loocd avatar Aug 19 '24 10:08 loocd

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.

github-actions[bot] avatar Nov 17 '24 12:11 github-actions[bot]

Based on multiple user confirmations, it appears there is still a bug present since the introduction of the 'new' user profile related settings. The responsibility for resolving this issue lies with the developers, whether it's a new feature or not. Make it clear: The current behavior is problematic, which calls for a bugfix for almost 5 years.

cociweb avatar Nov 17 '24 21:11 cociweb

I have the same problem and have been able to recreate it with an absolute basic automation:

alias: Start default theme (Vision OS)
triggers:
 - event: start
 trigger: homeassistant
actions:
 - data:
 name: visionos
 mode: dark
 action: frontend.set_theme

So really simple, it should activate the "visionos" theme in dark mode at every system start. The fact is that dark mode can also be selected wonderfully via the user interface of the automation, but it is completely ignored.

However, I can definitely say that dark mode is supported by this theme, as I can also select it manually in the user profile. Of course, it's the same behavior with the basic Home Assistant theme...

Mickoeck avatar Feb 11 '25 22:02 Mickoeck

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.

github-actions[bot] avatar May 13 '25 00:05 github-actions[bot]

The issue is still not resolved.

cociweb avatar May 13 '25 04:05 cociweb

the problem still persists

JanKraslice avatar Jul 11 '25 21:07 JanKraslice

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.

github-actions[bot] avatar Oct 09 '25 22:10 github-actions[bot]

comment 👍

cociweb avatar Oct 10 '25 02:10 cociweb

Issue still exists

ncd7 avatar Oct 11 '25 15:10 ncd7

I have same problem, and the automated operation is useless, the color mode cannot be set.

hhuangpeiqi avatar Oct 13 '25 02:10 hhuangpeiqi

I agree, there should be the ability to override the dark/light mode through the backend natively based on any condition you choose. I would like to change my theme based on sunset and sunrise for all devices and that is not possible without third party integrations. And to be honest if a user does not want this to happen they can still manually override it in there profile settings by using the currently available Use default theme and selection the current auto, light, or dark modes to their preference. Just because I want home assistant to be in light mode during the day doesnt mean I want my entire device and all its apps to be in light mode too.

Rather then adding back the backend-selected theme option Ithink for themes that have dark/light mode support there should be a 4th radio button options called "Backend" and possilby a 5th option for "Sunset/Sunsrise" in addtion to the current "Auto", "Light", "Dark" options.

Image

Also the "Auto" radio button should also have tool tip text triggered by info Icon click/hover, or static description under it stating it uses the devices native dark/light mode feature for clarity.

Tjstock avatar Oct 21 '25 02:10 Tjstock

I think this PR introduced the bug, which made the action call unusable for the mode attribute: https://github.com/home-assistant/frontend/pull/6430

this pr changed the js cards to ts as well. maybe the Calling set_theme with mode: light/dark option lost somewhere. Interesting thing that "backend-selected" option existed on that time... https://github.com/home-assistant/frontend/blob/2df02f1b09a643b5b625608a000a275a1a25a1bc/src/panels/profile/ha-pick-theme-row.js#L96 @bramkragten I hope you don't mind if I involve you to the conversation.

cociweb avatar Oct 21 '25 10:10 cociweb