Hi all,
I am trying to get Text-To-Speech on Alexa Media Player to read out information from my weather station.
I am stuck on converting a number to a direction text, I have got similar working in template cards but I do not fully understand how to do it here.
Is there syntax I’m missing or is it not supported?
service: notify.alexa_media_kitchen_echo_dot
data:
data:
type: tts
message: >-
The temperature is {{
states('sensor.weather_station_esp32_station_temperature') }} degrees celsius,
humidity is {{states('sensor.weather_station_esp32_station_humidity') }} percent
and wind speed is {{states('sensor.weather_station_esp32_station_wind_speed') }} kilometers an hour,
in {{(% set bearing=states('sensor.weather_station_esp32_station_wind_direction_bearing') | int %)
(% if bearing == 0 %)
North
(% elif bearing == 45 %)
North East
(% elif bearing == 90 %)
East
(% elif bearing == 135 %)
South East
(% elif bearing == 180 %)
South
(% elif bearing == 225 %)
South West
(% elif bearing == 270 %)
West
(% elif bearing == 315 %)
North West
(% else %)
Unknown }} direction.
{{states('sensor.weather_station_esp32_station_total_rain') }} millimetres of rain in the past minute
and total rain has been {{states('sensor.weather_station_esp32_station_total_rain') }} millimetres.
message: >
The temperature is {{ states('sensor.weather_station_esp32_station_temperature') }} degrees celsius,
humidity is {{states('sensor.weather_station_esp32_station_humidity') }} percent,
and wind speed is {{states('sensor.weather_station_esp32_station_wind_speed') }} kilometers an hour, in a
{% set bearing=states('sensor.weather_station_esp32_station_wind_direction_bearing') | int %}
{% if bearing == 0 %}
North
{% elif bearing == 45 %}
North East
{% elif bearing == 90 %}
East
{% elif bearing == 135 %}
South East
{% elif bearing == 180 %}
South
{% elif bearing == 225 %}
South West
{% elif bearing == 270 %}
West
{% elif bearing == 315 %}
North West
{% else %}
Unknown
{% endif %}
direction.
{{states('sensor.weather_station_esp32_station_total_rain') }} millimetres of rain in the past minute
and total rain has been {{states('sensor.weather_station_esp32_station_total_rain') }} millimetres.
I noticed you used tabs instead of spaces in some places too. Do not do that. yaml does not like it. Spaces only.
I’ve managed to also get values for rain in now , thank you again Tom.
message: >
The temperature is {{ states('sensor.weather_station_esp32_station_temperature') }} degrees celsius,
humidity is {{states('sensor.weather_station_esp32_station_humidity') }} percent,
and wind speed is {{states('sensor.weather_station_esp32_station_wind_speed') }} kilometers an hour, in a
{% set bearing=states('sensor.weather_station_esp32_station_wind_direction_bearing') | int %}
{% if bearing == 0 %}
North
{% elif bearing == 45 %}
North East
{% elif bearing == 90 %}
East
{% elif bearing == 135 %}
South East
{% elif bearing == 180 %}
South
{% elif bearing == 225 %}
South West
{% elif bearing == 270 %}
West
{% elif bearing == 315 %}
North West
{% else %}
Unknown
{% endif %} direction.
{% if states('sensor.weather_station_esp32_station_rain') | float > 0 %}
There has been {{states('sensor.weather_station_esp32_station_total_rain') }} millimetres of rain in the past minute
and total of {{states('sensor.weather_station_esp32_station_total_rain') }} millimetres.
{% else %}
With no rain in the past minute.
{% endif %}