teleoltre
(Teleoltre)
March 16, 2022, 8:39am
1
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
pedolsky
(Pedolsky)
March 16, 2022, 11:20am
2
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
petro
(Petro)
March 16, 2022, 12:01pm
3
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.
teleoltre
(Teleoltre)
March 16, 2022, 12:06pm
4
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
petro
(Petro)
March 16, 2022, 12:07pm
5
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.
teleoltre
(Teleoltre)
March 16, 2022, 12:11pm
6
I understand…
And can a TAG be assigned to a group?
petro
(Petro)
March 16, 2022, 12:12pm
7
You can create input selects with tag ids
teleoltre
(Teleoltre)
March 16, 2022, 12:18pm
8
Can you give me an example?
Thank you
petro
(Petro)
March 16, 2022, 12:20pm
9
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