Hi there HA community!
2nd post here ever!
Question about passing data through a script to a service.
I have a service which is working fine to send SMS in my configuration.yaml
rest_command:
telynx_sms:
url: https://sms.telnyx.com/messages
method: POST
headers:
x-profile-secret: eVWm*******************DCtuF7L
accept: 'application/json, text/html'
payload: '{"from": "+15*************3","to": "{{ number }}","body": "{{message}}"}'
content_type: 'application/json; charset=utf-8'
verify_ssl: true
This makes a REST call to telynx to send SMS to phones
I’d like to be able to have a script that I can pass the message to that has 3 or 4 calls in it to the service passing the same message to multiple numbers.
I have created scripts in the scripts.yaml that look like this that work:
trash_monday_01:
alias: TrashMonday01
sequence:
- data:
message: 'Monday Night! Trash needs to go to curb by 9pm please!! :-) There will be 2 more. --from Dad'
number: '+1510****427'
service: rest_command.telynx_sms
- data:
message: 'Monday Night! Trash needs to go to curb by 9pm please!! :-) There will be 2 more. --from Dad'
number: '+1510****300'
service: rest_command.telynx_sms
- data:
message: message: 'Monday Night! Trash needs to go to curb by 9pm please!! :-) There will be 2 more. --from Dad'
number: '+1510****309'
service: rest_command.telynx_sms
- data:
message: message: 'Monday Night! Trash needs to go to curb by 9pm please!! :-) There will be 2 more. --from Dad'
number: '+1510****395'
service: rest_command.telynx_sms
However what I’d like to be able to do is pass the message to the script that then gets passed to the service so I don’t have to have a script for every one of those.
Something like (this is the part I’m not sure about):
group_sms_trash_reminder:
alias: groupTrashReminder
sequence:
- data:
message: '{{message}}'
number: '+1510****427'
service: rest_command.telynx_sms
- data:
message: '{{message}}'
number: '+1510****300'
service: rest_command.telynx_sms
- data:
message: '{{message}}'
number: '+1510****309'
service: rest_command.telynx_sms