Hello to everyone
I’m trying to solve this problem but i can’t find a solution…
I want to call a one script from automation but i have this error:
TestNotificaAlexa: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: 'None' has no attribute 'attributes'
While executing automation automation.testnotificaalexa
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 285, in async_render
return compiled.render(kwargs).strip()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "<template>", line 2, in top-level template code
File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'None' has no attribute 'attributes'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 138, in async_prepare_call_from_config
service_data.update(template.render_complex(config[conf], variables))
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 81, in render_complex
return {
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 82, in <dictcomp>
render_complex(key, variables): render_complex(item, variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 81, in render_complex
return {
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 82, in <dictcomp>
render_complex(key, variables): render_complex(item, variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 86, in render_complex
return value.async_render(variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 287, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'attributes'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 206, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 385, in _async_call_service_step
domain, service, service_data = async_prepare_call_from_config(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 140, in async_prepare_call_from_config
raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'None' has no attribute 'attributes'
The automation:
- id: '1601037095611'
alias: TestNotificaAlexa
description: ''
trigger: []
condition: []
action:
- data:
entity_id: script.01notifiche_alexa_e_app
variables:
message: "Attenzione!!! ALLARME ATTIVATO!! Effettuata Chiamata a Forze Dell'Ordine...\
\ Risposta OK... In Arrivo. Invio Immagini di Sicurezza a Centro di Controllo\
\ Completato... Sistema di Sicurezza Attivato... Sensori Attivi Comunicati:\
\ {% for state in states.binary_sensor -%}\n{% if state.state == 'on'\
\ and state.entity_id not in states.group.noalarm.attributes.entity_id %}\n\
\ {{ state.name }}\n {%- endif -%}\n {%- endfor -%}\n"
title: ATTENZIONE!! Allarme Attivato!!
service: script.turn_on
The script:
01notifiche_alexa_e_app:
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.echo_dot_di_marco
volume_level: 1
- delay: 00:00:02
- data_template:
data:
method: all
type: announce
title: '{{ title }}'
message: '{{ message }}'
service: notify.alexa_media_echo_dot_di_marco
- delay: 1
- data_template:
data:
type: push
title: '{{ title }}'
message: '{{ message }}'
service: notify.alexa_media_echo_dot_di_marco
- service: media_player.volume_set
data:
entity_id: media_player.echo_dot_di_marco
volume_level: 0.5
Can someone help me please?
Thanks
Stefano