Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Script with if ..... help

$
0
0

@alverman wrote:

Good evening I have a script that prepares a message and sends the message to a script that makes alexa pronounce it but the script that builds the message does not work.

Message construction:

calendario_lavoro:
  alias: "Prossimo lavoro"
  sequence:
    - service: script.speak_all
      data_template:
        {% if is_state("calendar.lavoro", "off")-%}
          message: Oggi non hai nessun impegno programmato
        {%- else -%}
          message: Ciao Alberto, hai un impegno di lavoro il {{ as_timestamp(states.calendar.lavoro.attributes.start_time) | timestamp_custom('%-d %B') }} dalle {{ as_timestamp(states.calendar.lavoro.attributes.start_time) | timestamp_custom('%I:%M %p') }} alle {{ as_timestamp(states.calendar.lavoro.attributes.end_time) | timestamp_custom('%I:%M %p') }} al {{states.calendar.lavoro.attributes.message }}
        {%- endif %}

this script reads with alexa.
This definitely works because other messages read them

speak_all: 
  alias: "TTS message all"
  sequence:
    - service: media_player.volume_set
      entity_id: media_player.cucina
      data:
        volume_level: '.3'
    - service: notify.alexa_media
      data:
        data:
          type: tts
        target:
        - media_player.cucina
        - media_player.ufficio
        - media_player.letto
      data_template:
        message: "{{ message }}"
        data:
          type: announce
#        method: media_player.all

How can I solve its syntax?
Thanks, Alberto

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>