I’m trying to have a card, that when clicked triggers an automation that starts a PC. However the PC started should be relative to the user who clicked the card. It’s not about starting the PC, that one works. It’s about getting the template to find out which user pressed the button. My problem is that it always returns true even if I check for a username that I (the tester) don’t have. (My username is Jo not “name”). For refrence I have a picture of the automation testing telling me “true”, wich is the green text (gerrman for “condition true”).
Ok I apologise.
Here is my code again just this time labeled as a yaml code
However I still didn’t quite get your “missing trigger” point. I don’t want the automation to go off with a trigger. I want the automation to trigger with a card action, therefore I don’t know what trigger to use. Action part:
It doesn’t work because it’s now a script, not an automation, and scripts don’t have triggers, only automations have triggers, so the trigger variable is always undefined in a script.
The fact is you can only determine context.user_id from the trigger variable, which exists exclusively in an automation that has been triggered by one of its triggers. So far, nothing you have created meets those requirements.
FWIW, I may be wrong but I don’t think you can determine who pressed a standard-issue Button card. You can determine who pressed an Input Button.
Note, .user_id is not a name, but the ID (in my case c4321b2f12e24d599b2e2c5dd08abddd).
You can find your ID by opening the user in http://[my.HA.add.ress]:8123/config/users
PS: There is no need for if/then as it is the nature of a condition that it must be true in order to continue the automation