Hi all!
I trying to make a script that speaks via several mediaplayers a texts.
Mediaplayer’s name and text to speak I put into two variables in any automations and then it call this script. Mediaplayer works fine with this variables, but I can not make valid if-then using variables.
How can I replace “media_player.2floor_2floor” with “media_player.{{ mediaplayer }}_{{ mediaplayer }}”?
All listing here:
sequence:
- data:
title: media_player.{{ mediaplayer }}_{{ mediaplayer }}
message: "{{ text }}"
action: persistent_notification.create
enabled: true
- if:
- condition: state
entity_id: media_player.2floor_2floor
state: playing
then:
- wait_for_trigger:
- entity_id:
- media_player.2floor_2floor
to: idle
trigger: state
timeout:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
continue_on_timeout: false
- action: media_player.play_media
target:
entity_id: media_player.{{ mediaplayer }}_{{ mediaplayer }}
data:
media_content_id: media-source://media_source/local/00001.mp3
media_content_type: audio/mpeg
metadata:
title: 00001.mp3
thumbnail: null
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://media_source
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.{{ mediaplayer }}_{{ mediaplayer }}
message: "{{ text }}"
language: ru
target:
entity_id: tts.google_en_com
enabled: true
action: tts.speak
fields:
mediaplayer:
selector:
text: null
name: Mediaplayer
description: Через что говорить
required: true
text:
selector:
text: null
name: Text
description: Что говорить
required: true
alias: Говорилка
description: ""