Home Assistant Webhooks, Time pattern Automation Triggers, and some Timestamp Math
Вставка
- Опубліковано 30 лип 2024
- In this video, we are going to build a Home Assistant remote monitoring system to notify me if my brother's Home Assistant instance goes down.
To make that happen we are going to use a web hook. So if you are interested in how to get started with web hooks this video will walk you through creating a web hook and using it to trigger a Home Assistant automation.
We will also talk about time pattern automation triggers, triggering an automation on Home Assistant startup, and even everyone's favorite timestamp math.
So if any of that is interesting to you, check it out.
Chapters:
00:00 - Home Assistant Webhooks, Time pattern Automation Triggers, and some Timestamp Math - Intro
01:51 - What is a Home Assistant Web Hook
04:23 - A Remote Monitoring Use Case
06:22 - Build a Home Assistant automation with a webhook trigger
07:39 - Formatting Home Assistant Timestamps
08:52 - Find the difference between two timestamps in Home Assistant
10:37 - Defining a Rest Command in Home Assistant
11:21 - Build a Home Assistant Automation with a time pattern trigger
Blog Post with YAML: slacker-labs.com/2021/08/28/h...
#homeassistant #smarthome #homeautomation
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
.
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... - Наука та технологія
The home assistant teacher! You rock jeff!
Another awesome video. There's always so much good information in your videos. Sitting here watching you video on webhooks...while I've been thinking about trying to fix my automations that "break" if I reboot Home Assistant. You've given me some good ideas and guidance on how to fix these situations. So many tips...and so may use cases!
Great Job, this has given me some ideas on a project of mine. And, I'll be reviewing your other video's to see what else I can gather from them. Thanks, very clear concise and in good order!
Great tip on the /30 thank you!
Hmm, one year ago I watched this for the first time. Again, thanks. Great example, clear and simple. OH, I see there are other Webhooks vid's you've created. "Webhooks: The Universal Home Assistant Integration" Onward bound.
Yeah, those web hooks come in handy. There was an update to them earlier this year, that adds some security options, so check out the video I did a few months back.
Your videos are simple and to the point. Subbed ✊🏻
Thanks! The struggle to keep it simple is real. Heck. I just scraped a video on how I setup my version of JARVIS because during the edit I realized it was going to be way too complicated and impossible to follow.
@@SlackerLabs I completely agree . Keeping it simple is very challenging. Keep up the good work
webhooks are extremely simple by installing the Cloudflared solution for remote access. Also, i was able to use Tasker on Android to fire off a webhook to HA, your video is another step to not only automating but also connecting :)
I need to take a look at that cloudflarered setup. I glanced at it the other day and thought it might be useful.
@@SlackerLabs 5 minutes setup, create domain on cloudflare, install on HA and three lines in config.yaml. Done!
Great video. I've been working on something broader to identify home automation problems in my home. I had to sit down and create a list of services and systems. You don't realize how complicated your home automation is till you've done that. 😂
Yea. It’s nuts. I was working on something the other day and noticed a temp sensor that hadn’t updated in weeks. Found out it’s battery had died. So now I’m trying to figure out how to get Jarvis to give me a list of sensors that haven’t sent an updated in more than 24 hours
@@SlackerLabs I just had the exact same issue! lol
Great video on webhooks. I did this exact monitoring of another home assistant instance but took a different approach. I created a date_time sensor on the machine to be monitored, then created a rest sensor on the monitoring machine looking at the rest url of the date_time sensor. This removes the need for webhook or interval update automation. Then i used a template trigger in an automation to compare the time now to that of the rest sensor and notify if greater than 10 minutes difference.
I like it. Definitely less complex. I will give it a try!
@@SlackerLabs The only downside is it does update quite frequently when not strictly neccessary.
@@SlackerLabs It also works great to automate guest mode when some of my relatives with homeassistant visit my house. I created a zone on their instance which covers my house, then i used a rest sensor to monitor their person status and turn on guestmode if at my house.
@@simonparkis9301 Genius! I was monitoring nmap for their mac address of their device. But I like this method. More "active" than scanning for ip addys.
If you do a more general web hooks video, it would be interesting to know if it is possible to pass data into the web hook (in the POST request), and get at that data from within the automation.
I have started working on another video and will be able to show exactly that. Hoping to have a couple of use cases to talk through.
Thank you very much for your webhook and rest.
I wonder if it possible to use this trick to make use of asking google mini with voice and let home assistant answer in verbal. If it can be done, could you please make this guide vdo. Thank you very much in advance.
Thanks! And yes, it is possible. Actually, I talk about it in a couple of videos and show some examples of it working, although I can't remember if I walk through it. I will work on that video. I actually was going to do one about local audio so this will fit in.
Anyway you could make a blueprint for this? Thanks
How do you use webhooks if the HA url in my instance is DYNDNS enabled ( DuckDNS) and SSL secured with LetsEncrypt ? If the required port is 80, how is that port forwarded because HA now listens on port 443 ? Thx
Is the required port 80? I don't think I have run into that. I think you just have to hit the url for the instance. The https one works in my last test. But let me check. I am not running the latest version so maybe something changed.
Could this work with integrating web apps for habit tracking like Done or Way of Life into Home Assistant?
Yes, although I suspect the best way would be using the shortcuts app. At least if those apps allow you to get to the data you via the short cuts app. I couldn't tell if those apps had a web app or a way to configure a webhook to publish data from those apps to another app, so your chance of integrating my be limited to how much those apps let you have in shortcuts.
If those apps integrate with IFTTT you could perhaps use that as well to make the connect to a Home Assistant Webhook.
No, you talk without thinking someone has not set up some features...
Which features are you referring? I want to make sure I make things clearer as I make more videos.
What's the best way to debug webhook ? I successfully call this : GET [homeassistant]/api/config but this POST [homeassistant]/api/webhook/button1 doesn't work, result is an 404 error ? I found him in my automation file.
- id: '1670691760272'
alias: automation
description: ''
trigger:
- platform: webhook
webhook_id: button1
I find the best way is using a command tool like curl. From there you could do something like:
curl -X POST -H 'Content-Type: application/json' -d '{"content":"test"}' [homeassistant]/api/webhook/button1
and see if that works. 404 error, means it can get to that though to that server. That the get can makes me think some kind of filter on http methods. Like get is allowed but post is not.