From c5ab958dbfc6730d40e9cb07f7321cdd2adb1252 Mon Sep 17 00:00:00 2001 From: Carlo Costanzo Date: Wed, 11 Jun 2025 14:44:55 -0400 Subject: [PATCH] Enhance UV index reporting by adding weather-related tips and improving sensor data display --- config/templates/speech/briefing.yaml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/config/templates/speech/briefing.yaml b/config/templates/speech/briefing.yaml index 76754c08..f49142de 100755 --- a/config/templates/speech/briefing.yaml +++ b/config/templates/speech/briefing.yaml @@ -162,12 +162,25 @@ {%- endmacro -%} {%- macro uv() -%} - {% if states.sensor.pirateweather_uv_index.state|int(9999)>= 6 and states.sensor.pirateweather_uv_index.state|int(9999)<= 7.9 %} - Today's UV index is {{ states.sensor.pirateweather_uv_index.state }}. You should wear sunscreen if going outside. - {% elif states.sensor.pirateweather_uv_index.state|int(9999)>= 8 and states.sensor.pirateweather_uv_index.state|int(9999)<=10.9 %} - Today's UV index is {{ states.sensor.pirateweather_uv_index.state }}. This is VERY HIGH. Be sure wear sunscreen and re-apply. - {% elif states.sensor.pirateweather_uv_index.state|int(9999)>= 11 %} - Today's UV index is {{ states.sensor.pirateweather_uv_index.state }}. This is EXTREME. You should be very cautious going outside. + {% if states.sensor.pirateweather_uv_index.state|int(9999)>= 6 %} + Today's UV index is {{ states.sensor.pirateweather_uv_index.state }}. + {%- for entity in states.sensor if 'pirateweather' in entity.entity_id %} + {%- set state = entity.state %} + {%- set unit = entity.attributes.unit_of_measurement if 'unit_of_measurement' in entity.attributes else '' %} + {%- set friendly_name = ' '.join(entity.attributes.friendly_name.split(' ')[1:]) %} + {%- if state not in ['0', '0.0', 'none'] and 'UV Index' not in friendly_name %} + {%- if 'Temperature' in friendly_name -%} + {{ friendly_name }}: {{ state }} {{ unit }} + {%- elif 'Minutely' in friendly_name -%} + {{ friendly_name }}: {{ state }} {{ unit }} + {%- elif 'Cloud Coverage' in friendly_name and state | float > 75 -%} + {{ friendly_name }}: {{ state }} {{ unit }} + {%- elif 'Humidity' in friendly_name and (state | float < 50 or state | float > 85) -%} + {{ friendly_name }}: {{ state }} {{ unit }} + {%- endif -%} + {%- endif %} + {% endfor -%} + [Give helpful tip based on the current UV index and weather conditions] {% endif %} {%- endmacro -%}