Hello, I’m trying to set up a script but I’m getting an error
Message malformed: Entity {{ media_player_id }} is neither a valid entity ID nor a valid UUID for dictionary value @ data[‘entity_id’]
the essence of the script (briefly)
pass to the script: media player, volume and text
the script checks if the player is working or not
if not, sets the specified volume and plays the text, then returns the previous volume (already written, but the problem is in the wait_for_trigger block)
2nd part (not yet written) if the player was playing music, then pause, set the volume, play the text, return the volume of the music and resume it.
script below:
alias: Kodi (TTs)
mode: single
icon: mdi:kodi
fields:
message:
description: Что сказать?
example: Привет мир!
media_player_id:
description: entity_id устройства
example: media_player.kodi
tts_volume:
description: Громкость в %
example: 90
variables:
volume: |
{{state_attr(media_player_id,"volume_level")}}
sequence:
- if:
- condition: template
value_template: |
{{states(media_player_id) == "idle"}}
then:
- service: media_player.volume_set
data:
volume_level: |
{{ tts_volume / 100 }}
target:
entity_id: |
{{ media_player_id }}
- service: notify.notify
data:
message: |-
Kodi бездействует, громкость {{ (volume * 100)|int }} %.
Подготовка говорить, громкость {{ tts_volume }} %
- service: tts.google_translate_say
data:
message: |
{{ message }}
cache: false
language: ru
entity_id: |
{{ media_player_id }}
- wait_for_trigger:
- platform: state
entity_id: "{{ media_player_id }}"
from: playing
to: idle
timeout:
hours: 0
minutes: 0
seconds: 20
milliseconds: 0
- service: media_player.volume_set
data:
volume_level: |
{{ volume }}
target:
entity_id: |
{{ media_player_id }}