RFID RC522 / HA Tag / Know where the tag was scanned

Hi,
i´m just moving my node-red based smart home to HA + nodeRed + ESPhome.
I run two ESP32 based RFID rc522 readers (own written code) in our house.
Currently the same chip triggers independet action on each RFID reader.
Can I achive that using native HA tags?

My current state is that the ESP32 is running with new ESPHome code (damn easy…) and the RFID tag is submitted to HA after scanning. From this point I switch over to node red and run an automation.

What is the best way to achieve a spearate automation based on the reader the chip was scanned?
One possible way would be to publish chip to mqtt topc and specify separet topics for each reader, is there another option?

Thanks, Bernd

if you use substitutions in esphome, and $devicename you could add ${devicename} before/after the !lambda (below example code) then in an automation pickup as an condition if “devicename” = device ?

rc522_spi:
cs_pin: $cs_pin
reset_pin: $reset_pin
update_interval: 3s
on_tag:
then:
- homeassistant.tag_scanned: !lambda ‘return x;’

1 Like

perfekt - that was exactly what I was looking for!
Thanks!

image

  on_tag:
    then:
      - homeassistant.tag_scanned: !lambda 'return "${scanprefix}"+x;'
1 Like