Is there a way to colour an SVG part based on a state?
I have the following custom field which creates a hue bulb. At the moment the base (bulb) is a set colour of #C0C0C0 and the light is filled with “var(–button-card-light-color)” which for Hue bulbs works fine as the light part displays the light of the bulb nicely and it goes grey when off.
custom_fields:
icon_hue: >
<svg viewBox="0 0 32 32"><path id="Bulb" d="M16,11.999c1.523,0 3.746,-0.143
5.539,-0.553c-1.358,4.219 -1.591,8.078 -1.545,9.176c0.011,0.255 -0.076,0.496
-0.242,0.689l-0.441,0.504c-0.952,0.113 -2.055,0.184 -3.311,0.184c-1.256,0
-2.359,-0.071 -3.311,-0.184l-0.441,-0.504c-0.166,-0.193 -0.253,-0.434
-0.242,-0.689c0.046,-1.098 -0.187,-4.957 -1.545,-9.176c1.793,0.41
4.016,0.553 5.539,0.553Zm-2.998,10.862c1.042,0.101 2.188,0.138
3.002,0.138c0.814,0 1.96,-0.037 3.002,-0.138l-0.501,3.108c-0.026,0.218
-0.132,0.42 -0.3,0.573l-0.467,0.424c-0.032,0.029 -0.061,0.06
-0.089,0.092l-0.493,0.583c-0.19,0.226 -0.48,0.358
-0.787,0.358l-0.365,0l-0.365,0c-0.307,0 -0.596,-0.132
-0.786,-0.358l-0.495,-0.583c-0.027,-0.032 -0.056,-0.063
-0.087,-0.092l-0.467,-0.424c-0.168,-0.153 -0.275,-0.355
-0.301,-0.573l-0.501,-3.108Z" style="fill:#C0C0C0;"/><path id="Light"
d="M22.304,5.398c1.525,1.402 0.137,3.985 -0.329,4.907c-1.257,0.366
-3.269,0.695 -5.975,0.695c-2.706,0 -4.717,-0.329 -5.974,-0.695c-0.466,-0.922
-1.855,-3.505 -0.329,-4.907c1.631,-1.499 6.028,-1.396 6.303,-1.396c0.276,0
4.672,-0.103 6.304,1.396Z"
style="fill:var(--button-card-light-color)"/></svg>
However when the light is off i would also like the bulb part to be dimmer as #C0C0C0 is quite bright. I have tried the following but with no success:
state:
- styles:
custom_fields:
icon_hue:
- fill: red
state:
- color: var(--disabled-text-color)
label:
- color: var(--disabled-text-color)
value: 'off'
Normally the bulb is a sudo element and is access via the .bulb entity within CSS and fill being the value but in the button card its handled differently.
Any ideas how to achieve this?
–
Side note, after setting this up i have noticed that Hue bulbs go grey when off however zigbee bulbs dont and stay the last colour/temp they where at. Not sure exactly why this happens.
Edit: above comment, just noticed --button-card-light-color-no-temperature value can be used however this sets it to the icon active colour from the theme. Anyway to override this value without changing the theme?