I’ve checked a few topics with similarities, but I can’t seem to get my head around it properly.
context:
1 garagedoor, shown as cover in HA
4 users, all tracked for being home or not.
I want:
1 button in the UI that opens de garage door, but only if the user that clicks the button is state ‘at home’.
I’ve first of all problem with what approach would make most sense:
script or automation. As it is a button, i would suppose script does the job.
then next, how to make the script use a template to retrieve the users ‘home state’. I really struggle with attributes that only exist in the script context (and hence not accessible in devtools/templates)
how would i use something like states.script.garage_auth_open.context.user_id in this script to match the home state for that person?
Great idea. Look at the users. They would be “home” or “away”.
My cover object is always available in the UI - and the only triggers I can see are those that are from the position of the cover that is reported. So when the “cover” button is clicked I have no way of intercepting the action of it starting to open or close the door (and who clicked it). So, in my case I’ve got to add logic with an ‘unrelated’ automation that just disables the cover object if nobody is home and then once any of us are home, to re-enable the cover in the UI. I wish there was a cleaner way of doing this (I could just hide the cover object n the UI and use buttons that call it (only if someone is home) but that seems like a lame workaround)…
I’m not sure that you can programmatically get ahold of who pushed a button and use that information in an automation or script, so that would be the first hurdle.
Off the top of my head, the way I would handle this would be to create different views with the garage door “button” on each, and limit visibility to only that user.
When the button is pressed, it triggers an automation that only runs if that user is home, and the automation then operates the garage door.
this seems to return the state, didnt expect that.
Still dont know how to get it compared to ‘home’ value in template as its just a string now. I’m so bad in this syntax and cant seem to find samples for it
I think one of the original points here is being lost. When the cover object arrow is pressed in the UI, there is no way to insert any condition logic to stop the action of the cover opening to be thwarted. Is there?
Well , i kinda knew that would be reacting on events and stopping the action. That would cause the door be slightly opened and need to close again. That’s something I would not want to put to the doors engine. Hence a seperate UI button is the only way for now.
HA would need an authorisation scheme/security mechanism to make this possible