RDM6300 - delay between actions

I have an RDM6300 that reads cards and triggers an automation in Home Assistant.

rdm6300:
  on_tag:
    then:
      - homeassistant.tag_scanned: !lambda 'return to_string(x);'
      - delay: 2000ms #This does nothing

It works well, with one problem. While the card is close to the reader it continously sends the tag to Home Assistant.
In Home Assistant i have an automation that triggers on tag_scanned. Sometimes my automation fails and it’s very hard to debug, because of the huge number of incoming tag_scanned events.
I want to deal with this on the ESPHome side, i.e. send less events.
What i am looking for is something like a user defined delay bewteen the sending of the tags, or something similar. The delay in the code above does not work.
Does anyone have a clue how to implement that?

I think you should pass it to rdm6300 Binary Sensor

rdm6300:

binary_sensor:
  - platform: rdm6300
    uid: 7616525
    name: "RDM6300 NFC Tag"

on binary sensor you can automate how to trigger home assistant and use delayed_on or _off.

Thank you for the idea but this would not be useful for my case. I have many different RFID tags (>60) and my Home Assistant automation uses the ID of the tags, and i want to keep it this way (Each tag triggers a different playlist on a media player). Your suggested solution would meant that i would need a binary sensor for each tag in ESPHome, that is not feasible for me. It’s easiser to manage the different tags in the Home Assistant automation than in ESPHome.

Why? You can set them internal, so it’s not exposed to home assistant…

Well it can be done, but I don’t want to update ESPhome everytime I add a new RFID tag. If I understand the example correctly, each new tag that I add requires an update of the ESPHome to add a new binary sensor with the corresponding UID.
In my current setup I only need to edit the automation in home assistant and I was hoping that I could leave it that way

I finally understand, and agree…
So whatabout template binary sensor

rdm6300:
  on_tag:
    then:
      - lambda: |-
        id(some_binary_sensor).publish_state(true);

or

then:
          - switch.turn_on: dummy_switch

so just one binary sensor (or switch) where you trigger HA and set delay

Thank you for the hint, here is my final result:


# Read and send tag
rdm6300:
  on_tag:
    then:
      #- homeassistant.tag_scanned: !lambda 'return to_string(x);'
      - text_sensor.template.publish:
          id: last_card_id
          state: !lambda 'return to_string(x);'  
      - binary_sensor.template.publish:
          id: "NewCardScanned"
          state: On
      - delay: 100ms  
      - binary_sensor.template.publish:
          id: "NewCardScanned"
          state: Off

text_sensor:
  - platform: template
    name: Last Card ID
    id: last_card_id

binary_sensor:
  - platform: template
    name: "New Card Scanned"
    id: "NewCardScanned"
    filters:
      - delayed_off: 2000ms
    on_press:
      then:
        homeassistant.tag_scanned: !lambda 'return id(last_card_id).state;'

You are welcome. Nice that you solved it.