Skip to content
Projets

À propos

3D digital twin for home assistant card and addon (view entities, import models, integrated floorplan editor)

Design et médias

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
+3
in 15 days
+3
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

DT3D - 3D Digital Twin for Home Assistant

Add the DT3D backend app repository to Home Assistant Open the DT3D dashboard card in Home Assistant Marketplace

  • DT3D is a Home Assistant addon and dashboard card to create a digital twin of a home.
  • Features a integrated 3D editor to create and modify the digital twin, add 3D elements, and link them with HA entities.
  • The project is split into a HA frontend card and a Home Assistant app/add-on that stores 3D scene data.
  • The system allows to create multiple spaces (environments) in the same deployment.
  • For installation and connection instructions, see the setup guide.
  • For the illustrated walkthrough and detailed settings, see the user manual.
Finished DT3D studio DT3D Model Library

System architecture

  • DT3D uses a dedicated addon to store 3D scene data separate from Home Assistant entity.
  • The frontend card communicates with the addon directly through REST API calls.
    • It is required that the addon is reachable from the Home Assistant frontend, and complies with the CORS policy.
  • Frontend card: renders the scene, provides the editor, consumes Home Assistant entity states, opens entity dialogs, and calls Home Assistant services in the same way as any other custom frontend card.
  • Backend app/add-on provides the 3D space API and persists spaces, object hierarchies, transforms, materials, viewports, space configuration and uploaded geometry.
  • The optional MCP server lets MCP clients manage those spaces and build or edit floorplans.
  • Persistent spaces and objects are synchronized to the backend.
  • Home Assistant entity state is consumed live and is not copied into the DT3D database as an alternative entity registry.

Frontend Card

  • Frontend card is built with TypeScript and uses Lit and three.js.
  • Vite library-mode build producing one ES module
  • The built custom element is registered as dt3d-card and is used in Home Assistant as custom:dt3d-card.

Build and test

  • Setup node.js and npm on your development machine.
  • Install dependencies and build the frontend card using npm install and npm run build in the frontend directory.
  • The build writes dt3d-card.js to the repository root. The content_in_root setting in hacs.json lets Marketplace detect the card alongside the backend app repository.
  • Include both files in each GitHub release tag. Marketplace uses the latest published release to detect and install the card.
  • To test, copy the bundle to Home Assistant's /config/www directory and register it as a JavaScript module resource in Settings → Dashboards → three-dot menu → Resources.
  • Hard-refresh the browser after replacing the bundle to ensure the new version is loaded.

Setup

  • Frontend card can be configured trough the GUI or using YAML in a dashboard view.
  • Choose Language under View and behavior in the card editor. Auto follows Home Assistant, then the browser language, with English as the fallback.
  • Use HTTPS for the backend when the Home Assistant page uses HTTPS; browsers block calls from a secure page to an insecure backend.
  • Sample configuration for a dashboard view:
type: custom:dt3d-card
address: http://homeassistant.local
port: 8080
service_key: <secret> # Same as the backend addon configuration
language: auto # auto, en, pt, es, fr, de, or zh
navigation_controls: orbit
vr_mode: false # Show VR entry on supported WebXR devices
ar_mode: false # Show AR entry on supported WebXR devices
ar_location_based: false # Anchor AR using a Home Assistant location entity
ar_location_entity: ""
ar_environment_orientation: 0 # Clockwise degrees from geographic north
visualization_only: false # Set to true to disable editing and object creation
hide_occluding_walls: true # Make nearby walls and their attached openings transparent in low-angle visualization views
general:
  developmentMode:
    enabled: false

VR and AR require a browser/device with immersive WebXR support and a secure Home Assistant page (HTTPS). In AR, DT3D automatically hides the sky and uses a transparent scene background so the device camera feed remains visible. Location-based AR additionally requires device location and compass permission. The selected entity must expose numeric latitude and longitude attributes.

Backend Addon

  • Addon is built using Go with Gin and GORM alongside a SQLite database.
  • Home Assistant base container on Alpine Linux
  • Header-based API authentication with X-DT3D-Service-Key
  • Optional TLS using a configured certificate/key pair or a generated self-signed certificate

Build and test

  • Go with the version supported by addon/backend/go.mod.
  • Can run directly from the development machine with go run main.go or using docker.
  • To exercise MCP model imports in the backend tests, install the converter dependencies with npm ci in addon/model-import before running go test ./... in addon/backend.
  • Run npm run export:mcp-furniture in frontend after changing the editor's furniture options so MCP clients can discover the updated presets.
  • Alternatively copy the content from addon/* to a Home Assistant /addons/dt3d directory and install as a local app/add-on.
  • Open Settings → Apps (or Settings → Add-ons on older versions), open the store, and reload it from the three-dot menu.
  • Open the local DT3D entry and select Install or Rebuild.
  • Configure at least a non-empty service_key, then start the app/add-on.
  • There is a deployment bash script that copies the backend over SSH, reloads the store, and then installs, rebuilds, or restarts the local app/add-on ./addon/deploy.sh <ssh-user> '<ssh-password>' [ha-host] [ssh-port]
    • It requires the Home Assistant Terminal & SSH app/add-on and sshpass on the development computer.

Configuration

  • The addon configuration can be set in the Home Assistant GUI or using YAML.
  • For HTTPS and certificates, follow the network and TLS section of the setup guide.
  • Here is a sample configuration for the backend add-on.
port: 8080
mcp_enabled: false
service_key: <secret> # Can be anything, used for header-based authentication
ssl_certificate: ""
ssl_key: ""
use_self_signed_certificate: false

Data Structure

  • Inside the Home Assistant app/add-on:
  • SQLite uses /data/data.db, inside Home Assistant's persistent add-on data volume. It survives add-on restarts, rebuilds, and upgrades.
  • Generated or normalized TLS files live under /data.
  • Imported binary geometry lives under /data/dt3d-geometries.
  • Certificates mounted from Home Assistant are available under /ssl.
  • The frontend can download and upload spaces as portable .dt3d ZIP archives. Each archive contains a versioned space.json database snapshot and the space's persisted assets under assets/.

Repository structure

.
├── addon/
│   ├── backend/
│   │   ├── handlers/       HTTP authentication and space/object routes
│   │   ├── models/         GORM database models
│   │   ├── repository/     SQLite persistence
│   │   └── service/        Space and object business logic
│   ├── config.yaml         Home Assistant app/add-on metadata and options
│   ├── Dockerfile          Home Assistant app/add-on image
│   └── deploy.sh           SSH-based local deployment helper
├── frontend/
│   ├── src/
│   │   ├── components/     Card, editor UI, menus, tree, and inspectors
│   │   ├── editor/         Scene, renderer, walls, materials, and measurements
│   │   ├── objects/        Persistable 3D and Home Assistant entity objects
│   │   ├── service/        DT3D API client and scene synchronization
│   │   └── locale/         UI strings
│   └── vite.config.js      Single-module production build
├── sample/                 Sample 3D assets
├── MANUAL.md               Illustrated walkthrough and feature reference
├── SETUP_GUIDE.md          Installation and connection documentation
└── README.md               Architecture and development documentation

Documentation

Explorer des projets similaires

Chargement…