I’m trying to set up Home Assistant to send me SMS messages via the AWS SNS notification.
I have put the following into my configuration.yaml
file:
aws:
credentials:
- name: name-of-aws-credential
aws_access_key_id: !secret aws_access_key_id
aws_secret_access_key: !secret aws_secret_access_key
notify:
- service: sns
region_name: eu-west-1
Now I go to Developer Tools
> Services
and select Notify.Notify
as the service.
In the Service Data (YAML, optional)
entry box I put the following JSON:
{
message: "Test Message",
title: "Test Title"
}
If I submit this, it works and I get a notification on the Home Assistant app on my Andrioid Phone.
When I expand the JSON to include the SNS arn
as follows I cannot get it to work:
{
message: "Test Message",
title: "Test Title",
target: "arn:aws:sns:eu-west-1:nnnnnnnnnnnn:hass-notifications"
}
This fails with the following log entry:
'arn:aws:sns:eu-west-1:nnnnnnnnnnnn:hass-notifications'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/notify/__init__.py", line 120, in async_notify_message
await notify_service.async_send_message(**kwargs)
File "/usr/src/homeassistant/homeassistant/components/mobile_app/notify.py", line 114, in async_send_message
entry = self.hass.data[DOMAIN][DATA_CONFIG_ENTRIES][target]
KeyError: 'arn:aws:sns:eu-west-1:nnnnnnnnnnnn:hass-notifications'
I kind of get that the python code is looking for a nested structure but I’m not sure what it wants due to the constants used for the keys in the stack trace.
I’m guessing that I enter in Service Data
goes into self.hass.data
so therefore I need some extra levels in my JSON to get target into the right place.
Can anyone provide a sample of some JSON that would work here? Ideally I could also do with a sample that would work in an automation as well.
Thanks.