Checking tag_id in a list of tags

Hello everyone! I just registered here.

I am on the board of directors for a local, non profit maker space, and we just rolled out Home Assistant for the space. Primarily, we’ve been using HA for power useage montoring, which indirectly tells us what tools people are using and it’s percent utiliziation. So for example I can run a report and look at the plugs that my 3D Printers are plugged into, and anytime the power goes over 60W I know someone is printing a print on the printer.

My next step is to solve our access control system as well as implement a tool badge-in system. I’ve gotten ESP32 hardware to report keycard taps with an RDM6300 module. I can see the tag_scanned events when I listen for them under Developer tools → Events:

event_type: tag_scanned
data:
  tag_id: "3714534"
  name: null
  device_id: 968723c875b53ba76709dba170de3746
origin: LOCAL
time_fired: "2024-04-12T21:11:10.499413+00:00"
context:
  id: 01HVA2CSX36TKM0HHFVE33J0A6
  parent_id: null
  user_id: null

Since we are kinda small <200 members, <20 card readers probably for tools to badge into, I am hoping to do without implementing a database. Instead I am keeping access controls through a custom Google Sheet, and the plan is to generate a list that HA can slurp in holding the key card tag_id of authorized users.

I’ve modified the example code here on building an RFID jukebox:

So far, this is my code in Automations.yaml:

- id: '1712777877320'
  alias: RFID Card Tap Processing
  description: This automation is launched when an RFID card is tapped.
  trigger:
    platform: event
    event_type: tag_scanned
  variables:
    authuser: ['0000000','0000001','3714534']
    frontdoor: ['968723c875b53ba76709dba170de3746']
#  condition: and
#  conditions:
#  - "{{ trigger.event.data.tag_id in authuser }}"
#  - "{{ trigger.event.data.device_id in frontdoor}}"
  action:
    service: notify.persistent_notification
    data:
      title: Hello!
      message: Scan registered
  mode: single

Which - if I comment out the conditions, I can get the action to fire every time there’s a card tap (persistent notification pops up). But if I comment out the conditions, it doesn’t fire at all, even though the card 3714534 from device id 968723c875b53ba76709dba170de3746 is presented every time.

Thoughts?

I got it!

Turns out I screwed up the formatting for conditions. 2 spaces in front of the dash fixed it.

- id: '1712777877320'
  alias: RFID Card Tap Processing
  description: This automation is launched when an RFID card is tapped.
  trigger:
    platform: event
    event_type: tag_scanned
  variables:
    authuser: ['0000000','0000001','3714533','4040344']
    frontdoor: ['968723c875b53ba76709dba170de3746']
  condition:
    - "{{ trigger.event.data.tag_id in authuser }}"
    - "{{ trigger.event.data.device_id in frontdoor}}"
  action:
    service: notify.persistent_notification
    data:
      title: Hello!
      message: Scan registered
  mode: single

Well… welcome anyway. :grin: