SENDING webhooks

Similar situation here…
I need to trigger some macros in MacroDroid app and can’t find a way to send the webhooks from HA.
I hope there is something new about this!

1 Like

Sure! Figured it out.

Edit your configuration.yaml to have a line like this

rest_command:
example_request:
url: “https://yourwebhooklink

Then go into automations. Select a trigger. Then in actions select call service. Put rest_command.example_request in the line there. Obviously name it what you want rather than example request in both the config and automation.

Thank you!
I just tested it, the code seems fine both at configuration.yaml and automations.yaml (after adjusting indentation and copying the URL generated by MacroDroid), but the macro at MacroDroid did not start. It is a simple macro, just starting an app to test the webhook. The automation debugging says that the rest_command was executed…
Do you know any simple way to test if my HA is actually sending the webhook?

Home Assistant app can also launch apps using the intents.
Perhaps that is an easier setup?

@Hellis81 Maybe… Can it perform actions within the app? (e.g. press buttons in the app)
I have no idea how to use intents. Googled it for a while, but did not find anything I could understand/apply. If you have any links showing how to do it, I would be interested in trying.
I considered using MacroDroid with ClickMate, but if HA app can do the job, it would be even better.
MacroDroid is working fine - if I paste the webhook to a web browser, it opens the app. I think the issue is on HA, as even triggering the automation manually does not start the app, so I assume it is not sending the webhook.

I’m far from an expert on this but intents are (as I have understood it) kind of like you tell the phone to do something or an app can say “I did this” and everyone else can listen and say “Ok”…

If the app has an intent for this button to be pressed then it should be possible to “push” the button from HA.
The issue is to find what the command is. There is a listener in the app that can help you or you can google for “intents [app name]”.

If you get it to work, don’t forget to share your finding/work Android Intents - Sending & Receiving List (Starting Activities too!)

Thanks!
I will have a look at that and share my results. Hopefully this app can listen to intents from HA.

I just remembered a third way.
You download the apk file, either from your phone via apk extractor apps or you google for the apk file.
You are not going to run the file so you don’t need to be picky about the page you find the apk on.
Then there are online services where you upload a apk and it will return all intent listeners and broadcasts the app has

I got my apk file, found the online service you mention (comdroid from UC-Berkeley), but that’s weird… Their link leads to a kind of commercial painting site. I wrote to the developer asking where would the application be hosted currently. Still waiting for an answer.
Meanwhile, searched for other ways to find these intents, but what I found is way beyond my understanding (like decompiling the code, finding manifests…)
The app I’m trying to control is MagicHome

So, back to the previous strategy (while waiting for the developer of Comdroid),
Any possible explanation for the webhook not being sent from HA?

My configuration.yaml looks like this:

rest_command:
  example_webhook_request:
    url: “https://tinyurl.com/yen73x5o/w1”

and the automation :

- id: '1619231621690'
  alias: webhook to macrodroid test
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.condition_t
    to: 'on'
  condition: []
  action:
  - service: rest_command.example_webhook_request
  mode: single

rest_command:
  example_request:
    url: "https://URL"

alias: Webhook Test
description: ''
trigger:
  - platform: device
    type: turned_on
    device_id: 12345
    entity_id: switch.basement_filter
    domain: switch
condition: []
action:
  - service: rest_command.example_request
mode: single

That format above works for me. The only thing I can think of is that you have an issue with formatting or your trigger is bad.

action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.alarm_system_active

Looking at an automation that I use input_boolean (this was an action, not a trigger), I would check to see if that’s the way it works.

Also I belive it sends a get…make sure your webhook wants that. I had problems sending it to smartthings. When I send it to my ngrok it works fine.

@vondalej Thanks a lot! As you suggested, formatting was the issue.
Little details, big difference…
It was the character used for double qoutes around the url.

url: “https://URL”

versus

url: "https://URL"

I pasted it from the original software and did not notice the different characters. Now the macro starts, and my next struggle is on the MacroDroid blog, as it seems to work only if the phone is unlocked.

@Hellis81 As I’m still struggling with the control of an app, Intents are still in the game.
The developer of Comdroid replied and he dropped the project, the software is no longer available. I tried digging deeper, to find something that could tell me to what Intents MagicHome would listen.
I could open the AndroidManifest.xml for that app, and found only the following information about the intents:


I don’t know exactly how to work with intents, but it seems that it just allows to launch the app, configure and refresh the widget.

Would you have any interesting insight based on that?

You are probably right.
It seems there is nothing to control the app.
What exactly are you trying to do? What is this app and what is the app supposed to do?

Hi, I cannot get this to work, would love to be able to send a webhook straight from ha, please help. I have used the same method you have

So couple things. You need to add this to your configuaration.yaml

rest_command:
example_request:
url: “https://WEBHOOKEXAMPLE

You then create an automation using the function “Call Service”

rest_command.example_request

I have a webhook URL that can pass a variable. I want to add the variable to the URL using a template in the automation — is there a way to dynamically change the webhook URL when the automation triggers?

erm… not clear if you want to send a webhook from HA or to HA…

anyway,
When sending a webhook to HA, you can pass data in json format…

f.e:

trigger:
  - platform: webhook
    webhook_id: Fullfilment_Order_Shopify
  condition:
    - condition: template
      value_template: "{{ trigger.json.tracking_company == 'UPS' }}"