trying to refine my templates Im stuck with the way the component calculates lx from light_level, please have a look with me. This is the official Philips Hue table:
Philips Hue definition Lux MeasuredValue
Overcast moonless night sky 0.0001 0 dark.....
Outdoor: Bright moonlight 1 1
Home: Night light 2 3000
Home: Dimmed light 10 10000
Home: ‘Cosy’ living room 50 17000
Home: ‘Normal’ non-task light 150 22000
Home: Working / reading 350 25500
Home: Inside daylight 700 28500
Home: Maximum to avoid glare 2000 33000
Outdoor: Clear daylight > 10000 > 40000
Outdoor: direct sunlight 120000 51000
However, since the CC uses lx = round(float(10 ** ((lightlevel - 1) / 10000)), 2)
there is no way I am ever going to get a lx value <1. Meaning, even when pitch dark 0 is measured for light_level, it will always be lx 1, which is 1 step up in the table…
Ideally Im am trying to reach a template for lx like the one I use for light_level (translated Overcast moonless night sky to dark for convenience sake):
friendly_name_template: >
Attic:
{% set light_level = states('sensor.attic_motion_sensor_light_level')|int %}
{% if light_level == 0 %} dark
{% elif light_level <=1 %} bright moonlight
{% elif light_level <=3000 %} night light
{% elif light_level <= 10000 %} dimmed light
{% elif light_level <= 17000 %} 'cosy' living room
{% elif light_level <= 22000 %} 'normal' non-task light
{% elif light_level <= 25500 %} working / reading
{% elif light_level <= 28500 %} inside daylight
{% elif light_level <= 33000 %} maximum to avoid glare
{% elif light_level <= 40000 %} clear daylight
{% elif light_level <= 51000 %} direct sunlight
{% else %} too bright!
{% endif %}
I can’t however build the same template for lx, have a look:
friendly_name_template: >
Attic:
{% set lux = states('sensor.attic_motion_sensor_lux')|int %}
{% if lux <=1 %} moonlight
{% elif lux <=2 %} night light
{% elif lux <= 10 %} dimmed light
{% elif lux <= 50 %} 'cosy' living room
{% elif lux <= 150 %} 'normal' non-task light
{% elif lux <= 350 %} working / reading
{% elif lux <= 700 %} inside daylight
{% elif lux <= 2000 %} maximum to avoid glare
{% elif lux <= 10000 %} clear daylight
{% elif lux <= 120000 %} direct sunlight
{% else %} too bright!
{% endif %}
adding a first line to this template {% if lux <1 %} dark
is useless, for it will never be <1… Mind you, this isn’t a silly detail, we can distinguish dark from moonlight with our eyes, and so does the hue sensor. Making it a float in the template doesn’t help, because of the way the rounding is done in the component…
might be able to do something with a template based in the light_level attribute, but feel this should really be refined in the component for lx value calculating. @robmarkcole @yottatsa what could we do to realize that?
thanks!