[JS+Editor Module] Conditional background color (deprecated) #1636
Replies: 16 comments 69 replies
-
“Hi, great job, you’ve made my life a bit easier. Would you also be able to create something similar for the background color of the icon container? I like the possibility of choosing the opacity with a slider.” |
Beta Was this translation helpful? Give feedback.
-
Hi, great work, I do however seem to have an issue that the conditional colour does not seem to 'clear' once the condition is no longer met. I'm using it to colour the card based on an occupancy sensor, when movement is detected, it changes colour, but it doesn't revert to it's normal colour once the detected is no longer present. |
Beta Was this translation helpful? Give feedback.
-
Updated to v1.1
Disclaimer: Leaving out the conditions will evaluate to |
Beta Was this translation helpful? Give feedback.
-
Could we have support for hex colors? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Updated to v1.2
Disclaimer: Be aware that this update changes the schema so you'll have to update your YAML accordingly. The main post has an example you can use as orientation or otherwise the UI 👍 |
Beta Was this translation helpful? Give feedback.
-
Looking at the different compatibility issues with the different card types, maybe it's better to split different types into different modules? That way I could add options specific to card types (like coloring the slider and background part of a slider button) which is now very difficult. Any opinions on that? @Clooos sorry for pinging you but how does the module store exactly? Considering I might want to discontinue this module in favor or card-specific modules what's the best way to do that? I see that I can close this discussion as outdated but does that affect the module store search? |
Beta Was this translation helpful? Give feedback.
-
I have two shutters,one is a smart one and it correctly results as 100% open, in this case the color override is fine. The other isnt smart, it doesnt report its current %, therefore the state is unknown. In this case the background color override is wrongly applied to the icon too |
Beta Was this translation helpful? Give feedback.
-
Hi, nice work! Is it possible to add my own theme color in here, or a gradiant color? |
Beta Was this translation helpful? Give feedback.
-
Thanks for this module, easy to use and engancing a lot the bubble cards. |
Beta Was this translation helpful? Give feedback.
-
Still having issues with default color. |
Beta Was this translation helpful? Give feedback.
-
It seems the GUI for specifying conditions is not the same as the one used in automations for example. |
Beta Was this translation helpful? Give feedback.
-
This is great. Any way you can add in the option to change the icon colour as well? I usually like to change both the card background and icon colour while leaving the icon background default. |
Beta Was this translation helpful? Give feedback.
-
If I want to use the lights color, what I just use: var(--color) it didn’t seem to work, or is the format not correct? I have CSS variable mode selected |
Beta Was this translation helpful? Give feedback.
-
Hi, I can't seem to get negative ("not") conditions to work at all with this module. Normal conditions work fine, but no conditional colors are ever applied to the card when I negate a condition like this:
|
Beta Was this translation helpful? Give feedback.
-
I know you deprecated this, but I didn't see one you made for a switch button. I was able to get this to work for that using the conditions, as default didn't work. Is there one for a switch? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Conditional background color
Version: v1.2
Creator: andarotajo
Warning
I've decided to split this module into multiple ones that are dedicated to each card type, so I'll not provide any updates for this one. This discussion will probably be closed after I've put out some of the individual modules. Thank you for all the testing and feedback so far, it will come in very handy with the new modules :) Links to the new individual modules:
Important
Supported cards:
Unsupported cards:
This module allows you to change the background color (and optionally opacity) of a card and/or icon based on one or more conditions. Generally, it has the following features:
Conditions:
Conditions are configurable via the default selector of Home Assistant, allowing for the conditions you're already used to. The configurable default background colors and opacities for the card and icon are applied when no conditions match or if an element could not be modified due to an error or invalid configuration.
It's possible to set up multiple color/condition pairs by copying the "conditional_background_1" block and incrementing the number. Though the name doesn't have to end with a number since the code looks for "conditional_background_", it is recommended to do so for clarity.
Disclaimer:
This is my first module so I'm happy to receive feedback on the code etc. I couldn't test it for climate/cover too much as I don't have those entities but they should work from what I've seen. If not, I'll update it to mark them unsupported.
Configure this module via the editor or in YAML, for example:
🧩 Get this Module
Screenshot:
Before posting your module
unsupported
propertyyour_module_key
Beta Was this translation helpful? Give feedback.
All reactions