All posts

Building my own Home Assistant cards

Dark-mode showcase of three custom Home Assistant cards on a charcoal dot grid: an AWTRIX pixel clock reading 19:42, a 142 W smart plug card, and a 71-degree climate card with a dual sparkline.

I've always been a heavy sleeper. Multiple alarms are the norm for me, and I haven't owned a single alarm clock I haven't slept through at least once. My old one finally stopped cutting it: it was too quiet, and changing anything meant fighting a complicated set of buttons I still needed the manual to figure out.

A normal person buys a louder clock. Instead, I built one in Home Assistant and ended up with six custom dashboard cards, three of which are now on HACS. I really enjoyed making them, and it's been pretty cool watching the download counter tick up.

A pixel clock with a speaker

I already had Ulanzi's original Smart Pixel Clock (TC001), and it's a great little device. The best part is that you can replace the stock software with open-source firmware and expose the whole thing to Home Assistant over MQTT.

Newer hardware solved the alarm problem: Ulanzi's Pixbar Pixel Clock II (TC002) adds a speaker and runs AWTRIX NG. If my brain ever got too used to one alarm sound, I could swap it out for a new one.

The catch was controlling it. AWTRIX NG exposes the clock as nearly twenty separate MQTT entities, with no built-in card preset to tie them together. Using stock Home Assistant controls, this 18-row stack was the best I could come up with:

Stock Home Assistant entities card titled Livingroom Clock stacked vertically across five sections with 18 separate toggles, dropdowns, volume sliders, and sensor rows

Eighteen rows tall, and you still couldn't see what was on the screen or send it a message. Not bad, but not great.

Down the rabbit hole with Preact

I figured, how hard could it be to design my own card?

Turns out, not too bad. Most custom Home Assistant cards use Lit, which is where I started, before deciding I didn't want to learn another framework for a side project. Under the hood, a Home Assistant card is just a browser custom element: Home Assistant hands it your config and a hass object with the state of every entity in the house, and it doesn't care what renders the HTML inside. So I switched to Preact. It's lightweight like Lit, with the React syntax and hooks I already know well.

AWTRIX NG Card

My replacement card puts the whole clock in one place: a live pixel preview of what's currently on the display, brightness and app controls, and tabs for messages, corner indicators, display settings, and sound.

AWTRIX NG Card for Bedroom Clock on a 52x16 matrix showing 00:23 in red LEDs with the BigClock app selected, battery and Wi-Fi status chips, a 10 percent brightness slider, and the Message tab open

Those red digits in the preview are another rabbit hole. AWTRIX NG's built-in fonts top out at 8 pixels tall, which looks tiny across a bedroom on a 52×16 panel. I wrote BigClock to draw full-height 16-pixel digits out of solid blocks and flip to red at night.

The alarm card

Next, I needed the alarm controls. Home Assistant helpers store the alarm schedules, and automations and scripts make the TC002 sound the alarm. I loaded some genuinely annoying sounds onto the clock: a foghorn, a rooster, and an old school bell. When I noticed it could stream internet radio stations, I added a few of those too.

The card keeps the day-to-day part simple: day-of-week pills, a toggle per alarm, sound and volume controls, and Test and Stop buttons so I can try out alarms without waiting until morning.

AWTRIX NG Alarm Card for Bedroom alarm displaying weekday and weekend schedules with day-of-week pills and toggles, an add-alarm bar, and sound, volume, ring duration, and test controls

In for a penny, in for a pound

Once I had a workflow I was happy with, it was tough to stop at clocks. Change a line, reload, and the card on the dashboard updates right away. I ended up building cards for the rest of the devices I use every day.

Smart Plug Card

A plug toggle that also tells you what the plug is doing: live wattage, a 24-hour graph, and the energy used today, yesterday, and this month. Add your electricity rate and it calculates the cost too. It works with Shelly and Tasmota plugs, or any switch with power monitoring.

Smart Plug Card for Bedroom Light showing a glowing amber lamp icon and toggle, live 5.0 W power readout, a 24-hour power usage graph, and energy totals for today, yesterday, and this month

Shelly H&T Card

A temperature card that shows the trend, not just the number: whether the room is warming or cooling, a comfort label, and the last 24 hours of temperature and humidity. It's built for Shelly's H&T sensor, though it works with any temperature sensor.

Shelly H&T Card for Bedroom showing 63.1 degrees Fahrenheit with a steady trend arrow, Cool comfort label, 43 percent humidity, 72 percent battery badge, a 24-hour temperature and humidity sparkline, and 24-hour low, high, humidity range, and last-updated time

RGB light card

Home Assistant's stock light controls were too small for me. I wanted a big color wheel and preset swatches right in my face on the dashboard.

Each of my RGB lights also does more than just pick a color: the RGB tree has a separate Twinkle switch for a string of small companion LEDs, both the tree and the dino have a rainbow effect, and the Shelly strip driver adds a dedicated white channel and physical switch inputs. Rather than building three separate layouts, I made one card that adapts to all three.

Three custom RGB Light Cards side by side for RGB Tree, RGB Dino, and Shelly RGB Strip, each showing a large color wheel, brightness slider, nine color preset swatches, and device-specific controls for rainbow effects, companion Twinkle LEDs, and Shelly switch inputs

What surprised me under the hood

Building six cards back to back taught me a lot about how Home Assistant's frontend actually works:

  • Cards run in your browser, not on the server. The live clock preview is your browser asking the clock for a new frame every two seconds while the card is on screen. At home on Wi-Fi, the card can also fetch the clock's app list directly over HTTP. Away from home over HTTPS, browser mixed-content rules block that local request, so the card falls back to the apps it has already seen.
  • Devices tie separate entities together. A smart plug isn't one entity; it's a switch plus separate wattage and kWh sensors sharing a device ID. You only hand the Smart Plug Card the switch, and it finds the rest itself. Pulling totals from long-term statistics also means plugs that count up forever (Shelly) and plugs that reset (Tasmota) work the same way.
  • Only admins can subscribe to MQTT from the frontend. Any user can send commands to a clock, but Home Assistant blocks non-admin accounts from listening to MQTT topics in the browser. The clock card catches that and shows a clear warning instead of an empty panel.
  • The phone app is a cached webview. Because the Companion app loads the same web frontend as desktop, every card worked on my phone and tablet for free. The catch is aggressive caching: updating a card means a trip to Companion app → Debugging → Reset frontend cache.

Get the cards

Three of the cards are general-purpose enough for anyone's dashboard and are available on HACS:

Card What it does Install Source
AWTRIX NG Card Live preview and full control of an AWTRIX NG pixel clock Open in HACS GitHub
Smart Plug Card Live wattage, a 24-hour graph, energy totals, and cost Open in HACS GitHub
Shelly H&T Card Temperature trend, comfort label, and 24-hour range Open in HACS GitHub

Click Open in HACS, install the card, and reload the page, then add it to a dashboard. Each one includes a visual editor, so there's no YAML to write unless you want to.

The alarm card and RGB light card live in my homeassistant-ui repo alongside a sixth card that broadcasts a message to every pixel clock in the house at once. Those three are built around my own helpers and setup, so they aren't on HACS. If one looks useful to you, let me know.