adding to the above template sensor, one could also use this template sensor in the Lovelace frontend:
{% set direction = states('sensor.br_wind_direction') %}
{% set gust = states('sensor.br_wind_force') %}
{% set ext = '.png' %}
{% set path = '/local/weather/compass/' %}
{% if gust <= '10' %} {% set color = '-blu' %}
{% elif gust <= '20' %} {% set color = '-grn' %}
{% elif gust <= '30' %} {% set color = '-yel' %}
{% else %} {% set color = '-red' %}
{% endif %}
{{[path,direction,color,ext]|join('')}}
given my test sensors, this is a completely wrong outcome, but I wanted to keep Tom’s calculations for this example, and I don t have the Bom sensors to try. (we use different windspeed units…)
guess this would be more appropriate for BR windspeed:
{% set direction = states('sensor.br_wind_direction') %}
{% set speed = states('sensor.br_wind_speed') %}
{% set path = '/local/weather/compass/' %}
{% set ext = '.png' %}
{% if speed <= '11' %} {% set color = '-blu' %}
{% elif speed <= '39' %} {% set color = '-grn' %}
{% elif speed <= '75' %} {% set color = '-yel' %}
{% else %} {% set color = '-red' %}
{% endif %}
{{[path,direction,color,ext]|join('')}}
using:
- type: custom:button-card
show_entity_picture: yes
name: >
[[[return states['sensor.br_wind_direction'].state + ' - ' + states['sensor.br_wind_force'].state]]]
entity_picture: >
[[[return states['sensor.colored_wind_compass'].state ]]]
styles:
name:
- color: >
[[[ var speed = states['sensor.br_wind_speed'].state;
if (speed <= 11) return 'blue';
if (speed <= 39) return 'green';
if (speed <= 75) return 'yellow';
return 'red'; ]]]
Tom, when does Calm kick in in your template, given the fact that you start the color selection with <=10, wouldn’t that exclude any other picture than the direction pictures?