Hi, i need help with the sunlight_opacity sensor for my floor plan. Could someone post a working sensor template?
thanks in advance
Hi, i need help with the sunlight_opacity sensor for my floor plan. Could someone post a working sensor template?
thanks in advance
found it myself. If someone need it…
sunlight_opacity:
value_template: >-
{%- set sunpct = states('sensor.sunlight_pct') | float %}
{%- set opacity = sunpct / 100 | float %}
{{ opacity }}
and
- platform: template
sensors:
sunlight_pct:
entity_id:
- sun.sun
- sensor.openweathermap_cloud_coverage
value_template: >-
{%- set elevation = state_attr('sun.sun','elevation') | float %}
{%- set cloud_coverage = states('sensor.openweathermap_cloud_coverage') | float %}
{%- set cloud_factor = (1 - (0.75 * ( cloud_coverage / 100) ** 3 )) %}
{%- set min_elevation = -6 %}
{%- set max_elevation = 60 %}
{%- set adjusted_elevation = elevation - min_elevation %}
{%- set adjusted_elevation = [adjusted_elevation,0] | max %}
{%- set adjusted_elevation = [adjusted_elevation,max_elevation - min_elevation] | min %}
{%- set adjusted_elevation = adjusted_elevation / (max_elevation - min_elevation) %}
{%- set adjusted_elevation = adjusted_elevation %}
{%- set adjusted_elevation = adjusted_elevation * 100 %}
{%- set brightness = adjusted_elevation * cloud_factor %}
{{ brightness | round }}
unit_of_measurement: '%'
device_class: 'illuminance'