~/jackwent.co.uk
jack@jackwent:~$ cat rfid-films.yaml

RFID Cards That Start Films in Home Assistant

by published 24 September 2026updated 6 November 20267 min read

Streaming menus are hard work for small children. Too many rows, too many buttons, and a remote that somehow always ends up down the back of the sofa. So we made films physical again.

There’s an RFID reader by the TV and a stack of cards, one per film. Tap a card on the reader and the film starts playing on the living room TV from our Plex server. We’re up to 32 cards now.

The hardware

  • An ESP32 with an RC522 RFID reader, running ESPHome. It reads the unique ID of any card you tap and sends it to Home Assistant as a sensor called Last RFID UID.
  • A 16x2 LCD with an I2C backpack, so the box can say what it’s doing: ā€œPlease select a movie!ā€ while it waits, then a loading bar once a card is tapped.
  • Blank RFID cards that match your reader (the RC522 only reads 13.56MHz MIFARE cards, not 125kHz ones). Print the film’s poster and stick it on the front so little ones can pick by picture.
  • A Chromecast on the TV, which Home Assistant can send media to.
  • Plex, with the Plex integration set up in Home Assistant so it can browse the film library.

The case

The reader lives in a 3D printed box by the TV, so there’s one obvious place to tap a card. It has ā€œSCANā€ raised on the lid.

rfid-reader-box-finished.webp
The finished 3D printed RFID reader, a pink and purple box with SCAN raised on the lid, sitting on a wooden unit by the TV with its blue LCD screen showing Please select a movie!
The finished box by the TV, waiting for a card.
rfid-reader-box-inside.webp
Inside the 3D printed RFID box with the lid off: an ESP32 board wired to a 16x2 LCD with an I2C backpack at the top and the blue RC522 reader glued in at the bottom, powered over USB-C
Inside the box: the ESP32, the LCD and its I2C backpack, and the RC522 reader underneath where the cards go.
rfid-case-v3.stl
A 3D model of a square purple box on a printer's build plate, with SCAN raised on the lid and a rectangular frame standing up at the back
Version 3 of the case in the slicer. It's 120 x 117 x 62mm.

If you’d like to print your own, the model is free to download: rfid-reader-case-v3.stl (300KB). Check it fits your reader before you print, as boards vary.

Wiring it up

The reader talks to the ESP32 over SPI and the screen over I2C, so the two never get in each other’s way.

  • RC522 to ESP32: SDA to GPIO5, SCK to GPIO18, MOSI to GPIO23, MISO to GPIO19, RST to GPIO4, 3.3V to 3V3 and GND to GND. Leave IRQ unconnected. The RC522 is a 3.3V board, so don’t power it from 5V.
  • LCD backpack to ESP32: SDA to GPIO21, SCL to GPIO22, VCC to VIN and GND to GND. Powered from VIN, the backpack’s built-in pull-up resistors hold SDA and SCL at 5V, which is more than the ESP32’s 3.3V pins are rated for. It’s worked fine for me, but if you’re building one, a small I2C level shifter (or removing the backpack’s pull-ups) is the safe option. The backpack in the config is at address 0x27; if your screen stays blank, scan: true in the config lists the address it found in the ESPHome logs.

The ESPHome config

Here’s the whole config for the reader. When a card is tapped it:

  1. turns the screen’s backlight on and shows Card Scanned
  2. publishes the card’s ID to the Last RFID UID sensor, and fires an esphome.rfid_card_scanned event in Home Assistant
  3. shows Loading Movie… with a 16 second loading bar, then Movie Loaded, Enjoy!
  4. sets the sensor back to Waiting… and the screen back to Please select a movie!
  5. turns the backlight off again after 30 seconds
card-scanned.webp
The RFID reader with a white card sitting on top and the blue LCD showing Card Scanned, Please wait...
Step 1: a card on the reader and the screen showing Card Scanned.
loading-movie.webp
The RFID reader with a card on top and the blue LCD showing Loading Movie... with a loading bar starting along the bottom line
Step 3: Loading Movie... with the 16 second loading bar starting along the bottom.

The passwords and keys are !secret references, so put your own in ESPHome’s secrets.yaml.

rfid-reader.yaml (ESPHome)
esphome:
  name: rfid-reader
  friendly_name: RFID Reader
  on_boot:
    priority: -100
    then:
      # Turn off LCD backlight
      - lambda: |-
          id(rfid_lcd).no_backlight();

      # Reset RFID state (IMPORTANT)
      - text_sensor.template.publish:
          id: last_rfid_uid
          state: "Waiting..."

      # Idle screen (2-line)
      - text_sensor.template.publish:
          id: lcd_line1
          state: "Please select"

      - text_sensor.template.publish:
          id: lcd_line2
          state: "a movie!"

esp32:
  board: esp32dev
  framework:
    type: esp-idf

####################################
# LOGGING / API / OTA
####################################
logger:

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

####################################
# WIFI
####################################
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password_iot
  min_auth_mode: WPA2

  ap:
    ssid: "Rfid-Reader Fallback Hotspot"
    password: !secret fallback_ap_password

captive_portal:

####################################
# I2C (LCD)
####################################
i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

####################################
# LCD DISPLAY (16x2 I2C)
####################################
display:
  - platform: lcd_pcf8574
    id: rfid_lcd
    dimensions: 16x2
    address: 0x27
    lambda: |-
      it.printf(0, 0, "%-16s", id(lcd_line1).state.c_str());
      it.printf(0, 1, "%s", id(lcd_line2).state.c_str());

####################################
# SPI BUS (RC522)
####################################
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

####################################
# RC522 RFID READER
####################################
rc522_spi:
  cs_pin: GPIO5
  reset_pin: GPIO4
  on_tag:
    then:
      # Turn backlight ON
      - script.execute: lcd_backlight_on

      - text_sensor.template.publish:
          id: last_rfid_uid
          state: !lambda |-
            return x;

      - text_sensor.template.publish:
          id: lcd_line2
          state: "Card scanned"

      - script.execute: rfid_loading_bar

      # Start auto-off timer
      - script.execute: lcd_backlight_auto_off

      - homeassistant.event:
          event: esphome.rfid_card_scanned
          data:
            uid: !lambda |-
              return x;

####################################
# GLOBALS (LCD LOADING BAR)
####################################
globals:
  - id: load_pos
    type: int
    restore_value: no
    initial_value: '0'

####################################
# SCRIPTS
####################################
script:
  - id: lcd_backlight_on
    mode: restart
    then:
      - lambda: |-
          id(rfid_lcd).backlight();

  - id: lcd_backlight_auto_off
    mode: restart
    then:
      - delay: 30s
      - lambda: |-
          id(rfid_lcd).no_backlight();

  - id: rfid_loading_bar
    mode: restart
    then:
      # Ensure backlight stays on
      - script.execute: lcd_backlight_on

      # Card scanned message (3s)
      - text_sensor.template.publish:
          id: lcd_line1
          state: "Card Scanned"

      - text_sensor.template.publish:
          id: lcd_line2
          state: "Please wait..."

      - delay: 3s

      # Show loading title
      - text_sensor.template.publish:
          id: lcd_line1
          state: "Loading Movie..."

      - globals.set:
          id: load_pos
          value: '0'

      # Progress bar
      - repeat:
          count: 16
          then:
            - text_sensor.template.publish:
                id: lcd_line2
                state: !lambda |-
                  std::string bar = "";
                  for (int i = 0; i < id(load_pos); i++) bar += "#";
                  for (int i = id(load_pos); i < 16; i++) bar += "-";
                  return bar;

            - globals.set:
                id: load_pos
                value: !lambda 'return id(load_pos) + 1;'

            - delay: 1s

      # Show success message
      - text_sensor.template.publish:
          id: lcd_line1
          state: "Movie Loaded"

      - text_sensor.template.publish:
          id: lcd_line2
          state: "Enjoy!"

      - delay: 5s

      # Reset RFID UID
      - script.execute: reset_last_rfid_uid

      # Back to idle
      - text_sensor.template.publish:
          id: lcd_line1
          state: "Please select"

      - text_sensor.template.publish:
          id: lcd_line2
          state: "a movie!"

  - id: reset_last_rfid_uid
    then:
      - text_sensor.template.publish:
          id: last_rfid_uid
          state: "Waiting..."

####################################
# SENSORS
####################################
sensor:
  - platform: uptime
    type: timestamp
    name: "Last Boot"
    icon: mdi:clock-outline

  - platform: wifi_signal
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: diagnostic

  - platform: copy
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    id: wifi_signal_pct
    unit_of_measurement: "%"
    accuracy_decimals: 0
    device_class: ""
    entity_category: diagnostic
    filters:
      - lambda: |-
          if (x <= -100) return 0;
          if (x >= -50) return 100;
          return 2 * (x + 100.0);

####################################
# TIME
####################################
time:
  - platform: homeassistant
    id: hass_time
    on_time_sync:
      then:
        - if:
            condition:
              lambda: 'return id(device_last_restart).state == "";'
            then:
              - text_sensor.template.publish:
                  id: device_last_restart
                  state: !lambda 'return id(hass_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'

####################################
# WEB SERVER
####################################
web_server:
  port: 80
  auth:
    username: !secret web_server_username
    password: !secret web_server_password

####################################
# BUTTONS
####################################
button:
  - platform: restart
    name: "Restart Device"

####################################
# TEXT SENSORS
####################################
text_sensor:
  - platform: wifi_info
    ip_address:
      name: "IPv4 Address"
      entity_category: diagnostic
    mac_address:
      name: "Mac Address"
      entity_category: diagnostic

  - platform: template
    name: "Last Restart"
    id: device_last_restart
    icon: mdi:clock
    entity_category: diagnostic

  - platform: template
    name: "Last RFID UID"
    id: last_rfid_uid
    icon: mdi:card-account-details-outline

  - platform: template
    id: lcd_line1
    internal: true

  - platform: template
    id: lcd_line2
    internal: true

Finding each card’s ID

The automation below uses the Last RFID UID sensor, which works straight away. If you’d rather trigger on the esphome.rfid_card_scanned event instead, turn on Allow the device to perform Home Assistant actions in the ESPHome integration’s options for the reader (Settings > Devices & Services > ESPHome > the reader > Configure). Without it, the event never reaches Home Assistant.

Tap a new card on the reader, then look at the Last RFID UID sensor in Home Assistant. It’ll show something like A1-B2-C3-D4. That’s the ID you’ll use in the automation. Do the same for each card.

The automation

Each card gets a trigger with its ID as the trigger id, and a matching action that plays the film. Here it is with two films. Mine just has thirty more of each.

alias: RFID play films
mode: single
triggers:
  - trigger: state
    entity_id: sensor.rfid_reader_last_rfid_uid
    to: "A1-B2-C3-D4"
    id: the-bad-guys
  - trigger: state
    entity_id: sensor.rfid_reader_last_rfid_uid
    to: "E5-F6-A7-B8"
    id: sing
actions:
  - alias: Wake the Chromecast if it's asleep
    if:
      - condition: state
        entity_id: media_player.living_room_chromecast
        state:
          - "idle"
          - "off"
          - "standby"
    then:
      - action: media_player.turn_off
        target:
          entity_id: media_player.living_room_chromecast
      - delay:
          seconds: 3
      - action: media_player.turn_on
        target:
          entity_id: media_player.living_room_chromecast
  - choose:
      - conditions:
          - condition: trigger
            id: the-bad-guys
        sequence:
          - action: media_player.play_media
            target:
              entity_id: media_player.living_room_chromecast
            data:
              media:
                media_content_type: movie
                media_content_id: plex://YOUR-SERVER-ID/20225
      - conditions:
          - condition: trigger
            id: sing
        sequence:
          - action: media_player.play_media
            target:
              entity_id: media_player.living_room_chromecast
            data:
              media:
                media_content_type: movie
                media_content_id: plex://YOUR-SERVER-ID/20004

Setting up the Plex integration

If Plex isn’t in Home Assistant yet, add it first: go to Settings, Devices & services, Add integration, choose Plex Media Server, sign in with your Plex account and pick your server. Home Assistant can then browse your Plex library from the Play media action, which is what makes the next step easy. The Plex integration docs cover the options.

Getting the Plex ID

The easiest way to find the media_content_id for a film is to let Home Assistant write it for you. Add a Play media action in the visual editor, pick the Chromecast, browse to the film in your Plex library, then switch to YAML mode and copy what it filled in.

When you do, you’ll notice the visual editor also saves a metadata block with a thumbnail URL. That URL contains your Plex token, which is effectively a password for your Plex server. It isn’t needed for playback, so I’d delete the whole metadata block, especially if you ever share your YAML online.

The Chromecast wake-up

The first action deals with a quirk. If the Chromecast has been sitting idle for a while, it sometimes ignores the first play_media call. Turning it off and on again first, only when it isn’t already playing, wakes it up properly so the film starts first time. It’s the oldest fix in IT and it still works.

If I built it again

It works well, but there are two things I’d do differently with hindsight:

  • Use Home Assistant tags instead of a sensor. ESPHome can send a proper tag_scanned event, and Home Assistant has a built-in Tags page where you name each card. You then trigger on the tag rather than a sensor value. The catch with the sensor approach is that a state trigger only fires when the value changes, so tapping the same card twice in a row would do nothing. My reader gets around that by setting the sensor back to Waiting… after every film, but tags would make that step unnecessary.
  • One mapping instead of 32 triggers. A single trigger on any new card plus a lookup table of card ID to film would be much shorter than one trigger and one action per film. Adding a film would be one line instead of two blocks.

Even so, it’s a lovely first ESPHome project if you’ve got kids. Once it’s running, my automatic ESPHome updates keep the reader on the latest firmware without any clicking.

Was this helpful?

[jackwent]