button-card icon indicating copy to clipboard operation
button-card copied to clipboard

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

Open andyblac opened this issue 2 years ago • 2 comments

Checklist

  • [yes ] I updated the card to the latest version available
  • [ y] I cleared the cache of my browser

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%

andyblac avatar Sep 04 '23 13:09 andyblac

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.

RomRider avatar Sep 04 '23 15:09 RomRider

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

andyblac avatar Sep 08 '23 11:09 andyblac