Here is a more complex one which may help you with some ideas. The delay at the end calculates the spoken text time and sets the delay before Sonos rejoins the other speakers.
- service: tts.google_cloud_say
data_template:
entity_id: "{{ (state_attr('variable.v_sonos_speaker_group', 'master')) }}"
message: >-
{# ======================================================================================================== #}
{# Preamble #}
Your daily briefing is about to start.
{# ======================================================================================================== #}
{# Salutation #}
{% if states('sensor.time_of_day') != '' %}
Good {{states('sensor.time_of_day')}} {{ var_person_name }}.
{% endif %}
{# ======================================================================================================== #}
{# Time #}
{% if states.sensor.readable_time.state.lstrip('0') != '' %}
The time is {{ now().strftime('%-I:%M %p') }}.
{% endif %}
{# ======================================================================================================== #}
{# Day/Date #}
Today is a
{% if (states('sensor.payday') == 'True') and (states('sensor.day_of_the_week') == 'Friday') %}
payday
{% endif %}
{{states('sensor.day_of_the_week')}}
and the date is the {{states('sensor.day_of_the_month')}} of {{states('sensor.month_name')}}.
{# ======================================================================================================== #}
{# Special Events #}
{% if states('sensor.special_events') != 'NoEvents' %}
{% if states('sensor.special_events') != '' %}
{{states('sensor.special_events')}}
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Birthday/Holiday All #}
{% if states('sensor.todays_events') != 'NoEvents' %}
{% if states('sensor.todays_events') != '' %}
{% if states('sensor.todays_events')|replace("\'","") == 'Arts Birthday' %}
Happy Birthday Art.
{% endif %}
{% if states('sensor.todays_events')|replace("\'","") == 'Steffs Birthday' %}
Happy Birthday Steff.
{% endif %}
Don't forget, it's {{states('sensor.todays_events')}} today.
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Holiday Lighting #}
{% if (states('sensor.season') != (states('input_select.season_holiday'))|lower()) %}
Remember to look for the {{ states('input_select.season_holiday') }} lighting theme later tonight.
{% endif %}
{# ======================================================================================================== #}
{# Birds #}
{% if states('sensor.weigh_birds') == 'True' %}
It's time to weigh the birds again.
{% endif %}
{# ======================================================================================================== #}
{# Weather #}
It's currently {{states('sensor.dark_sky_summary')}} and {{states('sensor.dark_sky_temperature')}} degrees at home.
Today will be {{states('sensor.dark_sky_hourly_summary')|replace('.','')}}, with a high of {{states('sensor.dark_sky_daytime_high_temperature_0d')|round(0)}} degrees and a low of {{states('sensor.dark_sky_overnight_low_temperature_0d')|round(0)}} degrees.
{% if states('sensor.dark_sky_precip_intensity_0d') | float(default=0) > 0.1 %}
We may see {{states('sensor.dark_sky_precip_intensity_0d')}} inches of rain today.
{% endif %}
{# ======================================================================================================== #}
{# Winds #}
{% if states.sensor.dark_sky_daily_summary.state != '' %}
Current winds are
{% set winbearing = ((states('sensor.tidewater_wind_dir_avg_10m')|float(default=0)+22.5)/45)|int|round %}
{% if winbearing > 7 %}{% set winbearing = 0 %}{% endif %}
{% set winddir = ['North', 'North East','East','South East','South','South West','West','North West'] %}
{{ winddir[winbearing]}} averaging {{(states('sensor.dark_sky_wind_speed_0d')|int)|round}} miles per hour
{% if states('sensor.dark_sky_wind_gust_0d') | float(default=0) > 0 %}
with gusts up to {{(states('sensor.dark_sky_wind_gust_0d')|int)|round}}
{% endif %}
miles per hour.
{% endif %}
{# ======================================================================================================== #}
{# NWS Warnings #}
{% if states('sensor.coastal_duval') | int > 0 %}
{% if states.sensor.coastal_duval.attributes.alerts[0].title | lower() != 'none' %}
{% if states.sensor.coastal_duval.attributes.alerts[0].title | lower() != 'unknown' %}
{% if states.sensor.coastal_duval.attributes.alerts[0].title | lower() != 'unavailable' %}
The National weather service has issued the following alert for {{ state_attr('sensor.coastal_duval', 'friendly_name') }}. {{ states.sensor.coastal_duval.attributes.alerts[0].title }}, {{ state_attr("sensor.coastal_duval_alert_1","alert_NWSheadline") }}.
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# UV Index #}
{% if states('sensor.dark_sky_uv_index')|int >= 6 and states('sensor.dark_sky_uv_index')|int <= 7.9 %}
Today's UV index is {{ states('sensor.dark_sky_uv_index') }}. This is high. Be sure wear sunscreen.
{% elif states('sensor.dark_sky_uv_index')|int >= 8 and states('sensor.dark_sky_uv_index')|int <=10.9 %}
Today's UV index is {{ states('sensor.dark_sky_uv_index') }}. This is very high. Be sure wear sunscreen and re-apply.
{% elif states('sensor.dark_sky_uv_index')|int >= 11 %}
Today's UV index is {{ states('sensor.dark_sky_uv_index') }}. This is EXTREME. You should use caution when going outside.
{% endif %}
{# ======================================================================================================== #}
{# Fog Warnings #}
{% if states('sensor.pirate_weather_visibility') != '' %}
{% if states('sensor.pirate_weather_visibility')|int(default=0) < 2 %}
{% if states('sensor.pirate_weather_visibility') != 0 %}
Current visibility is only {{states('sensor.pirate_weather_visibility')}} miles. Use caution!
{% endif %}
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Sunrise/Sunset #}
{% if states('sensor.next_rising') != '' %}
{% if states('sensor.next_setting') != '' %}
Sunrise
{% if states('sun.sun') == 'above_horizon' %}
was at
{% else %}
is at
{% endif %}
{{states('sensor.next_rising')|replace(':',' ')}}
and sunset will be at
{{states('sensor.next_setting')|replace(':',' ')}}.
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Moon #}
{% if states('sensor.moonphase') == 'Full Moon' or (states('sensor.dark_sky_moon_phase_0d')|float(default=0) > 0.45 and states('sensor.dark_sky_moon_phase_0d')|float(default=0) < 0.55) %}
There will be a Full Moon tonight.
{% endif %}
{# ======================================================================================================== #}
{# Tides #}
{% if states('sensor.next_tide') != 'unknown' %}
{% if states('sensor.next_tide') != '' %}
{% if is_state_attr('sensor.dames_point_tides', 'next_tide_type', 'High') %}
The next High tide is at {{state_attr('sensor.dames_point_tides', 'next_tide_time')}}.
{# ==== High Tide Warnings ===================== #}
{% if states('sensor.high_tide_height')|float(default=0) > states('variable.v_max_high_tide')|float(default=0) * 0.90 %}
It will be higher than average at {{states('sensor.high_tide_height')|float(default=0)|round(2)}} feet above sea level.
{% endif %}
{# =============================================== #}
The last Low tide was at {{state_attr('sensor.dames_point_tides', 'last_tide_time')}}.
{% else %}
The next Low tide is at {{state_attr('sensor.dames_point_tides', 'next_tide_time')}}.
The last High tide was at {{state_attr('sensor.dames_point_tides', 'last_tide_time')}}.
{% endif %}
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Arts Location #}
{% if var_person_name == 'Steff' %}
{% if states('device_tracker.arts_iphone_11') != 'home' %}
Art is
{% if states('device_tracker.arts_iphone_11') == 'S*****' %} currently at S***** Hospital.
{% elif states('device_tracker.arts_iphone_11') == 'B*****' %} currently at B***** Hospital.
{% elif states('device_tracker.arts_iphone_11') == 'F*****r' %} currently at F***** Hospital.
{% elif states('device_tracker.arts_iphone_11') == 'M*****' %} currently at the M***** Clinic.
{% elif states('device_tracker.arts_iphone_11') == 'M*****' %} currently at M*****l Hospital.
{% elif states('device_tracker.arts_iphone_11') == 'St V****' %} currently at St V***** Hospital.
{% else %}
away from home.
{% endif %}
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Trash Day #}
{% if states('sensor.day_of_the_week') == 'Wednesday' %}
Today is Wednesday. The trash bin needs to be out to the road.
{% endif %}
{# ======================================================================================================== #}
{# Recycling Day #}
{% if states('sensor.date') == states('input_datetime.recycle_pickup_date') %}
Today is Monday. The recycling bin needs to be out to the road.
{% endif %}
{# ======================================================================================================== #}
{# First Saturday #}
{% if (states('sensor.day_of_the_week') == 'Saturday') and (states('sensor.day_num_of_the_month') | int < 8) %}
It's the first Saturday of the month. Please remember to change the furnace filters and top off the golf cart batteries.
{% endif %}
{# ======================================================================================================== #}
{# Reminders Art #}
{% if var_person_name == 'Art' %}
{% if states('sensor.submit_expenses') == 'True' %}
{% if states('input_boolean.remind_expenses') == 'on' %}
Remember to submit your expense report today.
{% endif %}
{% endif %}
{% if states('sensor.submit_mileage') == 'True' %}
{% if states('input_boolean.remind_mileage') == 'on' %}
Remember to submit your mileage today. You have {{state_attr('sensor.submit_mileage', 'days_remaining')}} days remaining.
{% endif %}
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Appointments Art #}
{% if var_person_name == 'Art' %}
{% if states('sensor.arts_next_appointment') != '' %}
{% if state_attr('sensor.arts_next_appointment','appointment_date') == states('sensor.date') %}
{% if states('binary_sensor.workday_today') == 'on' %}
Your next scheduled case starts at {{states('sensor.arts_next_appointment')}} at {{states('sensor.arts_next_appointment_location')}}, {{ state_attr('sensor.arts_next_appointment','appointment_title')|replace(states('sensor.arts_next_appointment_location')|lower,"") }}.
{% if is_number(states('sensor.to_'+states('sensor.arts_next_appointment_location')|lower))%}
{% set traveltime = states('sensor.to_'+states('sensor.arts_next_appointment_location')|lower) %}
{% set travelseconds = ((traveltime|int)*60) %}
Travel time to {{states('sensor.arts_next_appointment_location')}} is {{states('sensor.to_'+states('sensor.arts_next_appointment_location')|lower)}} minutes.
{% set nxtapp = (states('sensor.arts_next_appointment')) %}
{% set apdate = (state_attr('sensor.arts_next_appointment','appointment_date')) %}
{% set todest = (states('sensor.to_'+states('sensor.arts_next_appointment_location')|lower)) %}
{% set ttsecs = todest|int*60 %} {# travel time in seconds #}
{% set app_ts = as_timestamp(apdate + ' ' + nxtapp) %} {# appointment timestamp #}
{% set gotime = app_ts - ttsecs %}
You will need to leave no later than {{ gotime | timestamp_custom('%H:%M') }} to arrive on time.
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{# ======================================================================================================== #}
{# Space Launches #}
{% if (states('binary_sensor.launch_within_24_hours') == 'on') %}
There is a planned rocket launch of the {{states('sensor.next_launch_rocket')}} {{states('sensor.next_launch_mission')}} mission. Liftoff is scheduled for {{ states('sensor.next_confirmed_launch_time') }} on {{ states('sensor.next_launch_day') }}.
{% endif %}
{# ======================================================================================================== #}
{# Closing Statement #}
{% if var_person_name == 'Art' %}
Have a{{ [' pleasant', ' nice', ' great', ' good', ' cheerful', ' delightful', 'n enjoyable', ' super', ' wonderful', ' satisfying'] | random }} day!
{% else %}
Have a{{ [' pleasant', ' nice', 'n amiable', ' happy', ' cheerful', ' delightful', 'n enjoyable', ' lovely', ' pleasing', ' good'] | random }} day!
{% endif %}
- delay: >-
{% set duration = (states.media_player.kitchen_white.attributes.media_duration) %}
{% if duration < 2 %}
{% set duration = 2 %}
{% endif %}
{% set seconds = duration % 60 %}
{% set minutes = (duration / 60)|int % 60 %}
{% set hours = (duration / 3600)|int %}
{{ [hours, minutes, seconds]|join(':') }}