Refactor speech briefing macros for improved clarity and functionality. Updated documentation, enhanced weather reporting with air quality and UV index checks, and streamlined location reporting using a new helper macro. Removed deprecated air quality macro.
# Original Repo: https://github.com/CCOSTAN/Home-AssistantConfig
# Blog Post: https://www.vcloudinfo.com/category/home-assistant
# Follow me on https://www.vcloudinfo.com/click-here
#-------------------------------------------
>-
>-
@ -32,37 +26,53 @@
{%- endmacro -%}
{%- endmacro -%}
{%- macro inside_weather() -%}
{%- macro inside_weather() -%}
Inside the house, it is {{ states.climate.downstairs.attributes['current_temperature'] }} degrees with {{ states('sensor.downstairs_thermostat_humidity') }} percent humidity. [Only mention humidity if it seems unusually high]
{% set temp = state_attr('climate.downstairs', 'current_temperature') | default('unknown') %}
{% set humidity = states('sensor.downstairs_thermostat_humidity') %}
Inside the house, it is {{ temp }} degrees{% if humidity not in ['unknown','unavailable','none'] %} with {{ humidity }} percent humidity{% endif %}. [Only mention humidity if it seems unusually high]
{%- endmacro -%}
{%- endmacro -%}
{% macro outside_weather() %}
{% macro outside_weather() %}
[Here is the current weather outside]
[Here is the current weather outside]
Air Quality:{{state_attr('sensor.bear_stone_common_air_quality_index', 'description')}}
{% set aq_description = state_attr('sensor.bear_stone_common_air_quality_index', 'description') | default('') %}
{%- for entity in states.sensor if 'pirateweather' in entity.entity_id %}
{% set aq_index = states('sensor.bear_stone_common_air_quality_index') | int(0) %}
{%- set state = entity.state %}
{% if aq_description %}
{%- set unit = entity.attributes.unit_of_measurement if 'unit_of_measurement' in entity.attributes else '' %}
Air Quality:{{aq_description }}
{%- set friendly_name = ' '.join(entity.attributes.friendly_name.split(' ')[1:]) %}
{% endif %}
{%- if state not in ['0', '0.0', 'none'] and 'UV Index' not in friendly_name %}
{% if aq_index >= 150 %}
{%- if 'Temperature' in friendly_name -%}
[Air quality is unhealthy; limit outdoor activity]
{%- elif 'Wind Speed' in friendly_name and state | float(0) > 15 -%}
{% for entity in pirateweather_metrics %}
{{friendly_name }}:{{state }} {{ unit }}
{% set value = entity.state %}
{%- elif 'Cloud Coverage' in friendly_name and state | float(0) > 75 -%}
{% set unit = entity.attributes.unit_of_measurement | default('') %}
{{friendly_name }}:{{state }} {{ unit }}
{% set base_name = entity.attributes.friendly_name | default(entity.entity_id) %}
{%- elif 'Humidity' in friendly_name and (state | float(0) < 50 or state | float(0) > 85) -%}
{% set friendly_name = ' '.join(base_name.split(' ')[1:]) or base_name %}
{{friendly_name }}:{{state }} {{ unit }}
{% set numeric = value | float(0) %}
{%- elif 'Nearest Storm Distance' in friendly_name and state | float(0) <= 10 -%}
{% set include = (
{{friendly_name }}:{{state }} {{ unit }}
'Temperature'in friendly_name
{%- endif -%}
or 'Minutely' in friendly_name
{%- endif %}
or 'Precip' in friendly_name
{% endfor -%}
or ('Wind Speed' in friendly_name and numeric > 15)
or ('Cloud Coverage' in friendly_name and numeric > 75)
or ('Humidity' in friendly_name and (numeric < 50 or numeric > 85))
or ('Nearest Storm Distance' in friendly_name and numeric <= 10)
) %}
{% if include and 'UV Index' not in friendly_name %}
{{friendly_name }}:{{value }} {{ unit }}
{% endif %}
{%- endfor %}
{% set uv_index = states('sensor.pirateweather_uv_index') | float(0) %}
{% if uv_index >= 6 %}
UV index is {{ uv_index }}.
[Give a helpful suggestion based on the current UV index or weather conditions]
{% endif %}
{%- if states('sensor.nws_alerts') | int(0) > 0 -%}
{%- if states('sensor.nws_alerts') | int(0) > 0 -%}
{%- set alert_description = state_attr('sensor.nws_alerts', 'Alerts') %}
{%- set alert_description = state_attr('sensor.nws_alerts', 'Alerts') | default('') %}
[Summarize the included weather alert and give overall details on any storms relevant to the residents of the home. Use the Situation Overview Section to best understand what is going on - Be sure to highlight any impacts to Seminole County or Tallahassee]
[Summarize the included weather alert and give overall details on any storms relevant to the residents of the home. Use the Situation Overview Section to best understand what is going on - Be sure to highlight any impacts to Seminole County or Tallahassee]
{{alert_description }}
{{alert_description }}
[END of Weather Alert]
[END of Weather Alert]
@ -162,26 +172,7 @@
{%- endmacro -%}
{%- endmacro -%}
{%- macro uv() -%}
{%- macro uv() -%}
{% if states.sensor.pirateweather_uv_index.state|int(9999)>= 6 %}
{# UV details are now included in outside_weather with a threshold gate #}
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 a helpful suggestion based on the current UV index or weather conditions]