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.



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: truein 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:
- turns the screenās backlight on and shows Card Scanned
- publishes the cardās ID to the Last RFID UID sensor, and fires an
esphome.rfid_card_scannedevent in Home Assistant - shows Loading Movie⦠with a 16 second loading bar, then Movie Loaded, Enjoy!
- sets the sensor back to Waiting⦠and the screen back to Please select a movie!
- turns the backlight off again after 30 seconds


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_scannedevent, 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.
What to read next
3 pages
This is part of my smart home: see how it all fits together. Got a question about this, or built something similar? Get in touch. New write-ups go out on the RSS feed and LinkedIn, everything I've built is on the projects page, and my free calculators and guides are on the tools page.