Is that the HA way of saying that it’s installed and configured by default, and that you don’t need to do any additional setup?
Yes it is installed out of the box. Everything here is Integrations - Home Assistant
You don’t need to use a template. The command should run the same thing every time shouldn’t it?
I did just notice that the yaml in your first post has the indentation wrong. Please post what your current action is.
I’ve chopped and changed it multiple times trying to figure out what the problem is. so this is a badly hacked about version. Ech time I’m getting a similar error message
Automation with alias 'Save image from URL' could not be validated and has been disabled: Unable to determine action @ data['action'][0]. Got None
My understanding is that either Shell_command isn’t recognized, or that the payload of shell_command isn’t recognized meaning that I can’t call Curl in this way.
These is my last attempt.
From automations.yaml
- id: save_image_from_url
alias: Save image from URL
trigger:
- platform: time
at: '00:00:00'
action:
shell_command: curl -o /share/snapshots/image.jpg {{ ptz_besderii_motioneye_url
}}
From template.yaml (I’m keeping these in a separate file for convenience
- sensor:
- name: ptz_besderii_motioneye_url
unique_id: ptz_besderii_motioneye_url
state: "http://homeassistant.local:8123/api/ ......(URL from motioneye, confirmed good)"
That’s just from the post here, the original didn’t have that.
So completely different to your first post. Different url. Trying to use a nonsensical template.
Man you are hard to help.
Fundamentally why are you using a template?
I’ve changed the code because there was obviously something wrong with it as it wouldn’t run, but my problem is still the same.
Different url.
I tried a different URL in case the URL was the problem, it wasn’t.
Fundamentally why are you using a template?
Because it was in the original example that I was following, it produces the exact same error as putting the URL in with singe or double quotes, or no quotes at all.
I’m still getting fundamentally the same error message.
Unable to determine action @ data['action'][0]. Got None
Which means that I’m probably feeding shell_command the wrong inputs or formatting it in the wrong way.
I just want to run this command:
curl -o /share/snapshots/image.jpg {{ URL to an image }}
Could you please try writing an automation on your own system that does this, and see if you get something different at your end?
All that it’s supposed to do is to save the contents of the URL to the local disc.
My ultimate aim is to have the URL coming from a webhook, I tried it with and without it and the error message was the same.
Thank you for finally answering why you are using a template.
The template you are using, ie {{ ptz_besderii_motioneye_url}}
won’'t return anything sensible. You might want {{ states ('sensor.tz_besderii_motioneye_url')}}
You’ve asked the question before, I answered it last week. I’m not sure you’re asking again
Blindly copying someone else’s code is not a reason. You appeared to be trying to retrieve a static url. That is why I asked again. You have finally answered.
Blindly copying someone else’s code is not a reason.
Copying from tutorials is pretty much the default for new users. We take existing code and modify it until we have sufficient understanding to write our own from scratch. I’m afraid that my programming background is in assembler, and even then that was decades ago, so yaml syntax is an alien language to me.
You appeared to be trying to retrieve a static url.
It’s going to be dynamic, hence the template, but I haven’t gotten to that part yet.
The template you are using, ie {{ ptz_besderii_motioneye_url}} won’'t return anything sensible. You might want {{ states ('sensor.tz_besderii_motioneye_url')}}
Both seem to return identical values when I use the states function under developer tools. Could you please explain the difference to me in terms of the value that is returned.
Were you able to establish that the command
curl -o /share/snapshots/image.jpg {{ URL to an image }}
Is a valid command for use in Home Assistant\yaml?
Am I forming the command incorrectly, or trying to call something that doesn’t exist?
I made the change that you suggested but am still receiving the same error message.
I think that I understand what you’re getting at, but the log file suggests that the problem is with the commands that I’m passing to shell_command, or the way that I’m calling them, not with the URL.
Are you able to run Curl -o on your own system?
Try it in the template tab in dev tools.
One is a valid template, yours isn’t. You probably need to read this Templating - Home Assistant
curl -o works at the commandline here, but i haven’t tried it in an automation.
Another thing, does /share/snapshots exist? Is it accessible to ha? Try a command like touch /share/snapshots/testfile
in an automation.
I tried both in Developer Tools tab and they returned the URL without any problems. I think that this is just an older format.
Another thing, does /share/snapshots exist? Is it accessible to ha?
Yes, it exists and is visible to HA. I’ve been using it for a while with several other CCTV that support the snapshot command. I’m now trying to integrate several camera that provide their snapshots by URL. Hence the need to use Curl -o to save it.
The code is failing before the template is being called.
Try a command like touch /share/snapshots/testfile in an automation.
I’m going to need some instructions on how to do that, unless you want me to blindly copy some code from the internet again.
Frankly i don’t believe that. Can you post a screenshot please.
Frankly this isn’t the problem that I’m trying to fix right now.
Could we please stick with one problem at a time.
If I go into the command line and enter
curl -o /share/snapshots/image (Url as plain text, without quote, with single quote, or with double quotes)
I get the output
100 17 100 0 0 dload 618
I also get a file that is 1kb with the correct name in the correct directory. The file is not a valid image file. Viewing it in a hex editor shows that it’s an asci file containing the string “401 unauthorised”.
The link functions perfectly in both firefox and edge. So presumably I need to add something to Curl to tell it what to do rather than just giving it a raw URL.
401 unautorized - big clue there.
If I try the URL in firefox I get 401: unauthorised, not the image.
The link is perfectly OK in Edge, but not firefox.
I’m a little confused as to why you would say that it’s a clue rather than simply writing the answer.