When the light is off, does the state object have a brightness attribute? The likely answer is no. So you need to handle that case where the attribute dictionary is empty.
I’m confused, that would appear as a string ‘${attributes.brightness}’, not as the value inside attributes.brightness if that was inside a normal .yaml config. What component are you using this with?
Typical code inside yaml looks like this when attempting to extract info:
Well, I’m not sure. I’m not getting much info out of you. This is how it could work, assuming it doesn’t require ${} around your custom ui (FYI this is typically dictated by a .js or .html file, but configured in your yaml).
What it would look like if you are inside your yaml and it accepts value_templates:
I am not sure if they only show when available on your light (no color settings on non-colored lights) . I have many different lights, ambiance white, white only, ambiance color and white, Philips Hue and Ikea Tradfri, and none error out on the example i gave you, which i use for all my lights. Depending on your demands, set or comment out individual lines. this should work.
Unless, maybe your syntax is incorrect?
Cheers,
Marius
thanks, but I was referring to which attributes are availiable from a light, e.g. colour, temp etc
im pretty sure my syntax is correct. So I must be missing something else.
Im currently using with M-Light via the Limitless LED component.
I can call the light.turn on service with dev tools and specify the color_name and it works, but does not give me a badge in the Custom UI card…ill have a play and double check my .yaml