A room picture in Home Assistant that shows what's really happening

A room picture that follows the house: the fridge door opens when the real one does, the TV shows what's on, and the lights glow.

The whole open-plan living area as a picture in Home Assistant: dining table on the left, kitchen and fridge in the middle with the fridge doors swung open and lit inside, TV and couch on the right, with labels reading Fridge 3.3° · Freezer −19.7° and, in red, Fridge door open 0:16
Difficulty
Advanced
Parts cost
Free software. About US$1.40 of AI image edits for one room, or nothing if you take your own photos
Build time
An evening for the first room, once the sensors exist
Skills
Home Assistant, JavaScript, Python

The problem

Each room will get a small tablet on the wall, and each tablet shows a picture of that room. A list of switches tells you the state of things. A picture of the room should show it. If the fridge is open, the fridge in the picture should be open. If the TV is on, the TV in the picture should be showing something.

Home Assistant’s picture-elements card already puts live icons on a picture. What it can’t do on its own is change the picture itself. So I wrote one small custom element that sits inside the card and draws the parts of the room that change.

What moves

Side by side: on the left, Home Assistant's sensor list for the fridge with the Fridge door row reading Closed and highlighted; on the right, the room picture with the fridge's doors shut and a label reading Fridge 2.7° · Freezer −18.8°
Door shut. Left: the fridge's own sensors in Home Assistant. Right: the room picture.
Side by side: on the left, the same sensor list with the Fridge door row reading Open and highlighted; on the right, the room picture with both fridge doors open and lit inside, the temperature label, and a red label reading Fridge door open 0:12
Door open, 12 seconds later. Both screenshots are from the live dashboard, not a mock-up.
  • Lighting. The whole picture fades between day, night with the lights on, and night with them off.
  • Fridge. The doors swing open, the freezer drawer pulls out, or both. A red label counts how long it’s been open. The fridge and freezer temperatures sit underneath. The door and temperature readings come from my fridge bridge.
  • TV. When it’s on, the screen lights up in the right perspective. On the streaming stick it shows a live snapshot of the screen and the app’s name. The paid streaming apps block snapshots, so those get a soft blue glow with the app name instead.
  • Lights. Each fitting glows at its real brightness and colour. The electric candle flickers.
  • Aircon. Airflow lines come out of the louvre: blue for cooling, orange for heating. The label says “Cooling to 22°”.
  • Dishwasher. It’s hidden under the island, so the island front pulses blue while it runs. The label shows the program and the minutes left, read from my dishwasher bridge.

How it works

The card is an ordinary picture-elements card. Its first element is the custom one, stretched over the whole picture. It stacks these layers:

  1. Three backgrounds (day, night with lights on, night with lights off), one visible at a time.
  2. Overlay patches: small transparent pictures of just the part that changes, like the open fridge. Each one is cut from a full picture of the room in that state, so it lines up exactly.
  3. Glows: soft circles blended over each light fitting, coloured from the light’s own colour.
  4. The TV screen: a box bent into the TV’s perspective, showing the screen snapshot or a glow.
  5. Labels: the temperatures, the open-door timer, what’s on the TV.

The card’s normal light buttons sit on top, unchanged.

The element only reads. It never switches anything, and the build script refuses to deploy it if the file contains a call that could. Tap a label and you get that sensor’s details, nothing more.

What you need

  • Home Assistant, with sensors for the things you want to see move. A door sensor is all the fridge needs.
  • One photo of the room, taken from where the tablet will hang. Mine started as a photo I took of the room empty, then an AI image model furnished it.
  • A picture of each moving part in its other state, from exactly the same spot: the fridge door open, the drawer out, both. Take real photos if you can. I used an AI model to make mine for now, because the tablets aren’t on the walls yet.
  • Python with Pillow, NumPy and SciPy, to cut the overlays.
  • A way to load a custom JavaScript file into Home Assistant: a file in /config/www/, added as a dashboard resource.

Making the pictures

Make the day picture first. Then make every other picture from the day picture, not from the original photo, or the room shifts slightly between them and the layers stop lining up.

For the AI versions I used Gemini 3.1 Flash Image through OpenRouter, about US$0.10 a picture. The prompt that worked was short and strict: open the fridge’s doors, change nothing else, don’t zoom, don’t crop, keep the framing exactly. Without the last three, one of the night pictures came back zoomed in.

The lighting and the fridge multiply: 3 lighting states × door, drawer and both = 9 pictures for the fridge alone. That’s why only the changed part is kept.

Cutting the overlay

This compares a “door open” picture with its background, inside a box around the fridge, and keeps only the pixels that changed. The edges are feathered, and the whole patch fades out toward the edge of the box, so there’s no hard seam.

import numpy as np
from PIL import Image
from scipy import ndimage

BOX = (1200, 700, 1780, 1390)   # x0, y0, x1, y1 around the fridge, in pixels
EDGE = 40                       # fade to nothing over the last 40 px of the box

base = np.asarray(Image.open("room_day.png").convert("RGB")).astype(np.int16)
var = np.asarray(Image.open("room_day_door.png").convert("RGB")).astype(np.int16)
x0, y0, x1, y1 = BOX

d = ndimage.median_filter(np.abs(var - base).sum(axis=2)[y0:y1, x0:x1].astype(float), 5)
m = ndimage.binary_opening(d > 40, iterations=2)                 # changed pixels, specks dropped
m = ndimage.binary_fill_holes(ndimage.binary_closing(m, iterations=6))
m = ndimage.binary_dilation(m, iterations=6)
a = np.clip(ndimage.gaussian_filter(m.astype(float), 5) * 1.6, 0, 1)

h, w = a.shape
yy, xx = np.mgrid[0:h, 0:w]
a *= np.clip(np.minimum.reduce([xx, w - 1 - xx, yy, h - 1 - yy]) / EDGE, 0, 1)

patch = np.dstack([var[y0:y1, x0:x1].astype(np.uint8), (a * 255).astype(np.uint8)])
Image.fromarray(patch, "RGBA").save("fridge_door_day.png")

Save each patch’s position as a percentage of the whole picture. That’s what the card uses to place it, so it stays lined up at any screen size. I convert the patches to WebP, which keeps the transparency and cuts the size a lot.

The config

The custom element takes the lighting rules, the pictures and the entities. This is the fridge part, trimmed:

type: picture-elements
image: /local/rooms/room_day.jpg
elements:
  - type: custom:room-scene
    style: { left: 50%, top: 50%, width: 100%, height: 100% }
    lighting:
      - key: day
        when: [{ entity: sun.sun, state: above_horizon }]
      - key: night_on
        when: [{ entity: light.example_light, state: "on" }]
      - key: night_off
    backgrounds:
      day: /local/rooms/room_day.jpg
      night_on: /local/rooms/room_night_on.jpg
      night_off: /local/rooms/room_night_off.jpg
    overlays:
      # first match wins, so "both" goes first
      - when:
          - { entity: binary_sensor.fridge_door, state: "on" }
          - { entity: binary_sensor.freezer_drawer, state: "on" }
        images:
          day: { src: /local/rooms/fridge_both_day.webp, box: { left: 47.5, top: 41.5, width: 22.9, height: 40.4 } }
          # ...and the same for night_on and night_off
      - when: [{ entity: binary_sensor.fridge_door, state: "on" }]
        images: { ... }
      - when: [{ entity: binary_sensor.freezer_drawer, state: "on" }]
        images: { ... }
    fridge:
      x: 59.5
      y: 70
      fridge_temp: sensor.fridge_temperature
      freezer_temp: sensor.freezer_temperature
      door: binary_sensor.fridge_door
      drawer: binary_sensor.freezer_drawer
  # the card's normal light buttons go after it, on top

The element puts every overlay <img> in place once, at load. After that, a state change only changes which ones are visible, with a short CSS fade. Nothing reloads, so the door opens within about a second of the real one.

The open-door timer counts from the sensor’s last_changed. It ticks once a second, but only while a door is open.

The TV in perspective

The TV screen in the picture is a slanted shape, not a rectangle. I measured its four corners as percentages of the picture, then a CSS matrix3d transform bends a flat 1600 × 900 box onto those four corners. Anything inside that box, a picture or text, then sits in the screen in perspective.

The screen picture is the streaming stick’s own snapshot. Home Assistant’s Android TV integration grabs it over ADB and serves it as the media player’s entity_picture. Netflix and the other paid apps return a black snapshot, so when there isn’t a usable picture the element shows a blue glow and the app’s name instead.

Load the snapshot from the browser, not from Home Assistant’s server. The picture’s link carries a token that expires. If Home Assistant itself fetches an expired one, it counts as a failed login, and enough of those will ban the address it came from.

Testing it

You can’t test “fridge open” by asking someone to stand at the fridge each time, and you shouldn’t switch real things on to check a picture. So the element reads a pretend state from the page address:

/dashboard-path/rooms?efsim=binary_sensor.fridge_door=on;climate.living_room=cool;climate.living_room.temperature=22

Each entity=state pair overrides what this browser sees, and entity.attribute=value overrides one attribute. Nothing in the house changes, and nobody else’s screen changes. The card’s normal light buttons still show the real state, because only the custom element reads the address.

Step by step

  1. Get the sensors working first: the doors, the TV, the lights.
  2. Take or make the day picture from where the tablet will hang. Make the two night pictures from it.
  3. For each moving part, make the “changed” picture from each of the three backgrounds, same spot, same framing.
  4. Cut the overlays with the script above. Check each one over its background, at night especially, where a seam shows up most.
  5. Put the pictures and the element’s JavaScript file in /config/www/rooms/ and add the file as a dashboard resource. Put a version number on the end of its address (?v=2) and change it each time, or tablets keep the old copy.
  6. Measure the positions (TV corners, light fittings, label spots) as percentages of the picture.
  7. Try every state with the efsim address before you trust it, then wait for the real thing to happen once.

Lessons learnt

Make every picture from the same base. Generate each night picture and each open-door picture from the finished day picture. Otherwise the room moves a few pixels between them and the overlays don’t line up.

Tell the AI model what not to do. “Change nothing else, don’t zoom, don’t crop” mattered as much as the change itself. One night picture came back zoomed in until I added it.

Keep only the changed pixels. A rectangle cut from the “open” picture showed a visible edge and carried a smudge from the ceiling. Comparing against the background and fading out toward the box edge fixed both.

A picture of the room needs one picture for every combination. Door, drawer and both, each in day, night with lights on and night with lights off, came to 9 for the fridge alone. Plan the combinations before you make any pictures.

Test with pretend states, then wait for the real one. The address override checked every state in a couple of minutes without touching anything. The fridge screenshots above came from the real door being opened, after all the testing was done.

Keep the picture display only. Tapping a label opens that sensor’s details. The only things on the picture that switch anything are the card’s normal light buttons.

Questions and comments

Loading comments…

    Your name and comment show publicly. To stop spam, a scrambled code made from your internet address is kept, never the address itself. Comments with links wait for a quick check before they show. Be decent: I'll remove anything that isn't.