I want to call and execute a specific external URL at a specific time in an automation. Would you please help me? This is my pseudo code:
- alias: 'call my URL'
- condition: state
- condition: state
Thanks for your help
Define a Shell Command that uses curl to call the URL. Then call the shell command in your automation’s action.
# Example configuration.yaml entry
call_something: curl https://www.myexternalurl.com/something
In your automation:
- service: shell_command.call_something
This assumes you are not interested in any data that may be returned by the URL. If you are then you’ll need to consider using something different, perhaps a RESTful sensor.
Hijacking the thread… I have a similar question.
I have to occasionally log on to my Home Assistant at port 3456 to refresh my Amazon token. When I log on, I enter my Amazon login credentials and I am finished. Close the browser. If the token is already current the port 3456 doesn’t exist, so I get a 404 error.
Can you think of a way I could automate this?
Thanks for your reply. I did try a shell command but it didn’t work. I even tried the -G (get) option. I didn’t have any errors but for some reason it did not executed the external URL. I tried the rest command instead and that worked. So my solution was:
# In configuration.yaml file
# action In automation:
- service: rest_command.call_something
Are you sure the example you posted is correct? It looks more like a shell_command instead of a proper rest_command.
Look at the examples in the documentation and you’ll see that a rest_command has very different options and doesn’t call other commands (like
A properly configured rest_command looks more like this:
Yes, you are correct. I corrected the code.
It will look a lot like the example in the first post of this topic. An automation with a Time Trigger that calls a REST command. The main difference is that sometimes your rest_command will fail (because the desired port doesn’t exist) and generate an error message. I think if you add
continue_on_error: true then it’ll allow the automation to finish.
Thanks, but how do I structure the REST command to log on with credentials?
If it’s basic HTTP authentication, try using the rest_command’s