when i look at a light entity’s properties for brightness, i get a number between 1-255.
how do i convert that into a percentage for easier display between 1-100?
I made this template to extract the number from the entity’s properties, and if i could divide it by 255 and multiply it by 100 ill get the right percentage, but how do i do that within the code to get it to display the “new” number?
the other way thought about is to create a number helper with 1-100 range, and display it’s properties instead, but how do i tie it to the light entity i wish to extract the brightens level from?
let me better explain the purpose…
I use a matrix led panel to display different values from various sensors, time etc. at night, when i use a dimmer switch-button to dim the lights, i find it to be useful to have some form of a “number” to represent the brightness for better control. as mentioned, now, i have the brightness display as a number between 1-255, and i want it to represent percentages instead.
there must be some easier way i’m overlooking…
let me know
cheers
Although your device is only reporting brightness in the range 0-255, you can actually control it in an automation using brightness_pct which is 0-100. Just something to think about.
correct, but i wanted my matrix to display the brightness regardless of an automation to run it to a specific brightness value.
i use zha button remotes to dim up and down, and your solution works perfect for my needs
hi @Holdestmade
what you quoted was closer to my original attempt not @Rofo suggestion (at list to my understanding, and if i get your question correctly).
as i said, that works but brings out a number between 1-255, and i wanted a 1-100% range result.
at 50% brightness these will be the outputs: {{state_attr('light.changethis’,'brightness')}} = 127.5 {{state_attr('light.changethis’,'brightness_pct')}} = the added _pct = give my a none output {{state_attr(‘light.changethis’,‘brightness’)|float(0)*100//255}} = 50.0 {{state_attr(‘light.changethis’,‘brightness’)|int(1)*100//255}} = 50 (without the decimal point)
and thank again to @Rofo for coming up with the solution i wanted
hope that clarifies it better.