There seem to be theme variables for zones by name now (and also other sensors, like for example all the various states of my lawn mower robot).
for example I have a zone called “Arbeit”, and the variable is --state-person-arbeit-color
(lowercase, although my zone name starts with an uppercase letter)
I am using the following script (theme-override.js
placed in the /config/www
folder) to inject additional variables into an existing theme:
let myColors = [
['--state-inactive-color', '#22394f'],
['--state-person-home-color', '#408000'],
['--state-person-arbeit-color', '#0066cc'],
['--state-vacuum-mowing-color', '#33aa33'],
['--state-vacuum-error-color', 'var(--red-color)'],
['--state-vacuum-edgecut-color', 'var(--state-active-color)'],
['--state-vacuum-returning-color', 'var(--state-active-color)']
];
for (let [key, val] of myColors) {
document.documentElement.style.setProperty(key, val);
}
In configiration.yaml
I have this to activate the above javascript:
frontend:
extra_module_url:
- /local/theme-override.js
(the /local
folder is aliased to the /config/www
folder, so any javascript file placed in /config/www/something.js
must be referenced as /local/something.js
in the extra_module_url
)
I am using this hack instead of creating a new theme to be able to just continue using the built-in theme and only change a few variables. The above script will be injected after the theme has been loaded, so it will override any variables in the existing theme.
To activate it or test any color changes, just clear the cache and reload (shift+reload) in firefox or clear app cache on android.
PS: If you are wondering why I have a mowing vacuum cleaner: HA knows only about one kind of robot, and these are vacuum robots, so every robot you have in your home is a vacuum, even if it doesn’t suck.