I’m trying to implement the ability to send notifications via SMS where my HomeAssistant instance has no access to internet or where I’m without a data connection for my phone.
I currently have working states for when notifications should be via SMS and a working shell_command service to send SMS using gammu. input_boolean.notify_via_sms is set by the system as required and is then used to determine which notification to use.
However I’m struggling with the best method of templating this approach for ease of re-use throughout multiple automations, and hoped that someone here might be able to offer some pointers based on their experience.
My current (testing) scripts are:
SMS notification template - working
# send sms notification using gammu and data_template
sms_notification:
sequence:
- condition: state
entity_id: input_boolean.notify_via_sms
state: 'on'
- service: shell_command.send_sms
data_template:
sms_to: "{{ recipient }}"
sms_msg: "{{ msg }}"
Pushover notification template - working when called from services
pushover_notification:
sequence:
- condition: state
entity_id: input_boolean.notify_via_sms
state: 'off'
- service: notify.pushover
data_template:
title: "{{ title }}"
message: "{{ msg }}"
data:
sound: "{{ sound }}"
priority: "{{ priority }}"
timestamp: true
Master notification script - SMS working, pushover not
send_test_notify:
sequence:
- service: script.sms_notification
data_template:
recipient: "{{ states.sensor.sms.state }}"
msg: "{{ message }}"
- service: script.pushover_notification
data_template:
title: "{{ title }}"
msg: "{{ message }}"
data:
sound: "{{ sound }}"
priority: "{{ priority }}"
When calling script.send_test_notify with the services tool I get a failure for the pushover message from the master script:
2019-06-23 17:46:17 ERROR (SyncWorker_7) [custom_components.pushover_custom.notify] Could not send pushover notification
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/pushover_custom/notify.py", line 109, in send_message
self.pushover.send_message(message=message, attachment=file, **data)
File "/srv/homeassistant/lib/python3.6/site-packages/pushover.py", line 275, in send_message
return MessageRequest(payload, files)
File "/srv/homeassistant/lib/python3.6/site-packages/pushover.py", line 129, in __init__
Request.__init__(self, "post", MESSAGE_URL, payload, files)
File "/srv/homeassistant/lib/python3.6/site-packages/pushover.py", line 110, in __init__
raise RequestError(self.answer["errors"])
pushover.RequestError:
==> message cannot be blank
When calling script.pushover_notification with the same data from services tool the message sends successfully.
So - have I missed something obvious? Is there a better way of achieving my end goal?