Let me preface by saying that I’ve been using HA for a couple of years, so I’m not exactly a novice, but I’m by no means an advanced user. I’m trying to do something that I haven’t done before, using commands I’ve never used before, and apparently I’m not smart enough to figure it out, even though it seems like a very simple thing.
All I’m trying to do is send a URL to Tasker (with the AutoRemote plugin) to trigger a notification on my phone. I’ve tried Shell Commands, Command line Switches, RESTful commands and switches, but the documentation on almost all of these don’t show example automations, so while I can successfully add the switches/commands to my config, I’m not sure how to call them from an automation.
The closest I've been able to come is by RESTful Command. I've added a test to my config:
rest_command:
garage_door_off:
url: !secret ar_off_url
method: POST
headers:
authorization: !secret ar_token
I can call this service using the developers tools, and it works fine. It works with or without the headers. However, if I try to add this as an action to an automation it doesn’t work.
The documenation on the RESTful command is one of the few that have an example automation. This is the Action snippet.
action:
- service: rest_command.my_request
data:
status: "At Work"
emoji: ":calendar:"
Seems easy, but when I create a comparable automation, it doesn’t work because it’s looking for a switch??
action:
- alias: HS100
data:
entity_id: switch.garage_door
service: switch.turn_on
- data:
status:
service: rest_command.door_on
(built in automation formatting there) I get this error:
Error while executing automation automation.away_garage_door_off. Service not found for call_service at pos 1: (ServiceNotFound(…), ‘Service switch.door_on not found’)
Why is it looking for this switch? I have created three different switch types with similar names during my experimentation, but I don’t understand why the rest_command works fine when using the developer tool, but causes this error when used in an automation. (especially when I’m copying the example included in the documentation…)
Other switches I’ve added to my config for testing:
shell_command:
door_on: 'curl -X POST autoremoteurl
This sends, but causes AutoRemote to error or even crash. I’ve also tried double quotes instead of the single and it makes no difference.
switch:
- platform: command_line
switches:
gdoor_off:
command_on: 'curl -X POST autoremoteurl
This one doesn’t throw an error when calling the service, but it isn’t sent to my phone either…
switch:
- platform: rest
name: door_on
resource: autoremoteurl
body_on: true
body_off: false
This one is pretty bizarre, because immediately after being added to my config, it just continually spams the URL ever 10-15 seconds. So I guess you could say that it works, but I definitely don’t think it should keep sending just by being included in the config.
So does anybody know what I’m doing wrong? Surely just sending a URL from HA isn’t as difficult as I’m apparently making it. If you know an easier way, or just know how to make the RESTful method work from an automation, please let me know.
Any help is appreciated!
Edit: Formatting.