From 80bb7d22bf15222adb48f275ec169788045b2aac Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 30 Jun 2022 15:14:32 -0400 Subject: [PATCH] New weather briefing TTS template and script --- packages/custom_weather.yaml | 7 +++++ templates/speech/weather_briefing_full.yaml | 30 +++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 templates/speech/weather_briefing_full.yaml diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index ee77f48..15418a7 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -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 \ No newline at end of file diff --git a/templates/speech/weather_briefing_full.yaml b/templates/speech/weather_briefing_full.yaml new file mode 100644 index 0000000..c89d72a --- /dev/null +++ b/templates/speech/weather_briefing_full.yaml @@ -0,0 +1,30 @@ +> + {# Weather Briefing #} + {%- macro getReport -%} + +

+ {{ states('sensor.current_conditions_detail') }} +

+

+ {{ states('sensor.tomorrow_forecast_detail') }} +

+

+ {{ states('sensor.clothing_forecast_detail') }} +

+ + {%- 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()) -}} \ No newline at end of file