I’m trying to use the Live Sensor Report Example Automation provided in the Alexa Media Player github wiki.
What I have
The math should use the ‘brightness’ attribute from a light.alexa_virtual and convert it in to a percent integer.
{{ state_attr('light.alexa_virtual', 'brightness') | int / 255 * 100 | int }}
The above is the math part of the conditional:
{% if (state_attr('light.alexa_virtual', 'brightness') | int / 255 * 100 ) | int == 1 %}
Note
Note: the given example uses states.light.alexa_virtual.attributes.brightness
but I changed it to state_attr('light.alexa_virtual', 'brightness')
.
The math
If state_attr('light.alexa_virtual', 'brightness')
= 26
then the result should be 10 right?
{{ state_attr('light.alexa_virtual', 'brightness') | int / 255 * 100 | int }}
{{ 26 | int / 255 * 100 | int }}
The result should be 10 but when I put it in the Developer Tools > Template editor it shows 10.196078431372548.
What I’ve tried
I’ve tried using round
{{ 26 | int / 255 * 100 | round | int }}
but that didn’t change anything.
What am I doing wrong?