Hey guys,
can anyone help me and tell me why the string is deprecated ?
entity’s are correct.
The part sun.sun & sensor.openweather
entity_id:
- sun.sun
- sensor.openweathermap_cloud_coverage
Full code
- 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'
The entity_id option for template sensors has been deprecated a few releases ago. remove the complete entity_id section.
See the breaking change for templates here .
Thank you for replying!
Thats what I thought. But if I remove the enity the sensor doesn’t work anymore and becomes unavailable.
@Burningstone
petro
(Petro)
January 18, 2021, 7:18pm
4
post your config after you remove the entity_id section.
if you have sensor.time configured you can add the following at the top of the value template to get it evaluated every minute:
{% set x = states('sensor.time') %}
petro
(Petro)
January 18, 2021, 7:20pm
6
If you look at his template, it should work identical to removing the entity_id field. I believe he’s deleting too much.
- platform: template
sensors:
sunlight_pct:
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'
to much you think ?
@petro @Burningstone
petro
(Petro)
January 18, 2021, 7:25pm
8
No it looks fine. Are you reloading the template after you make the change?
full reboot of the system. will try again. and post the log maybe it shows more information.
petro
(Petro)
January 18, 2021, 7:28pm
10
just reload the templates, no need to restart
@Burningstone @petro
Apparentley i am a dumbass and i did remove to much the first time whitouwd knowing because it works now. Thank you for the help guys !
Realy apriciate it !