Sorry that I am only replying now after such a long time!
The original error was fixed by your tip but unfortunately I have another error. Can someone help me here again?
Error in Log:
2024-05-11 18:31:49.279 ERROR (MainThread) [homeassistant.components.script.1698594600049] Sprachausgabe mehrere Alexas: Ausgabe auf Alexa Lennard: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data['type']
2024-05-11 18:31:49.279 ERROR (MainThread) [homeassistant.components.script.1698594600049] Sprachausgabe mehrere Alexas: Error executing script. Invalid data for if at pos 7: extra keys not allowed @ data['type']
2024-05-11 18:31:49.279 ERROR (MainThread) [homeassistant.components.automation.test_nachricht] Edomi Nachricht auf Alexa ausgeben: Error executing script. Invalid data for call_service at pos 5: extra keys not allowed @ data['type']
2024-05-11 18:31:49.283 ERROR (MainThread) [homeassistant.components.automation.test_nachricht] Error while executing automation automation.test_nachricht: extra keys not allowed @ data['type']
I use in all cases the type = tts
Script that call the other script (Sprachausgabe mehrere Alexas):
alias: Sprachausgabe mehrere Alexas
description: Say something with a Group of Alexa devices (tts or announce)
fields:
titel:
description: der Title der Nachricht
example: Fenster/Tür offen
required: true
message:
description: the message (SSML)
example: <amazon:effect name="whispered">Please close the door.</amazon:effect>
required: true
type:
description: tts or announce
example: tts
required: true
duration:
description: the length of the speach in seconds
example: 3.3
required: true
sequence:
- if:
- condition: not
conditions:
- condition: state
entity_id: media_player.wohnzimmersonosone2
state: unavailable
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.wohnzimmer
target2: media_player.wohnzimmersonosone2
duration: "{{ duration }}"
alias: Ausgabe Sonos Wohnzimmer
alias: " Ausgabe Sonos Wohnzimmer"
- if:
- condition: not
conditions:
- condition: state
entity_id: media_player.kuche
state: unavailable
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.kuche
target2: media_player.kuche
duration: "{{ duration }}"
alias: Ausgabe Alexa Küche
- alias: Ausgabe auf Alexa Schlafzimmer
if:
- alias: Aber nur wenn Marion oder Thomas nicht schläft
condition: not
conditions:
- condition: or
conditions:
- condition: state
entity_id: input_select.thomas
state: Schlafend
- condition: state
entity_id: input_select.marion
state: Schlafend
- alias: Nur wenn der Echo im Schlafzimmer auch online ist
condition: not
conditions:
- condition: state
state: unavailable
entity_id: media_player.schlafzimmer
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.schlafzimmer
target2: media_player.schlafzimmer
duration: "{{ duration }}"
- if:
- condition: not
conditions:
- condition: state
entity_id: media_player.bad
state: unavailable
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.bad
target2: media_player.bad
duration: "{{ duration }}"
alias: Ausgabe Alexa Bad oben
- alias: Ausgabe auf Alexa Sydney
if:
- condition: not
conditions:
- condition: state
entity_id: input_select.sydney
state: Schlafend
alias: Aber nur wenn Sydney nicht schläft
- condition: not
conditions:
- condition: state
entity_id: media_player.sydney
state: unavailable
alias: Nur wenn der Echo von Sydney auch online ist
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.sydney
target2: media_player.sydney
duration: "{{ duration }}"
- alias: Ausgabe auf Alexa Helen
if:
- condition: not
conditions:
- condition: state
entity_id: input_select.helen
state: Schlafend
alias: Aber nur wenn Helen nicht schläft
- condition: not
conditions:
- condition: state
entity_id: media_player.thomas_2_echo
state: unavailable
alias: Nur wenn der Echo von Helen auch online ist
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.thomas_2_echo
target2: media_player.thomas_2_echo
duration: "{{ duration }}"
- alias: Ausgabe auf Alexa Lennard
if:
- condition: not
conditions:
- condition: state
entity_id: input_select.lennard
state: Schlafend
alias: Aber nur wenn Lennard nicht schläft
- condition: not
conditions:
- condition: state
entity_id: media_player.lennard
state: unavailable
alias: Aber nur wenn der Echo von Lennard auch online ist
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.lennard
target2: media_player.lennard
duration: "{{ duration }}"
- if:
- condition: not
conditions:
- condition: state
entity_id: media_player.terrasse
state: unavailable
then:
- service: script.turn_on
target:
entity_id: script.1698577146089
data:
variables:
message: "{{ message }}"
type: "{{ type }}"
target: media_player.terrasse
target2: media_player.terrasse
duration: "{{ duration }}"
alias: Ausgabe Alexa Terrasse
mode: parallel
icon: mdi:message-fast
Script for voice output on Alexa (Alexa say):
alias: Alexa say
description: Say something with an Alexa device (tts or announce)
variables:
pause: "{{ 3.0 if type == 'tts' else 2.3 | float }}"
gong: "{{ 1.7 if type == 'announce' else 0.0 | float }}"
messagevolume: >-
{{ (state_attr(target, 'volume_level')|float(0) + 0.1) | default(0.6, true)
}}
reset: "{{ state_attr(target, 'volume_level') | default(0.5, true) }}"
fields:
message:
description: the message (SSML)
example: <amazon:effect name="whispered">Please close the door.</amazon:effect>
required: true
type:
description: tts or announce
example: tts
required: true
target:
description: the target devise as a string (Lautstärke)
example: media_player.wohnzimmer
required: true
target2:
description: >-
Bei der SONOS ist das Device das die Nachricht ausgibt und das das die
Lautstärke einstellt unterschiedlich; the target devise as a string
(Nachricht)
example: media_player.wohnzimmersonosone2
required: true
duration:
description: the length of the speach in seconds
example: 3.3
required: true
sequence:
- service: notify.alexa_media
data:
target: "{{ target2 }}"
message: >-
<break time='{{ pause + 0.2 | float }}s'/> {{ message }} <break
time='1s'/>
data:
type: "{{ type }}"
- delay:
hours: 0
minutes: 0
seconds: "{{ pause | float }}"
milliseconds: 0
- service: media_player.volume_set
data:
volume_level: "{{ messagevolume }}"
target:
entity_id: "{{ target }}"
- delay:
hours: 0
minutes: 0
seconds: "{{ gong + duration | float }}"
milliseconds: 0
- service: media_player.volume_set
data:
volume_level: "{{ reset | float }}"
target:
entity_id: "{{ target }}"
mode: parallel
icon: mdi:bullhorn
Here the alarm:
wohnzimmer_fenster_alarm:
name: Es sind Fenster im Wohnzimmer offen und es ist entweder kalt (Heizung) oder warm (Beschattung)
entity_id: binary_sensor.wohnzimmerfensteralarm
state: "on"
skip_first: true
title: "Wohnzimmer Fenster oder Tür"
message: >
Achtung:
Im Wohnzimmer sind Fenster oder Tür seit mehr als {{ relative_time(states.binary_sensor.wohnzimmerfensteralarm.last_changed)| replace("hours", "Stunden") | replace("minutes", "Minuten") | replace("seconds", "Sekunden") }} offen
repeat:
- 10
notifiers:
- notify
- scripted_alerts
data:
type: "tts"
duration: 8.0