Hi,
I want to make a call from an external program to Hass to send a photo using Telegram. The photo file name is different every time, so I’ve created an script and I want to call it passing the photo name as a variable:
I want to do this using a script because I want to add some logit to it, so I cannot call the notify/telegram service directly.
I’ve created the follwing simple script:
test:
alias: 'Test script'
sequence:
- service: notify.telegram
data_template:
message: 'text'
data:
photo:
- file: '{{file}}'
caption: '{{caption}}'
I call it:
curl -X POST -H "Content-Type: application/json" -H "x-ha-access: xxxxxxxxx" -H "Cache-Control: no-cache" -d '{
"entity_id": "script.test",
"data": {
"file": "/test.jpg",
"caption": "Sample caption"
}
}' "https://xxx.www.zzz/api/services/script/test"
The call arrives to the server but I get the following error:
ERROR (MainThread) [homeassistant.core] Invalid service data for notify.telegram: extra keys not allowed @ data['data_template']. Got OrderedDict([('photo', [OrderedDict([('file', '{{file}}'), ('caption', '{{caption}}')])])])
Is there any way to pass “objects” as script variables?