EDIT
The answer to this is that you cannot use variables when you call cURL from an automation.
You must define your shell command in your config fil, including the variables and then call if from within the automation.
I placed this in my configuration file
shell_command:
cameraonesnapshot: curl -o /share/snapshots/cameraonesnapshot.jpg 'Url that you want to call'
If your URL includes an inline password then the entire url should be enclosed in single quotes '...'
I placed this in my automation as a service call
action:
- service: shell_command.cameraonesnapshot
I’m trying to create an automation that retrieves a still image from a CCTV camera and saves it to a named file when the automation is triggered.
The CCTV camera has a snapshot URL
(http://192.168.0.80/webcapture.jpg?command=snap&channel=0&user=...&password=...)
Calling this URL will automatically return an image named “webcapture.jpg”.
I want to save this image to local storage.
Based on the help documentation I’ve created this code segment that I’ve saved to the automations.yaml file using Studio code server.
- id: 1701508224410
alias: Save image from URL
trigger: (insert trigger here)
action:
- service: shell_command
command: curl -o /share/images/image.jpg {{ http://192.168.0.80/webcapture.jpg?command=snap&channel=0&user=...&password=... }}
mode: single```
The automation does not appear alongside the rest of the automations, and on a soft reboot the following error message appears in the log vile
Logger: homeassistant.components.automation
Source: components/automation/config.py:108
Integration: Automation (documentation, issues)
First occurred: 17:27:37 (5 occurrences)
Last logged: 17:31:26
Automation with alias 'Save image from URL' could not be validated and has been disabled: Service shell_command does not match format <domain>.<name> for dictionary value @ data['action'][0]['service']. Got 'shell_command' extra keys not allowed @ data['command']. Got 'curl -o /share/images/image.jpg {{ http://192.168.0.80/webcapture.jpg?command=snap&channel=0&user=...&password=... }}'
Automation with alias 'Save image from URL' could not be validated and has been disabled: Service shell_command does not match format <domain>.<name> for dictionary value @ data['action'][0]['service']. Got 'shell_command' expected str for dictionary value @ data['id']. Got 1701508224410 extra keys not allowed @ data['command']. Got 'curl -o /share/images/image.jpg {{ http://192.168.0.80/webcapture.jpg?command=snap&channel=0&user=...&password=... }}'
I think that I understand the basics of what the error message means, but I don’t know how to put the code in the correct format to achieve what I want.
Could someone please lend me a hand.
The URL is correct and the permissions to the destination directory are correct. I’m using them in other automations.