Webhooks: The Universal Home Assistant Integration

Поділитися
Вставка
  • Опубліковано 10 лип 2024
  • This week we are diving deeper into the realm of Webhooks. Because they have the power to expand the reach of your smart home.
    With a webhook you can not only trigger an automation, but you can pass data to your #homeassistant powered #smarthome. Meaning if a service or a device can call a webhook you can integrate it into Home Assistant. Think of Webhooks as a Universal Translator for Smart Home Services.
    In this video we are going to walk through using iOS Shortcuts, and If this Than That (IFTTT), and we will touch on Zapier. And by the end of the video you will be able to harness the power of this simple built-in integration.
    Chapters:
    00:00 - Use Webhooks to Integrate Anything in Home Assistant - Intro
    01:38 - Using iOS Shortcuts to call a Home Assistant Webhook
    05:11 - Integrate any IFTTT Service into Home Assistant
    07:15 - Using IFTTT to call a Home Assistant Webhook
    Who am I?
    My Name is Jeff. I am an DIY-er and Automator of boring things. And, of course, a huge Home Assistant fan. Oh, I also live in a house that tweets.
    Follow Me:
    Github - github.com/thejeffreystone
    Twitter - / thejeffreystone / / slackerlabs
    On the Web - slacker-labs.com/
    And if you like this video you could always fuel my automation habit -
    One Time Donation:
    Paypal: www.paypal.com/paypalme/Slack...
    Cash App: $slackerlabs
    Buy me a coffee: www.buymeacoffee.com/icE6DeBut
    Buy a Slacker Labs T-shirt: slacker-labs.com/shop
    Or use my Amazon affiliate link which provides a small commission on things you buy without additional cost to you - www.amazon.com/s/ref=as_li_ss...
    Video Gear:
    Canon m50: amzn.to/3ftldPH
    Desk Mic: amzn.to/3wkum40
    Camera Mic: amzn.to/3tXk1cp
    Newer 660: amzn.to/3fwwejd
    Dazzne D50: amzn.to/3oGBK5y
    Audio Interface: amzn.to/3u07chK
    Gimble: amzn.to/3ouKAoe
    Music - Epidemic Sound: www.epidemicsound.com/referra...
    Video Assets - LenoFx: i.refs.cc/CJXU6Da9?smile_ref=e...
  • Наука та технологія

КОМЕНТАРІ • 56

  • @SmartHomeMakers
    @SmartHomeMakers 2 роки тому +3

    Great video and cool use case with the iOS we hook, got me thinking :)

  • @arkadianeu
    @arkadianeu Рік тому

    great tutorial, thanks for sharing Jeff.

  • @syukrishahabuddin4618
    @syukrishahabuddin4618 Рік тому

    Nice tutorial. I am using this to pass on a message input that would have either a notify or TTS or Assistant Relay command as action. I basically have a shortcuts button to prompt a notification to my wife, to broadcast TTS over nest mini and/or to trigger my smart devices using webhook through HA instead of linking an action to iOS shortcuts.

  • @BeardedTinker
    @BeardedTinker 2 роки тому +1

    Nice video Jeff!! Should use webhooks more in my setup! I think I use them only in Synology integration to get notified if it detects motion on cameras.

    • @SlackerLabs
      @SlackerLabs  2 роки тому +1

      I was thinking of that as well...at least I should use these more. They might be one of the killer features of Home Assistant in terms of getting weird stuff, and normal stuff, integrated that is.

  • @ofcorsin
    @ofcorsin 2 роки тому

    Very nice video, thanks! I can now toggle on and off my lights with my Kronaby Smartwatch (Watch is only IFTTT compatible and the lights are Home Assistant compatible)

  • @vPeteWalker
    @vPeteWalker 2 роки тому +7

    I don't use IOS or IFTTT, so I would have loved you to show off a method just using software on the PC (like Postman or Insomnia). Thank you!

    • @thejonte
      @thejonte Рік тому

      A bit late but you can just make a POST request to http(s)://YOURHASSIP:HASSPORT/api/webhook/YOURWEBHOOKID, example: localhost:8123/api/webook/helloworld or hass.foo.bar/api/webhook/helloworld

  • @russtuff
    @russtuff Рік тому +1

    This is exactly what I was looking for!
    How would you go about adding a condition based on what's in the JSON payload? I only want the action to take place if the message contains specific words, but nothing I've tried has worked.

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      I used it as a condition in a choose action, but the condition could be anywhere. Here is a link to it in my current config: github.com/thejeffreystone/homeassistant-config/blob/904d05feca6d6bf7745591a2ce31812ef8828d17/config/automations.yaml#L238

  • @theycallmeken
    @theycallmeken Рік тому

    Nice Splunk shirt !

  • @michaelsorensen7914
    @michaelsorensen7914 Рік тому

    Very helpful, thank you! Is there a way to store the "message" in a variable that can be displayed in a lovelace dashboard? I have a webhook sending a message that gets updated every minute. Hoping to have my dashboard text updated each time the webhook is updated.

    • @michaelsorensen7914
      @michaelsorensen7914 Рік тому

      Nevermind - just figured it out. Created a "helper" for text, and used the automation to assign the text from the webhook to the helper. Then, used an 'entity card' in the lovelace dashboard and chose my new helper as the entity. Thank you!

    • @SlackerLabs
      @SlackerLabs  Рік тому

      Prolly the best way. Since it wouldn’t really be persistent. But sometimes you might get away with a markdown card and just some jinja like {{ message }}

  • @enricodalonzo7268
    @enricodalonzo7268 2 роки тому +1

    Great video! Do you know how to send back a message from home assistant to the webhook sender? I am trying to connect google actions to home assistant via node red. I am able to send webhook to home assistant but not to reply.

    • @SlackerLabs
      @SlackerLabs  2 роки тому +1

      I dont think there is a way to do that. At least not back to the source that called the webhook. I dont think Home Assistant has any awareness of who triggered the webhook by default. You could add another entity that is passed that contains a webhook to replay to, and then use the rest action to call that entity. I'll have to look to see if there is another way. But I dont think it keeps the connection open for a reply. Post and then done.

  • @kodeypatterson8973
    @kodeypatterson8973 2 роки тому

    Just discovered this as well.. Love the video but lost me when you went into IFTT

  • @aaronp74
    @aaronp74 2 роки тому

    can you fo a video on sending a webhook from home assistant as an action

  • @edgardaraujosantos
    @edgardaraujosantos Рік тому

    Hello. Excellent video! I'm trying to do something and running into a problem that I don't know is some limitation of IFTTT with HA. I'm trying to make an applet that when I receive a push notification from a specific application and that contains specific words, make HA receive this event and I want to trigger a message by alexa media notify informing what the push message is. The applet is running normally, and the message is in the log, but the HA is only executing the trigger if I just keep the call service in the body section, if I add a variable to pass the message, or use the service and the entity id to update an input_text, automation in HA does not run. Any suggestion on how to do this?

    • @SlackerLabs
      @SlackerLabs  Рік тому

      I'm not sure I follow the automation design on the Home Assistant side. But you may need to make sure that you are passing that message contents to the automation using something like {{ trigger.json.message }} which should print the contents of that message from IFTTT. I typically use IFTTT to call a single web hook, and embed something like event in the json passed t the web hook. Then the automation simply tiggers based on the web hook. Then in the action use the choose action and setup options to watch for specific event values using the template condition so I could do something based on what ever was in the json. Like this gist.github.com/thejeffreystone/61bc6d7abf7df89a309ab3be7fbf0b63

  • @PrimalDashes
    @PrimalDashes 9 місяців тому

    'After some crude remarks about it's intimate relationship with it's mother..." sounds like me with issues too lol

  • @federicos9821
    @federicos9821 Рік тому +1

    My webhooks automation triggered by external nabu url works whenever it wants, it’s not reliable at all, is that normal? I’m doing exactly as in your video and running the nabu URL in shortcuts 😟

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      Oh that's not good. I haven't seen any issues with mine. I used an IFTTT one for a solid month working on a video and it worked more reliably that than the SwitchBot integration. Then they improved bluetooth and I dropped the web hook.

  • @zavianthomas8339
    @zavianthomas8339 2 роки тому

    Do you have an example of what the domain name for the url looks like?
    Or the entire url?

    • @SlackerLabs
      @SlackerLabs  2 роки тому

      Yes. It will look something like ha.duckdns.org/api/webhook/send_a_message of if you are local only 192.168.1.159:8123/api/webhook/send_a_message But the domain will be the domain or IP of your Home Assistant instance.

  • @Mr-Coke
    @Mr-Coke 6 місяців тому

    Hello, very nice video. Can you send a post command from homeassistant to a webhook from a other service too? with a specified message in it?

  • @poweringindependence
    @poweringindependence Рік тому +1

    Maybe i'm missing something. But this video is about using webhooks as a trigger for home assistant automation. Can you also use it the other way around?
    Let Homeassistant send a webhook to Zapier? So for instance. If my garbage container is full i can scan the NFC tag connected to home assistant and it will send a webhook to Zapier, and Zapier will send a email through Gmail to the garbage company asking them to empty the container? This is what i'm looking for.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      Sure. You can use the rest integration as an action and post data to a webhook. I haven’t done that with zapier. But I have with ifttt.

  • @kerbalette156
    @kerbalette156 2 роки тому

    What’s the security implications for allowing an outside untrusted device to run any automation/device action?

    • @SlackerLabs
      @SlackerLabs  Рік тому

      I think that depends on the automation. I wouldn't run any security based automation unless you built in a way to pass a pin code or some key that isn't stored anywhere and could be verified by home assistant. That gets a little more complicated. But you should definitely make sure that you are comfortable with any risk when using webhooks.

  • @Mr-Coke
    @Mr-Coke 5 місяців тому +1

    Hello, i want to use an webhook to lets talk alexa a message. This works fine, but can i set an command that alexa is speaking the text which i send in the post message?

    • @SlackerLabs
      @SlackerLabs  5 місяців тому +1

      Sure. The Simon says command does that. And I think you could do that through a webhook. But the Alexa Media player integration in the home assistant community store makes that real easy using a notification service. You can also easily trigger routines using that integration as well or issue voice commands with just text.

    • @Mr-Coke
      @Mr-Coke 5 місяців тому

      @@SlackerLabs so youre opinion is several webhooks with specified messages via Automation trigger and alexa Media Player?

    • @SlackerLabs
      @SlackerLabs  5 місяців тому +1

      You could do either. The integration uses the same api. Just makes the service calls more standard. So it comes down to preference. If you want to do the calls to the Alexa api yourself you could do that. The rest_command service would allow you to call a webhook and pass data to it. I have never done it that way. But I do send a lot of text to speech notifications to amazon Alexa to say using the Alexa media player integration.

    • @Mr-Coke
      @Mr-Coke 5 місяців тому

      @@SlackerLabs ah okay. I mean a other Thing. I try to explain it better. I am using tradingview. Its a trading Software where you can send Alarms as a webhook to an Broker for example. Now I am sending only a empty post to the webhook url from homeassistant. And with that webhook I am using the alexa Media Action to let alexa say breakout by BTC for example. But I always must make an several webhook for each message. The idea is to send a postmessage with the Text in it what alexa should say. Direktly to homeassistant.

  • @bgstephenson
    @bgstephenson 2 роки тому +1

    Have you done a video on your iOS shortcuts?

    • @SlackerLabs
      @SlackerLabs  2 роки тому +2

      I have not done one on iOS shortcuts, but I have used them in the past. And I totally didn't have that idea on my list...but I do now..

    • @bgstephenson
      @bgstephenson 2 роки тому

      @@SlackerLabs thanks! I recently found your Chanel and I have been really enjoying it.

  • @waynenocton
    @waynenocton Рік тому +1

    I just can’t follow the JSON stuff, anyone know of a reasonably priced online class where I can learn this stuff?

    • @SlackerLabs
      @SlackerLabs  Рік тому +1

      I'm not sure this one is perfect for everyone, but I used www.w3schools.com/js/js_json_intro.asp when I needed to get up to speed on json. Honestly I am not that well versed. Just know enough to leverage it in python.

    • @waynenocton
      @waynenocton Рік тому

      @@SlackerLabs awesome thanks, watching your latest templating video now, it’s very good too!

  • @JayR_aus
    @JayR_aus Рік тому

    How do I use an attribute in a webhook payload to trigger when the attribute changes? I have a device that sends a webhook payload to Home Assistant with a payload showing the status of my front door lock. I only figured out how to get the automation to trigger when it receives the payload, but I need it to read a specific attribute and then trigger IF that attribute goes from "LOCKED" to "UNLOCKED". I'm thinking to create a custom entity and use some kind of code to grab the attribute and update the entity when HA receives the webhook, then use an Automation to trigger when the entity changes, but I cannot figure out how to do this. Help ? Thanks. :)

    • @SlackerLabs
      @SlackerLabs  Рік тому

      You could do this a couple of ways. If you want to trigger on the state change, then you will probably need to setup a helper that can hold the current state, or last known state. Home Assistant wont have any awareness of the previous state without that.
      I typically just trigger on receiving the webhook and then use the choose action to determine what to do based on the value passed in the webhook. Like this: gist.github.com/thejeffreystone/00b18b50c2e3fe8d1b1e2a2b696f3aa1

    • @JayR_aus
      @JayR_aus Рік тому

      @@SlackerLabs That looks easy enough. However, where is the state being written to?

    • @SlackerLabs
      @SlackerLabs  Рік тому

      @@JayR_aus it’s not. It’s passed in the webhook. But not stored unless you have an automation to take that value and store it somewhere. So it exists in the data passed to the automation. But as far as I know it’s not stored in any permanent place.

    • @JayR_aus
      @JayR_aus Рік тому

      @@SlackerLabs That's exactly what I'm trying to do. The lock will send the unlocked status to the webhook via the payload, then I want an automation that detects the change to unlocked and action something from that. I created an entity using templates, but I can't figure out how to manually change the state of an entity based on the webhook payload attribute.

    • @SlackerLabs
      @SlackerLabs  Рік тому

      @@JayR_aus I am not sure the template entity will hold the value without it being stored someplace else. Ive use an input text /select or even input_boolean, something else that will hold the state. In that case in that automation I linked under the sequence section you just have a call_service that calls the appropriate service to update the entity. Something like gist.github.com/thejeffreystone/00b18b50c2e3fe8d1b1e2a2b696f3aa1#file-gistfile1-txt-L8 but it would dependent on the helper you wanted to update. I dont think you will be able to use a template in that way.

  • @fredericfarjon5013
    @fredericfarjon5013 2 роки тому +2

    Shouldn't it be "If this ... Then that" ? Vs. "Than that"
    (Or maybe that was a pun I missed)

    • @SlackerLabs
      @SlackerLabs  2 роки тому

      Nope. You are right. Hopefully everyone will understand what I meant.

    • @fredericfarjon5013
      @fredericfarjon5013 2 роки тому +1

      @@SlackerLabs Sure :-) - Even the French dude writing this comment did ;-)

  • @TrillasAdventures
    @TrillasAdventures 2 роки тому

    i keep getting a 404 error that drives me crazy yet i can access remotely no problem

    • @SlackerLabs
      @SlackerLabs  Рік тому

      That makes me think the webhook isn't active or something is blocking it on the router side. If you can call the webhook from another device on the local network using the home assistant ip address the issue may be the router or the ssl config.

  • @KennethWill-jb6ox
    @KennethWill-jb6ox 7 місяців тому +1

    How do you go about giving someone a weblink. When they visit that weblink, it turns on one of my lights? I've got the HA part, but not sure which weblink to give them. I get lost on the post method part. I keep seeing that you can't trigger from a browser, but it's clear that there is a way, as I've seen people do it.

    • @SlackerLabs
      @SlackerLabs  6 місяців тому

      Yeah, Home Assistant added the ability to trigger a web hook based on the get method. I did a video about the changes, can't remember if I talked about the get option. But in the automation UI, there is a cog in the web hook trigger option, and you can tell it to rigger on get. then if you give people the URL for that web hook, they could just open that link in a browser and it will trigger your automation.

  • @gkchimzz28
    @gkchimzz28 2 роки тому

    :)