Google Home speaks differently depending on the condition

The code below does not work

error message: Invalid data for call_service at pos 2: extra keys not allowed @ data[‘data_template’]

How do I get it working?

- alias: 'weather'

initial_state: true

trigger:

platform: state

entity_id: binary_sensor.motion_sensor_158d00027ca3d5

from: 'off'

to: 'on'

condition:

- condition: state

  entity_id: binary_sensor.door_window_sensor_158d000293173a

  state: 'off'

- condition: or

  conditions:

    - condition: numeric_state

      entity_id: sensor.airkorea_pm25_24h

      above: 70

    - condition: numeric_state

      entity_id: sensor.airkorea_pm10_24h

      above: 130

    - condition: state

      entity_id: weather.kmalocalweather

      state: 'rain'

action:

- service: media_player.volume_set

  data_template:

    entity_id: media_player.geosil

    volume_level: 0.6

- service: tts.google_say

  entity_id: media_player.geosil

  data:

    data_template:

      message: >

        {% if is_state('weather.kmalocalweather' , 'rain') %} It's rain

        {% else %} Fine dust warning {% endif %}

    cache: 'true'

- delay: 0:0:10

- service: media_player.volume_set

  data_template:

    entity_id: media_player.geosil

    volume_level: 0.2
- service: media_player.volume_set

  data:

    entity_id: media_player.geosil

    volume_level: 0.6

- service: tts.google_say

  entity_id: media_player.geosil

  data_template:

    message: >

      {% if is_state('weather.kmalocalweather' , 'rain') %} It's rain

      {% else %} Fine dust warning {% endif %}

    cache: 'true'

works great! thanks

1 Like