RFID Many Tags

Hi Guys and Gals,

I have a RFID all setup and running, I am having trouble with the config/management of the tags.
For each tag I have a bunch of sensors and inputs, which makes adding/changing/deleting tags a bit of a nightmare.

The snippet below, XXX would be the name of the tag holder

# # # # # # # # # # # # # #
# # Displays time IN over period for each tag
sensor:
  - platform: history_stats
    name: XXX IN Yesterday
    entity_id: input_boolean.rfid_XXX
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    duration:
      hours: 24

  - platform: history_stats
    name: XXX IN Last Week
    entity_id: input_boolean.rfid_XXX
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) - timedelta(days=now().weekday() + 7) }}"
    duration:
      days: 5

  - platform: history_stats
    name: XXX IN Last Month
    entity_id: input_boolean.rfid_XXX
    state: "on"
    type: time
    start: "{{ (now().replace(day=1,hour=0, minute=0, second=0) - timedelta(days=1)).replace(day=1) }}"
    end: "{{ now().replace(day=1,hour=0, minute=0, second=0) - timedelta(days=1) }}"


# # # # # # # # # # # # # #
# # Displays In/Out toggle switch for each tag
input_boolean:
  rfid_admin:
    name: XXX
    icon: mdi:robot


# # # # # # # # # # # # # #
# # Displays the time in and out for each tag
input_datetime:
  rfid_admin_in:
    name: XXX
    has_date: true
    has_time: true
    icon: mdi:timer-outline

  rfid_admin_out:
    name: XXX
    has_date: true
    has_time: true
    icon: mdi:timer-off-outline

So is there a way to take a variable (from below variables) and dynamically create these components?

- variables:
  # Map tag ID to person
  tags:
	# Tag 1
	10-A0-B0-10:
	  tag_user: Dad

	# Tag 2
	10-A0-B0-20:
	  tag_user: Mum

	# Tag 3
	10-A0-B0-30:
	  tag_user: Kid1

	# Tag 4
	10-A0-B0-40:
	  tag_user: Kid2

Any help would be appreciated…
Thanks.

1 Like