custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.93k stars 233 forks source link

helpers.localize for brightness, does not return the actual brightness in % #766

Open andyblac opened 1 year ago

andyblac commented 1 year ago

Checklist

Describe the bug when using "[[[ return helpers.localize(states[entity], states[entity].attributes?.brightness); ]]]" it just returns the value of the brightness attribute ie 8, I would of expected it to return the actual brightness with the measurement type. ie 3%, to get the required result atm I have to use.

label: >
        [[
          let bri = Math.round(helpers.localize(states[entity], states[entity].attributes?.brightness) / 2.55);
          return (bri ? bri : "0") + "%";
        ]]

Version of the card Version: 4.1.1

To Reproduce This is the configuration I used:

label = "[[[ return helpers.localize(states[entity], states[entity].attributes?.brightness); ]]]"

Expected behavior I would of expected it to return the actual brightness with the measurement type. ie 3%

RomRider commented 1 year ago

It doesn't work like that unfortunately, that works only for "text" attributes or numeric main state of an entity. helpers.localize has no effect here, you should directly access the brightness attribute.

andyblac commented 1 year ago

the issue is the attribute does not hold the % value, but OK i'll keep using Math