Hi, I have 3 different readers built with the Adonno project. I would like to use the same tag-id to open different ports based on the reader reading it.
I found this workaround using the reader led in the conditions, but I don’t really like it as a solution.
- id: 'xxxxx'
alias: TAG READER PORTA UFFICI INTERNA
description: Lettore Cassettina Chiavi
trigger:
- platform: tag
tag_id: FD-20-D8-3F
- platform: tag
tag_id: 96-12-EF-D4
- platform: tag
tag_id: E1-7D-83-1C
condition:
- condition: device
type: is_on
device_id: 8814a592d1a4d55db88700240e579ee9
entity_id: light.tagreader_led_3
domain: light
action:
- service: switch.toggle
data: {}
target:
entity_id: switch.uffici2
enabled: true
mode: single
I’ve tried with variables, like in the example below, but it doesn’t work
- id: 'xxxxxxx'
alias: TEST TEST
description: Lettore Cassettina Chiavi
max_exceeded: silent
variables:
device_id: d7d19ee18e89f2cfa7cf5a2815a1e7b1
trigger:
- platform: tag
tag_id: FD-20-D8-3F
- platform: tag
tag_id: 96-12-EF-D4
- platform: tag
tag_id: E1-7D-83-1C
condition:
- '{{ trigger.event.data.tag_id in trigger }}'
- '{{ trigger.event.data.device_id in variables }}'
action:
- service: switch.toggle
data: {}
target:
entity_id: switch.sonoff_xxxxx
mode: single
i think this can work if you use an event type trigger (tag_scanned)
something like this
trigger:
- platform: event
event_type: tag_scanned
condition: []
action:
- if:
- condition: template
value_template: >-
{{ trigger.event.data.tag_id in trigger }}= 'device id from device you
want'
then:
- type: turn_on
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
entity_id: switch.xxxxx
domain: switch
i am currently not at home, so i cant check, but i will see later as i am in the proces of building automations through my nfc readers and will need this aswell.
i will do some looking around probably tonight and will post progress here…
but using the IF condition on the device_id triggering the scan seems like the way to go to me
It’s easy enough, seems this this is a standard function: Automation Trigger - Home Assistant (home-assistant.io)
just been testing this, works like a charm for my use case (same action in different rooms depending on what tag gets scanned in which room)
so in your case this would become something like this:
- id: 'xxxxx'
alias: TAG READER PORTA UFFICI INTERNA
description: Lettore Cassettina Chiavi
trigger:
- platform: tag
tag_id:
- "FD-20-D8-3F"
- "96-12-EF-D4"
- "E1-7D-83-1C"
device_id:
- "8814a592d1a4d55db88700240e579ee9"
condition: []
action:
- service: switch.toggle
data: {}
target:
entity_id: switch.uffici2
mode: single
Same here mate, i guess that the thing with Home Assistant, sometimes you expect it to be difficult. Tuth be told, there is so much possible it’s sometimes easy to miss how simple things can be.
glad to hear i could help someone for once
Feel free to tag that post as ‘answer’ it help people navigating through the forums to find answers…