Hello,
As requesting I am creating a new topic for my question.
I currently use a few Google TTS related automations which are sending notification messages (long dynamic string with few sentences including some inline jinja code), f.e. weather_forecast/daily_plan in local language.
Automations have multiple copies because of different triggers, conditions and//or output speaker device.
But the notifications parameter “message” is the same.
It’s a very long string with some jinja code to include selected sensors state.
I tried to use the new Template feature to remove duplicity of the notification message parameter between similar automations (use and maintain 1 copy of “message” parameter used by multiple automation).
Moved the “message” string to a file /config/custom_templates/tts_message_weather_forecast.jinja and
tried to replace the notification “message” parameter in automations with {% include 'tts_message_weather_forecast.jinja' %}
but receiving an error “Template not found”.
Is it possible to use the new HA 2023.4 templating feature somehow for definition of 1 dynamic message string used for sending notification messages via multiple automations?
Notification parameter Message content saved as tts_message_weather_forecast.jinja file follows:
Mám pre Vás informácie o počasí. Vonku je práve
{{states.sensor.openweathermap_weather.state}} a
{{states.sensor.openweathermap_temperature.state|round}} °, pocitová
teplota
{{states.sensor.openweathermap_feels_like_temperature.state|round}} °,
vlhkosť vzduchu {{states.sensor.openweathermap_humidity.state|round}} %.
{% set condition =
(states.sensor.openweathermap_forecast_condition.state) %} {% set
conditions = {'clear-night': 'jasná noc', 'cloudy': 'zamračené',
'exceptional': 'výnimočne', 'few clouds': 'slabá oblačnosť', 'fog':
'hmlisto', 'hail': 'krupobitie', 'lightning': 'búrky s bleskami',
'lightning-rainy': 'búrky s dažďom', 'partlycloudy': 'čiastočne
zamračené', 'pouring': 'silný lejak', 'rainy': 'dážď', 'snowy': 'padanie
snehu', 'snowy-rainy': 'dážď so snehom', 'sunny': 'slnečno', 'windy':
'veterno', 'windy-variant': 'premenlivý vietor'} %} Predpoveď na dnešný
deň je {{ conditions[condition] }}, najvyššia teplota dosiahne
{{states.sensor.openweathermap_forecast_temperature.state|round}} ° {%
if states.sensor.openweathermap_forecast_temperature_low.state ==
"unknown" %} . {% else %} a najnižšia klesne na
{{states.sensor.openweathermap_forecast_temperature_low.state|round}} °.
{% endif %} {% if
states.sensor.openweathermap_forecast_precipitation_probability.state|int
> 0 %} S pravdepodobnosťou {{
states.sensor.openweathermap_forecast_precipitation_probability.state }}
% by mohlo spadnúť {{
states.sensor.openweathermap_forecast_precipitation.state }} milimetrov
zrážok {% endif %} {% if
states.sensor.openweathermap_precipitation_kind.state == "None" %} . {%
else %} {% set precipitation =
(states.sensor.openweathermap_precipitation_kind.state) %} {% set
precipitations = {'Rain': 'dažďa', 'Snow': 'snehu', 'Snow-rain': 'dažďa
so snehom'} %} vo forme {{ precipitations[precipitation] }}. {% endif %}
{% if states.sensor.openweathermap_forecast_wind_speed.state|int > 5 %}
Vietor by mohol dosiahnuť rýchlosť až {{
states.sensor.openweathermap_forecast_wind_speed.state|int*3.6 }} km/h.
{% endif %} {% set ts_forecast =
(as_timestamp(states.sensor.openweathermap_forecast_time.state)) | int
%} {% set ts_now = (as_timestamp(now())) | int %} {% set
duration = ts_forecast - ts_now %} {% set seconds = duration % 60
%} {% set minutes = (duration / 60)|int % 60 %} {% set hours =
(duration / 3600)|int %} Platnosť predpovede {% if duration < 0 %} {%
set duration = -1 * duration %} skončila pred časom {% else %} skončí za čas
{% endif %} {{ duration | timestamp_custom("%H:%M:%S", 0) }}