Is it possible to trigger an action with a URL/link?

Hi, I want to know if it is possible to trigger a action by pressing a URL to trigger a action.

For example, I trigger a notification with PushOver that contains a link. Pressing this link triggers my action. I can choose not to trigger the action by ignoring the notification.

Take a look here: https://home-assistant.io/developers/rest_api/#post-apiservicesltdomainltservice

Feel free to ask if you need more info :slight_smile:

~Cheers

Thanks for your answer! I did successfully trigger this url using CURL in Terminal
http://localhost/api/services/switch/turn_off?entity_id=switch.coffee_switch&api_password=XXX

But can I trigger this from safari in iOS? It gives me HTTP response 405.

Hey,
the Actionable Notifications might be excatly what you want.
Best regards

I am terribly sorry. I totally blanked out there. You can’t at the moment start an action with a simple link. That is because your browser makes a HTTP GET request. But the API for domains and services only allows POST requests.

~Cheers

Can’t you do this with HTML5 Notifications though?

I don’t know about HTML5 notifications. Maybe it’s possible but as he mentioned he’s using PushOver for notifications and with that I don’t see any solution. Except maybe using an external service like http://get-to-post.nickj.org/ or this http://gettopost.altervista.org/ BUT this would include you exposing your API password to a third party! Therefor I do NOT recommend this.

~Cheers

Maybe you can create a local HTML document that performs the POST, using javascript:

1 Like

Thanks guys. I think I will use the HA iOS app and use it notifications as suggested by juka.

This is what i did:

The use case I am interested is providing a link to tradesmen to (say) open my garage door. A JWT that expires in 24 hours would be ideal. I guess if HA only responds to posts, one could create another page (outside of HA) that uses the provided token in an AJAX POST.

Has any one tried this?

2 Likes

Now that I’ve read the API documentation you couldn’t use AJAX as your password would be in cleartext in the JS - so you’d have to do it with some server side code

1 Like

I realize this is quite old an thread, but I couldn’t find any more recent info. I’ve done a crude php script that interacts directly with a ESPHome node as my HA setup is still on the thinking stage.

my ESPHome node only needs one trigger to pulse the relay for the programmed 3500ms and release automatically, but the curl call could trigger anything including HA API.

I’d love to see something more integrated in the interface for generating tokens and templates for sending them via email or even text, copy/paste at a minimum.

2 Likes

I would really like to see a feature like this in HA.

I also need such a feature.
The use case for me is:

  • Make an shortcut to the url on alexas silk browser
  • the url should wake the emby server and redirect to emby

Is something possible in 2022? :slight_smile: