guys, i am also using this, but when i clear my notification, i always get the error below inmy log
any idea?
automation:
- id: notifylogin
initial_state: 'on'
alias: "Send notification upon failed login attempt"
trigger:
- platform: state
entity_id: persistent_notification.http_login
condition:
- condition: template
value_template: "{{ trigger.to_state.state != 'None' }}"
action:
- service: notify.notifygmail
data_template:
#title: "{{ states.persistent_notification.http_login.attributes.message }}"
title: "{{ state_attr('persistent_notification.http_login', 'message') }}"
message: 'url: https://whatismyipaddress.com/ip/{{ states.persistent_notification.http_login.attributes.message.split ("from ") [1]}}'
2020-09-13 20:54:47 ERROR (MainThread) [homeassistant.components.automation.send_notification_upon_failed_login_attempt] Send notification upon failed login attempt: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: 'None' has no attribute 'attributes'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, 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 1, 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'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 132, in async_prepare_call_from_config
template.render_complex(config[CONF_SERVICE_DATA_TEMPLATE], variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in render_complex
return {key: render_complex(item, variables) for key, item in value.items()}
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in <dictcomp>
return {key: render_complex(item, variables) for key, item in value.items()}
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 76, in render_complex
return value.async_render(variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 232, in async_render
raise TemplateError(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 191, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 352, in _async_call_service_step
domain, service, service_data = async_prepare_call_from_config(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 135, 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'
2020-09-13 20:54:47 ERROR (MainThread) [homeassistant.components.automation.send_notification_upon_failed_login_attempt] While executing automation automation.send_notification_upon_failed_login_attempt
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, 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 1, 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'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 132, in async_prepare_call_from_config
template.render_complex(config[CONF_SERVICE_DATA_TEMPLATE], variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in render_complex
return {key: render_complex(item, variables) for key, item in value.items()}
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in <dictcomp>
return {key: render_complex(item, variables) for key, item in value.items()}
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 76, in render_complex
return value.async_render(variables)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 232, in async_render
raise TemplateError(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/components/automation/__init__.py", line 430, in async_trigger
await self.action_script.async_run(variables, trigger_context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 802, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 183, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 352, in _async_call_service_step
domain, service, service_data = async_prepare_call_from_config(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 135, 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'