Condition: Specific people

Hi to all

I have created the following automation that works perfectly:

‘’’
alias: NCF - Apertura Porta Uffici 1 - Esterna
description: ‘’
trigger:

  • platform: tag
    tag_id: xxxxxxxxxx
    condition: []
    action:
  • type: turn_on
    device_id: xxxxxxxxxx
    entity_id: switch.uffici1
    domain: switch
    mode: single

‘’’
Basically it opens a door for me to scan an nfc tag.

I would need to enter a condition that only people belonging to a specific group are allowed to do this.

How can I do ?
Thank you

You could use context
See:
context
your.homeassistant.ip:8123/config/users

E.g.
```

condition:
- condition: template
value_template: >
{{ trigger.to_state.context.user_id == ‘1deabc87f15b4c4aa8d4bfca1ec2f663’ or
trigger.to_state.context.user_id == ‘2ceabc66h15b4c4aa8d4bfca1ec2f663’ or
trigger.to_state.context.user_id == ‘3ceabc27p97b4c4aa8d4bfca1ec2f663’
}}


EDIT: Not working with tags

How are you specifying the groups? Based on tags? Keep in mind that when you scan a tag, it has no concept of who is using the tag.

Yes, unfortunately I noticed that the log does not specify who used the tag.

I have created a very simple group like this:
‘’’
Group:
test:
entities:
- person.massimo_pistone
‘’’

I am just starting out.
You advise me

The only way home assistant knows about people is based on who is logged in when using the item through the UI. Otherwise, HA has no context of who is using what. So there really is no starting point unless you assign tags to people and assume the people are using the tag that is assigned to them.

I understand…
And can a TAG be assigned to a group?

You can create input selects with tag ids

Can you give me an example?
Thank you

Open up your helpers, place the tag id inside a input_select via the UI. Same way as creating an input_boolean, just has different inputs. Or you can use yaml to define your input select

1 Like