It worked and I got the message on at least one Echo. However, I still have an error in the log. Not sure what this mean and how to solve.
Log:
2024-01-25 10:59:25.284 ERROR (MainThread) [homeassistant.components.script.1698577146089] Alexa say: Error rendering variables: TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'
2024-01-25 10:59:25.284 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 567, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2305, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 594, in _async_run
return await self.script.async_run(script_vars, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1535, in async_run
variables = self.variables.async_render(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script_variables.py", line 62, in async_render
rendered_variables[key] = template.render_complex(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 237, in render_complex
return value.async_render(variables, limited=limited, parse_result=parse_result)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'
Alert:
whirlpool_temperatur:
name: Die Temperatur des Whirlpools ist unter 6 Grad
entity_id: binary_sensor.whirlpool_temperatur_alarm
state: "on"
skip_first: true
repeat:
- 30
- 45
- 60
notifiers:
#- alexa_media_alle_lautsprecher
- scripted_alerts
message: "Achtung: Die Temperatur des Whirlpools ist unter 6 Grad"
title: "Temperatur des Whirlpools"
data:
type: "tts"
duration: 6.3
automation:
alias: Nachrichten aus Alarmen
description: Gib die Nachricht aus Alarmen auf verschiedenen Echos wieder
trigger:
- platform: event
event_type: call_service
event_data:
domain: notify
service: scripted_alerts
variables:
data: "{{trigger.event.data.service_data.data | to_json}}"
condition: []
action:
- service: script.1698594600049
data:
message: "{{trigger.event.data.service_data.message}}"
title: "{{trigger.event.data.service_data.title}}"
type: "{{data.type}}"
duration: "{{data.duration}}"
mode: parallel
Trigger Script (1698594600049):
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"
- 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
enabled: false
- 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
- 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 }}"
alias: Ausgabe Alexa Schlafzimmer
- 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
Echo script:
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') + 0.1 | default(0.6, true) | float }}"
reset: "{{ state_attr(target, 'volume_level') | default(0.5, true) | float }}"
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