Is webhooks the right answer for multi-garage door automation?

Problem Statement:

I have multi garage doors with different cars in each. I would like for HA to remember which garage door was opened and then closed and who was then marked away, so then upon return it opens the correct door for that person.

Scenerio example:

Wife leaves from garage 1, gone all day, wife returns, home automatically triggers garage 1.

I cant get my head around the configuration of trigger templates / webhooks.

I think I want to create an automation:

Upon garage door opening and closing within 5 minutes, POST who left to a webhook and which garage door (have life360 tracker).

Upon person arrival, check webhook, match person and Door, Open correct Garage door.

I haven’t found how to set this up in a basic enough fashion or I am missing the starting point. 5-6 years ago i was pretty proficient in powershell, but i would consider myself basic at this point when it comes to actual scripting.

If there are some examples that can walk me through getting the bones of this setup, i can trail and error my way forward. Just want to make sure the thought process makes sense and I am not over engineering this.

Events can be given IDs

When automation is triggered you can use

If ID1
Then do xx

You will use device status of phone as the event and provide separate IDs for each. Use that to determine which garage open

If iD_wifephone
Then open garage north

Refer to ID in automations docs

So if the garage Door 1 opens and wife_phone leaves within XX minutes, then store ID1. When wife_phone returns, lookup if IDX exists, then do action?

She is the easy example.

My tough one is me. I will leave with one of 3 cars. I need it to track what i do and then respond in kind, so with this, i guess i can assign a specific ID to each of my scenerios and then have it respond properly, but can I dynamically build the inout and output?

No

When she arrives the device will trigger the automation and the device will have a specified ID.

That ID can be used to trigger a specific door to open.

Typically, the way to save state (e.g., which door opened when a person left) is via a text helper. You can use a service (um, I guess I should say “action” now) to change its value. And then you can read its state later.

Yes, an automation is the way to, well, automate things. :slight_smile: In your use case, it will probably take at least two automations. One to record which door a person used when they left, and then another one to open that door when they arrive back home.

However, it’s a bit more complex than it might sound on the surface, since the automation really needs to use two “events” that happen at different times - i.e., a door opening, and a person leaving. If you try to trigger the automation when the door opens, the person hasn’t left yet. If you wait until the person leaves (i.e., their person or device_tracker entity changes to away, aka not_home), the door may have already closed. Or consider if two people leave at about the same time, where multiple doors are opening/closing and multiple person/device_tracker entities are changing state.

Let’s assume only one person leaves at a time, and the door they leave through is closed by the time another person leaves. The way I would approach it is to trigger the first automation when the person/device_tracker changes to away/not_home. (Actually, I would trigger on the state changing from home to something else. We’ll also ignore the possible unknown or unavailable states, although a robust automation would take those states into account as well.) The action would be to save the door that changed state last to a text helper for that person. The other automation would trigger when the person/device_tracker changes to home, and the action would be to open the door as indicated by that person’s text helper.

That’s the basic idea. Again, getting an automation to do what you want under perfect conditions (e.g., only one person leaves at a time, none of the entities have unknown or unavailable states, HA doesn’t restart while an automatin is running, etc., etc.) is often fairly straightforward. Making them robust can sometimes be the difficult part. But, then again, that’s the way it always is in software development. :rofl:

If you’d like a concrete example of how to build such an automation, just let me know. Also, it would be helpful to know some of the details, like exactly which entities represent the doors and people.