Dear Community, I am trying to randomize certain tts announcements and I created the following action in the automation:
service: tts.amazon_polly_say
data:
entity_id: media_player.tv_room_speaker
message: >-
{{[ 'Good morning . temperature outside is '{{states(‘sensor.openweathermap_current_temperature’)| round(0) }}‘degree’,
'Hello there . currently it is ‘{{states(‘sensor.openweathermap_condition’) }}’,
]|random }}
cache: false
But I get this error:
Message malformed: template value should be a string for dictionary value @ data[‘action’][2][‘data’]
The sensors itself work well but not when trying to randomize them. I’m sure I’m missing a quote somewhere or something like this. Read through a couple of posts here but can’t figure it out.
my bad here we go, hope that’s formatted correctly now
service: tts.amazon_polly_say
data:
entity_id: media_player.tv_room_speaker
message: >-
{{[ 'Good morning . temperature outside is '{{states('sensor.openweathermap_current_temperature')| round(0) }}'degree',
'Hello there . currently it is '{{states('sensor.openweathermap_condition') }}',
]|random }}
cache: false
Without digging too deep into your code. You are aware of the “Template” section in the developing tools? It gives quite good error messages. If the jinja2 code works there … you are fine.
So amazing how quick I get help here. I’m not really aware of the template section in the developing tools but will give it certainly a try, thanks Ralf.
I tried the new code but still getting an error:
Message malformed: template value should be a string for dictionary value @ data[‘action’][2][‘data’]