New weather briefing TTS template and script

This commit is contained in:
2022-06-30 15:14:32 -04:00
parent b399e8429e
commit 80bb7d22bf
2 changed files with 37 additions and 0 deletions

View File

@ -898,3 +898,10 @@ script:
entity_id: sensor.flood_warning
- service: homeassistant.update_entity
entity_id: sensor.flood_watch
weather_briefing:
sequence:
- service: script.speech_engine
data_template:
who: "{{ who }}"
message: !include ../templates/speech/weather_briefing_full.yaml

View File

@ -0,0 +1,30 @@
>
{# Weather Briefing #}
{%- macro getReport -%}
<p>
{{ states('sensor.current_conditions_detail') }}
</p>
<p>
{{ states('sensor.tomorrow_forecast_detail') }}
</p>
<p>
{{ states('sensor.clothing_forecast_detail') }}
</p>
{%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #}
{%- macro cleanup(data) -%}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim }} {% endfor -%}
{%- endmacro -%}
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
{{ getReport() }}
{%- endmacro -%}
{# Call the macro #}
{{- cleanup(mother_of_all_macros()) -}}