Visualizing Your Aqara + HA Setup as a Live 2D/3D Entity Graph

Evening all,

I’m sure some of you have done something similar and I have to admit I received inspiration from the Aqara “Spatial Tree” graph. I’ve been building out a pretty involved smart home around Aqara hardware and wanted a better way to see how everything is actually connected — not just a flat list of entities in HA, but a real map of what controls what, what triggers what, and what’s physically connected to which hub. The HA UI doesn’t give you that. So I built one.

Here’s what it looks like in action:

Please note that the below content is AI generated but all development was personally completed by me. It’s just easier to point the agent to my code and summarize then it is for me to type it all out.

What it is

It’s a force-directed graph — nodes are devices and entities, edges are relationships. You can switch between 2D and 3D. In 3D mode you get orbit/spin navigation with labeled floating spheres. In 2D it’s a flat draggable canvas with zoom and pan.

Every node is live. Colors update in real time as states change. When a light turns on, the node brightens. When something goes unavailable, it dims out. Click any node and you get a side panel showing the current state, attributes (brightness, temperature, preset mode, etc.), and direct controls — toggle a switch, activate a scene, change a thermostat preset, trigger an automation.

The graph I’m showing here is just the Living Room, which is heavily Aqara-loaded:

  • Aqara FP2 presence sensor (shows binary occupancy + light level as separate entity nodes)
  • Aqara W200 thermostat (climate entity + temp sensor + humidity sensor + occupancy all hanging off the same device hub node)
  • Aqara Zigbee lights — two ceiling fixtures and two sconces, all Matter-paired through my M3 hub
  • Aqara P100 door entry sensor (state + battery)
  • Aqara 2-gang switch (controls ceiling fan and patio light as separate event entities)

Beyond the Aqara gear there’s a Samsung TV, a couple Zigbee plug switches, an Amazon Echo, and then all the HA logic on top — automations, scenes, and scripts — shown as their own node types with edges pointing to what they control or trigger.


How the data works

Live state is pulled entirely over the HA WebSocket API (ws://ha-ip:8123/api/websocket). This matters because the page is served from my NAS and the REST API is blocked by CORS — the WebSocket doesn’t have that restriction. On connect it authenticates with a Long-Lived Access Token, sends a get_states request to load everything at once, then subscribes to state_changed events for live updates. No polling, no page refreshes. When HA fires a state change, the graph updates within a second.

Controls also go through the same WebSocket using call_service. Click “On” on a light node and it sends light/turn_on directly to HA over the existing connection. Same for scene activation, thermostat preset changes, automation triggers — all live.


How it’s hosted

Static HTML file, no backend, no dependencies to install. Three.js and 3d-force-graph load from CDN. The file lives on my ASUS NAS (http://nas-ip/ha-graph/) and I hit it from any browser on the local network. That’s it — one file, served by the NAS web server, talks directly to HA over WebSocket.


What’s next

Right now it’s just the living room. The plan is to expand this room by room — Scuba Shop is next since it has a lot of varied Aqara gear and its own alarm zone — and eventually build a whole-home view where each room is a node that expands when you click it.

I also have my home blueprints with room dimensions that I am thinking of overlaying for a device placement map. This would be a separate tab, not part of the 2D or 3D graph. Wondering if there is a way to automatically map out device location based on zigbee or wifi signal strength and direction to the mesh nodes. If anyone has any ideas here, would love to hear them.

6 Likes

Really cool project! Just out of curiosity, how exactly are you bridging your M3 hub into HA (Matter or HomeKit Controller)? By the way, if you ever consider a direct integration via a Zigbee USB stick, Zigbee2MQTT actually has a built-in network map feature that does something very similar for the network topology.

Have you considered packaging your project as a Home Assistant Add-on/App? It would basically just be a lightweight Docker container running a web server to host your HTML file. Alternatively, an even simpler approach would be to just drop your HTML file into the HA www folder and set it up as a Custom Panel. Both ways would allow others in the community to easily install and use your dashboard directly within HA.

One quick tip regarding the Three.js and 3d-force-graph libraries: I’d highly recommend hosting those files locally rather than pulling them from a CDN. With a CDN, your local dashboard suddenly relies on an active internet connection, and there’s always the aspect of third-party tracking. Keeping it fully local is usually the way to go for HA.

By the way, regarding the CORS issue you mentioned with the REST API – you could have easily solved that by adding your full NAS origin URL (including schema and port) to the cors_allowed_origins list in your HA configuration.yaml. But honestly, switching to WebSockets was definitely the right move anyway. Getting live state pushes is generally more efficient and responsive than polling the REST API.

Regarding your question about automatically mapping device locations based on Zigbee or Wi-Fi signal strength (RSSI): Unfortunately, that’s not really going to work in practice. The main issue indoors is “multipath propagation” – radio waves constantly bounce off walls, furniture, and people. Because of this, a device two meters away behind a cabinet will often have a worse signal than a device eight meters down the hall with a clear line of sight. RSSI just isn’t a reliable measuring tape for physical distance, and without true directional data, the calculated positions would likely be unstable and drift over time.

1 Like

Thanks for the detailed feedback — really appreciate it!

To answer your questions: the M3 hub is bridged into HA via Matter — it shows up as a Matter bridge and exposes all its child devices through that.

On Zigbee2MQTT’s network map — that’s actually what originally inspired this project. I’m on ZHA rather than Z2M so I don’t have that feature natively, and I wanted something similar but with a bit more visual depth. Good to know it’s there for Z2M users though.

The local CDN hosting is a great call — I’ll be pulling those Three.js and 3d-force-graph files down locally in the next revision. No reason to phone home for a local dashboard tool.

On the CORS note — good to know about cors_allowed_origins, I’ll keep that in the back pocket. You’re right that WebSockets was the better move anyway.

The Custom Panel idea is interesting and something I want to dig into. The Add-on route seems like overkill for my use case right now, but dropping it into www/ and registering it as a panel would be a clean way to integrate it. I’ll experiment with that.

On RSSI positioning — yeah, that’s more or less what I figured. Multipath indoors makes it basically useless as a distance proxy. I’ll take it off the wish list and focus on manual placement instead.

1 Like

Good call on the CDN. It is running locally now.

2 Likes

Lovely work

2 Likes

Great work and nice to have this visualization! Aqara hopefully will release something like that too ! Hopefully :x2fozabcpx9xrbxmdpseb3_61:

1 Like

Hey, awesome! Have you published your project somewhere, like GitHub, Gitea, GitLab, or Codeberg?

I haven’t posted it publicly. I have Git on my NAS which is where all of my code and programs are stored. I’ll be honest, I usually only develop for me and have never posted a coding application publicly. I’m not opposed to it by any means, just hadn’t given it much thought before.

I’ll run though the code and make sure it is cleansed and parameterized for public use and throw it out on GitHub.

Really appreciate your feedback and suggestions!

1 Like

Not sure if I’m allowed to share this or not, but gonna throw it out there anyways. One of the new beta test devices I am testing has this functionality built in for Aqara spaces. That is where I got the inspriation for my HA project.

This is the Aqara Spatial Tree. It’s 2D but still pretty cool.

3 Likes

Keep in mind that when you push to GitHub via Git, all commits will be visible. If you want to play it safe, copy the project folder after cleaning it up, delete the ⁠.git⁠ folder, create a ⁠.gitignore⁠ file where you exclude all files and folders that shouldn’t be published, then initialize a new Git repository and push that to GitHub.

1 Like
2 Likes