HI trying to shorten this, but I can’t get the extension to concatenate after the number… what am i missing?
@petro could you please help me, in creating a mapper here? it’s somewhat different from the mappers with a fixed state, maybe not possible at all? If not, there must be a more intelligent way of doing this…
{% set degrees = states('sensor.br_wind_direction_azimuth')|float %}
{% set path = '/local/weather/wind_compass/' %}
{% set ext = '.png' %}
{{path-}}
{% if degrees <= 5.62 %}0
{% elif degrees <= 16.87 %}11
{% elif degrees <= 28.12 %}22
{% elif degrees <= 39.37 %}33
{% elif degrees <= 50.62 %}45
{% elif degrees <= 61.87 %}56
{% elif degrees <= 73.12 %}67
{% elif degrees <= 84.37 %}78
{% elif degrees <= 95.62 %}90
{% elif degrees <= 106.87 %}101
{% elif degrees <= 118.12 %}112
{% elif degrees <= 129.37 %}123
{% elif degrees <= 140.62 %}135
{% elif degrees <= 151.87 %}146
{% elif degrees <= 163.12 %}157
{% elif degrees <= 174.37 %}168
{% elif degrees <= 185.62 %}180
{% elif degrees <= 196.87 %}191
{% elif degrees <= 208.12 %}202
{% elif degrees <= 219.37 %}213
{% elif degrees <= 230.62 %}225
{% elif degrees <= 241.87 %}236
{% elif degrees <= 253.12 %}247
{% elif degrees <= 264.37 %}258
{% elif degrees <= 275.62 %}270
{% elif degrees <= 286.87 %}281
{% elif degrees <= 298.12 %}292
{% elif degrees <= 309.37 %}303
{% elif degrees <= 320.62 %}315
{% elif degrees <= 331.87 %}326
{% elif degrees <= 343.12 -%}337
{% elif degrees <= 354.37 %}348
{%- endif -%}
{{-ext-}}
this is what i do in other situations, both techniques work:
{% set state = states('sensor.rsd_current') %}
{% set weather = mapper[state] if state in mapper else 'weather' %}
{% set path = '/local/weather/animated/' %}
{% set ext = '.svg'%}
{{[path,weather,ext]|join('')|lower}}
{% set state = states('sensor.rsd_current') %}
{% if state in mapper %}
{{ '/local/weather/animated/{}.svg'.format(mapper[state]) }}
{%else%} '/local/weather/animated/weather.svg'
{%endif%}
this might do it:
entity_picture_template: >
{% set degrees = states('sensor.br_wind_direction_azimuth')|float %}
{% set path = '/local/weather/wind_compass/' %}
{% set ext = '.png' %}
{{path-}}
{%- if degrees <= 5.62 -%} 0
{%- elif degrees <= 16.87 -%} 11
{%- elif degrees <= 28.12 -%} 22
{%- elif degrees <= 39.37 -%} 33
{%- elif degrees <= 50.62 -%} 45
{%- elif degrees <= 61.87 -%} 56
{%- elif degrees <= 73.12 -%} 67
{%- elif degrees <= 84.37 -%} 78
{%- elif degrees <= 95.62 -%} 90
{%- elif degrees <= 106.87 -%} 101
{%- elif degrees <= 118.12 -%} 112
{%- elif degrees <= 129.37 -%} 123
{%- elif degrees <= 140.62 -%} 135
{%- elif degrees <= 151.87 -%} 146
{%- elif degrees <= 163.12 -%} 157
{%- elif degrees <= 174.37 -%} 168
{%- elif degrees <= 185.62 -%} 180
{%- elif degrees <= 196.87 -%} 191
{%- elif degrees <= 208.12 -%} 202
{%- elif degrees <= 219.37 -%} 213
{%- elif degrees <= 230.62 -%} 225
{%- elif degrees <= 241.87 -%} 236
{%- elif degrees <= 253.12 -%} 247
{%- elif degrees <= 264.37 -%} 258
{%- elif degrees <= 275.62 -%} 270
{%- elif degrees <= 286.87 -%} 281
{%- elif degrees <= 298.12 -%} 292
{%- elif degrees <= 309.37 -%} 303
{%- elif degrees <= 320.62 -%} 315
{%- elif degrees <= 331.87 -%} 326
{%- elif degrees <= 343.12 -%} 337
{%- elif degrees <= 354.37 -%} 348
{%- endif -%}
{{-ext-}}
but it is still a bit heavy on the elif’s…