Skip to content
프로젝트

소개

A live 3D model of your home for Home Assistant: control lamps and devices in 3D, edit the plan in HA, turn room photos into a plan. Runs at 60 fps on a 2017 tablet.

디자인 및 미디어

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+2
in 7 days
기록 수집 중
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

House 3D for Home Assistant

▶ Live demo: runs in your browser with simulated devices, no Home Assistant needed.

A night orbit around the demo home: lamps glowing and casting shadows

House 3D is a live 3D model of your home that runs as a Home Assistant dashboard. Tap a lamp in the model to switch it; press and hold for brightness and colour. Every light, plug, fan, TV and thermostat shows its real state as it changes. Sunlight follows HA's sun.sun through your windows, presence sensors appear as people, and auto-off timers count down over the devices. You draw the plan in an editor inside HA, or build it from photos of your rooms with pretrained vision models. It runs at close to 60 fps on a 2017 Android tablet mounted on the wall.

Built on the web front-end of house-control (MIT).

Feature tour

Daylight through the windows Real sunlight. The sun follows HA's sun.sun and your plan's true north. It enters only through the windows: an invisible roof and outer walls cast the shadows, rooms with windows get a soft daylight fill, and window glass glows with the sky.
Sun moving through a day A day in 12 seconds. Low warm sun in the morning, white at noon, moonlight at night.
Lamps switching on with glow and shadows Every lamp is a light. Each fixture drives a real three.js light with glow and soft shadows, in its colour or white temperature. Lamps that can't change colour get a fixed LED tint.
The plan editor Plan editor inside HA. Rooms (L-shaped too), walls, doors and windows, furniture and devices, with snapping, rotate by right-drag or a two-finger twist, and undo. Link each item to an entity from a sorted list of your HA devices. Saves to HA.
Bedroom with a person lying in bed People from presence sensors. An LD2410-style radar puts a glowing figure at the measured distance, swaying while moving, or lying on the bed when the "in bed" sensor is on.
Countdown badge over a device Auto-off timers, found automatically: a plug's own auto-off (TP-Link/Tapo), a Tuya countdown, or an automation that turns a device off after a delay. A draining ring counts down in 3D; the tile says "off in 1h26".
Colour sheet for the TV backlight Detailed controls. Press and hold any tile, lamp or group: brightness, white, colour, and per-device options.
TV remote sheet TV remote and an ambient backlight. D-pad, volume, sources. A small script on an Android TV box sends the average colour of the top of the picture to HA, and the lamp behind the TV follows it (example).
Rooms, presence and timers Rooms and groups. Pick a room to fly to it. HA light groups become chips and rounded floor zones. Dumb devices (a fan on a wall switch, a lamp on a smart plug) point to the switch that powers them.
House 3D on a wall tablet Made for a wall tablet. Kiosk mode hides HA's chrome per device. Each device opens on its own room and returns to it after two minutes. Touch targets are sized for standing in front of it. Recorded on a Galaxy Tab S3.

Also included:

  • A Display panel with per-device graphics: presets, resolution when still and while moving, glow, shadows, a 60 fps cap, and a built-in benchmark.
  • A photo pipeline: photograph a room, and VGGT reconstructs it while OWLv2 finds the furniture and devices. The editor then shows the proposal for you to accept item by item.
  • Safety options: confirm before switching, and "critical" devices (a fridge's plug) that bulk actions never touch.

Performance

The render path has a low-power mode for old tablets: static geometry batched into a few draw calls, a light budget, shader light culling, lean bloom, dynamic resolution and flat UI. It is picked automatically on old GPUs and every part can be toggled in the Display panel. Measured with the built-in benchmark (world.bench(4): a 4 s orbit at 40°/s) on a 6-room apartment plan.

Galaxy Tab S3 (2017, Adreno 530, Android 9, Chrome/WebView 103). Stage ~690×880 CSS px, evening, 2 lamps lit:

fps frame p90 CPU per frame draw calls
Before: stock render path, 1× resolution, sun shadow, no glow, no lamp shadows ~24 n/a ~26 ms 923
Before, with bloom glow ~11 n/a n/a 923
After: low preset, 1× while moving, glow + sun + 2 lamp shadows 58 16.8 ms ~9 ms 130
After, at native 1.75× while moving 32 n/a n/a 130

The tablet draws at 1× while the camera moves and redraws at native resolution with a 150 ms crossfade once it settles. By day with ~4 lamps lit and window light on it runs at ~28 fps; with window light off, ~36 fps. The remaining cost there is the light count.

Desktop (RTX 5070 Ti, headless Chromium, 1920×1080 viewport, 2× pixel density, full preset): ~100 fps, 168 draw calls, ~1.3 ms CPU per frame. Headless Chromium's frame pacing is the limit there, not the GPU. The full preset batches too: 669 → 107 draw calls and 17 → 7 lights in the shaders on the apartment plan, with practically the same image (0.001 % of pixels differ).

Known issue: on Adreno 530 / Chrome 103, a lamp's cube shadow in the same shader as a 2D sun or spot shadow can make every lit draw fail (a black stage). The low preset never mixes the two kinds (shadowMix: false), and a GL-error safety net falls back further if anything else fails.

Install

You need Home Assistant (admin user), a way to copy files to /config/www (the Samba share or SSH add-on), and Node.js 20+ to build.

git clone https://github.com/kichappa/ha-house3d && cd ha-house3d
tools/install.sh [email protected]:/config/www/house3d      # or a mounted folder; Windows: tools\install.ps1
HASS_URL=http://homeassistant.local:8123 HASS_TOKEN=<long-lived token> python3 tools/setup_dashboard.py

setup_dashboard.py creates the House 3D sidebar dashboard (an iframe on /local/house3d/index.html) and two hidden admin dashboards that store the plan and scan jobs. Run both commands again after updating: HA caches /local for 31 days, so each build gets a new URL.

Then open House 3D and press the sliders button for the editor. Draw your rooms, add lamps and devices, link each to an entity ("Real device"), and press Save & apply.

  • Plan format: docs/plan-format.md. The demo home, web/public/plans/demo.json, is a full example, and tools/check_plan.py checks a plan for furniture in walls, overlaps and blocked doors.
  • Develop: cd web && npm ci && npm run dev. The demo runs with npm run dev:demo, and npm run build:demo builds the static site in dist-demo/.

Photos → plan

  1. On the dashboard, press the camera button, pick a room and upload photos. They go to HA's media folder; create /media/house3d/scans first.
  2. A worker on a PC with an NVIDIA GPU picks up the job:
    pip install -r tools/pipeline/requirements.txt     # after installing torch for your CUDA
    HASS_URL=... HASS_TOKEN=... python tools/pipeline/worker.py   # Windows: tools\pipeline\worker.ps1
    
  3. The worker runs heic2jpg.py → reconstruct.py (VGGT: camera poses and a point cloud, ~1 min on an RTX 5070 Ti) → place.py (OWLv2 detections, aligned to your plan's room).
  4. The proposal appears in the editor for review.

Model licences. VGGT's code allows commercial use (except military), but the facebook/VGGT-1B weights are CC BY-NC 4.0: non-commercial only. For commercial use, swap in the separately licensed facebook/VGGT-1B-Commercial. OWLv2 is Apache-2.0.

TV colour watcher & TV/soundbar setup

tools/tv_setup.py sets up each TV for you. It describes your TV setup to House 3D (the TV, an optional soundbar, a remote, and where volume goes) and, if you want, installs the TV colour watcher. The watcher is a small script that runs on the TV box. It averages the top of the picture on the box itself and sends only {r, g, b, dark} to a Home Assistant webhook, and a lamp behind the TV takes that colour. No pixels leave the TV. One file, Python standard library only.

You need:

  • An Android TV / Google TV box with network ADB on (Developer options → network debugging), and adb on the computer that runs the tool. The script was written on an onn 4K Plus (Android 14).
  • HA's Android TV integration (ADB) for the box: its media_player runs androidtv.adb_command.
  • Optional: the Android TV Remote integration for the D-pad, a colour lamp for the backlight, and a soundbar or AVR media_player.
  • A long-lived access token (your HA profile → Security). Inside an HA add-on, use HASS_URL=http://supervisor/core and the add-on's supervisor token instead.
export HASS_URL=http://homeassistant.local:8123 HASS_TOKEN=<long-lived token>
python3 tools/tv_setup.py add                       # asks about each TV; prints the plan of changes
python3 tools/tv_setup.py add --config tvs.yaml     # or flags: --slug --name --address --media-player --remote --light --soundbar --volume
python3 tools/tv_setup.py add ... --apply           # makes the changes
python3 tools/tv_setup.py list                      # TVs set up by the tool
python3 tools/tv_setup.py remove <slug> --apply     # undoes it, stops the script on the TV and deletes it

Nothing changes without --apply. The default is a dry run that prints every change first. For each TV, add checks ADB, pushes the script (tools/onn/topcolor_v2.sh; --script picks another) to /data/local/tmp/ and tests it. It then creates the helpers input_boolean.<slug>_backlight_follows, input_number.<slug>_colour_interval and <slug>_colour_band, input_select.<slug>_backlight_target (which light follows) and input_select.<slug>_colour_fade (100 / 250 / 500 ms, default 250; set in HA, not the dashboard), a random webhook id, and two automations. "Backlight follows the picture" colours the target lamp from the webhook. "Colour watcher keeper" restarts the script over ADB after a reboot while the TV is on, and passes it the helpers. It also creates script.<slug>_volume_step and links everything in the dashboard. Without a lamp, it skips the watcher and only sets up the remote and volume. Settings stay in tools/tv_setup.<slug>.json (git-ignored; it holds the webhook id).

The script reads the screen in one of two ways. screenrecord raw frames give 5 samples a second, but their format and orientation differ between devices. add runs the script's probe while the screen is on and uses raw frames only when they check out; it needs a picture with dark rows at one end, such as a letterboxed film or a menu bar. Otherwise it uses screencap (about one sample a second) and prints how to switch later (--mode auto --flip 0|1).

Volume routes (--volume): the TV sheet's volume rocker calls script.<slug>_volume_step with steps: +1 / -1.

Route Sends
tv media_player.volume_up / volume_down to the TV's media player
soundbar volume_set on the soundbar from its current level when HA knows it, else volume_up / volume_down
adb-cec input keyevent 24/25 on the TV over ADB; HDMI-CEC passes it on to the soundbar or AVR
remote remote.send_command VOLUME_UP / VOLUME_DOWN (Android TV Remote)

Linking in the dashboard: link the TV and the lamp in the editor first (Real device), then run add. It finds the plan items by their links. If it can't tell which item is which, pass --tv-item / --light-item. It sets remote, volumeScript and tvColour on the TV item and follow on the lamp. Then the TV's sheet shows a remote and "Backlight from the picture" with that TV's own switch and helpers (plan format). The tool reads the stored plan again just before writing, and stops if it changed meanwhile. The previous plan stays in house3d_plan_prev.

Swapping the light that follows. "Light that follows" in the TV sheet lists the plan's colour lamps and sets the target helper; the automation reads it for every colour, so a swap needs no edit in HA. The "Follow the TV picture" switch moves to the lamp that follows now. When the picture is near-neutral (sky, white walls) the v2 script can send k, a colour temperature; the lamp then shows that white, clamped to its own range.

Transitions, per lamp. The automation picks the lamp's route when each colour arrives (mode restart, so the newest colour wins; the v2 script already eases between colours on the TV):

  • A per-lamp restart-mode step script script.lamp_step_<lamp>, if it exists. It gets transition: 0, except on an IKEA KAJPLATS.
  • An IKEA KAJPLATS without one goes through script.light_soft_fade_step, if you have one. A KAJPLATS turns reds and oranges green partway through a native fade, and an instant change makes it overshoot to about twice the brightness for half a second. So it gets a short fade (0.4 s, or the fade helper if longer) through the step script, which keeps it only where it is safe. light.turn_on never sends a KAJPLATS a transition.
  • Any other lamp: light.turn_on with hs_color (or color_temp_kelvin) and brightness, and the "Fade" from the TV sheet (Off / 150 / 300 ms) as its transition. TP-Link Tapo bulbs ignore transitions anyway.

Credits

License

MIT.

관련 프로젝트 살펴보기

불러오는 중…