TTS with indication of a sensor value

Hello Every Body
I try to create an automation when i open my front door the media player say me the number of windows open .

- id: '1596450868596'
  alias: Ouverture de la porte Principale
  description: ''
  trigger:
  - device_id: bb88e5879ce248ddabbd83200d412105
    domain: binary_sensor
    entity_id: binary_sensor.hall_open_contact
    for:
      hours: 0
      minutes: 0
      seconds: 1
    platform: device
    type: opened
  condition: []
  action:
  - data:
      entity_id: media_player.sonos_bureau
      language: fr
      message: Ouverture de la porte d'Entrée
    service: tts.google_say
  - data:
      entity_id: camera.hikvision_ds_2cd2086g2_i_mainstream
      filename: /config/www/snapshots/parking1.jpg
    service: camera.snapshot
  - data:
      entity_id: camera.netatmo_video_entree
      filename: /config/www/snapshots/entree1.jpg
    service: camera.snapshot
  - data:
      data:
        images:
        - /config/www/snapshots/parking1.jpg
        - /config/www/snapshots/entree1.jpg
      message: Ouverture de la porte Principale, voici les photos
      title: Ouverture de la porte Principale
    service: notify.jarvis
  mode: single

I try to change the tts command but I don’t know how to
Il try this in dev Tools --> service
tts.google_say

entity_id: media_player.sonos_sdj
language: fr
message: "Attention il reste {{states('sensor.open_count')}}."

But I read the text with states sen…

I try this

entity_id: media_player.sonos_sdj
language: fr
data_template:
  message: "Attention il reste {{states('sensor.open_count')}}."
  cache: false

But the system don’t call the service with this error : Extra keys not allowed …

Can you help me ?

You can’t use data_template in the service menu but it works in automations:

  action:
    - service: tts.google_translate_say
      data_template:
        entity_id: media_player.sonos_sdj
        cache: false
        language: fr
        message: "Attention il reste {{states('sensor.open_count')}}."
1 Like