Skip to content
NathnCPublic

About

three.js 3D house model with live Home Assistant entities, generated from robot-vacuum maps

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

House 3D

A three.js 3D model of a house with live Home Assistant entities, served by Home Assistant itself from /config/www/house3d/ and embedded full-screen in a dashboard panel. Rooms come from your robot-vacuum maps; devices (lights, plugs, sensors, cameras) are placed on the plan and show live state. There is an in-page editor for moving rooms and devices, saved per user in Home Assistant.

How it works

  • Auth. Inside a Home Assistant dashboard the page borrows the parent frontend's token (same origin). Standalone it uses localStorage.hassTokens, or asks for a long-lived access token, which it keeps in that browser only.

  • Live data. Its own websocket connection: get_states once, then subscribe_events state_changed.

  • Floor plan storage. Edits made in "Edit plan" are saved per user via frontend/set_user_data {key: "house3d_layout"}. layout.default.json is the draft used until a save exists; "Reset to draft" reloads it.

  • Draft generation. seg.py segments the Roborock map images Home Assistant renders (12.5 mm per pixel) into room boxes by colour. Use its output as the starting rooms list in layout.default.json, then place devices in the in-page editor:

    python seg.py downstairs.png upstairs.png > seg.json
  • Doors. A room's doors string is "R 1.2, B 0.4 0.9": side as seen in the edit view (T/B/L/R), metres from that side's top/left end, optional width (default 0.85 m).

Deploy

Copy index.html and layout.default.json to /config/www/house3d/ on your Home Assistant host, then add an iframe card (panel view) pointing at /local/house3d/index.html?v=1. Bump ?v= after each change to defeat the browser cache.

Screenshot check

shot.js loads the dashboard in headless Chromium, logs in with a long-lived token and saves a screenshot, optionally running a list of actions first. Set HA_URL and HA_TOKEN in the environment:

HA_URL=http://homeassistant.local:8123 HA_TOKEN=... node shot.js out.png '[{"click":"#edit"}]'

Needs playwright installed (npm i playwright).

Files

File Purpose
index.html The app: three.js scene, HA websocket client, editor
layout.default.json Example layout (floors, rooms, devices)
seg.py Segments Roborock map images into room boxes
shot.js Headless screenshot helper

layout.default.json is an invented two-floor example with placeholder entity ids. Replace the rooms and entity ids with your own.

Licence

MIT.

About

three.js 3D house model with live Home Assistant entities, generated from robot-vacuum maps

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages