[HOW-TO][Pro][Cloud] - Zigbee Route map (Homey Pro 2016 - 2019 / Homey Bridge)

NOTE: :rotating_light: This is unfortunately NOT available on Homey Pro 2023

Hi,
I saw this thread and was inspired to create a script which can do this for you.

I made 2 variants:

Instructions:

  1. Run this script in the WebAPI playground: (make sure to empty the text area first)
const main = async function () {
    console.log('Starting main function...');

    const zigbeeUpdate = await Homey.zigbee.runCommand({ command: 'UPDATE_NODES' });
    const data = await Homey.zigbee.getState();

    const homeyID = data.controllerState.panId;

    let nodes = Object.values(data.nodes).map((node) => ({
        name: encodeURIComponent(node.name),
        group: node.type.toLowerCase(),
        id: node.nwkAddr,
        nodeState: {
            id: node.nwkAddr
        }
    }));
    const edges = [];

    nodes = [
        {
            name: encodeURIComponent('Homey'),
            id: homeyID,
            group: 'coordinator',
            nodeState: {
                id: homeyID
            }
        },
        ...nodes
    ];

    if (data.controllerState && !data.controllerState.routes) {
        return 'No data found. Currently only Homey Pro (2016-2019) supported';
    } else {
        for (const [key, value] of Object.entries(data.controllerState.routes)) {
            if (typeof value === 'string') {
                edges.push({ from: parseInt(value), to: parseInt(key) });
            } else if (Array.isArray(value) && value.length > 0) {
                if (nodes.some((n) => n.id === parseInt(value[0]))) {
                    edges.push({ from: parseInt(value[0]), to: parseInt(key) });
                } else {
                    edges.push({ from: homeyID, to: parseInt(key) });
                }
            } else if (Array.isArray(value) && value.length === 0) {
                edges.push({ from: homeyID, to: parseInt(key) });
            } else {
                console.log('No routes found');
            }
        }

        const nodeIds = nodes.map((n) => n.id);
        const edgeIds = [...edges.map((e) => e.to), ...edges.map((e) => e.from)];

        nodeIds.forEach((id) => {
            if (!edgeIds.includes(id)) {
                edges.push({ from: homeyID, to: id });
            }
        });

        const buf = window.btoa(JSON.stringify({ nodes, edges })).toString('base64');
        return `https://martijnpoppen.github.io/com.homey.map.mesh#${buf}`;
    }
};

main();



  1. copy the url in the reponse and paste it in your browser. (remove quotes)
  2. Voila, you have a map of your Zigbee Routes.


Contributions
If you appreciate what I do, contribute to future development by making a paypal contribution
or buy me a coffee on Ko-Fi or Bunq.me

image ko-fiimage


:computer: Apps made by @martijnpoppen

See for more apps link below :point_down:t2: or just open the pull down.

13 Likes

Hi Martijn,

is there something which has to be changed in the script? Because this is the output:

{
  "error": "Object.entries requires that input parameter not be null or undefined"
}

Hey @DirkG
Strange, Did you select a Homey?

Does it work when you only run:

Homey.zigbee.getState()

Yes

@DirkG Can you send me the response of that in a DM?
You can copy the response by clicking the icon next to “root”

1 Like

Another brilliant script. Thx!

1 Like

Error for me:

Response

“root”:{
1 item
“error”:
string"can’t convert undefined to object"
}

This script will only work on the older Homey Pro’s (2016-2019), the data is just not available for Homey Pro (early 2023) (the object is there but empty).
Also it is a “current route map” not the mesh map, as the mesh in reality will be much bigger with more connections between devices.

2 Likes

@Caseda yep i see :frowning:
That’s a pity.
Changed the title to route instead of mesh :wink:

Yay, almost start to celebrate for HP23, anyway, great stuff!

@Sharkys yeah wish i knew that earlier :stuck_out_tongue:

1 Like

I really wonder if it’s Athom decision or “SDK” Silicon Labs issue, would be so much helpful! Mostly when reading again and again about ZigBee issue

1 Like

It is an Athom decision, getting the mesh network is a build in function (not just from a controller perspective) from ZigBee (and Z-Wave) but Athom just never implemented it, also not for the older Homey Pro’s hence it only being a “last used route map”.

2 Likes

Thank you Caseda. I understand they would like to keep it simple for “this kind of product”…but given the nature of Zigbee devices (China, not following all required standards etc.), they can’t keep it simple for users and I believe such functionality is essential. But you know it, I know it…but I guess Athom decided already.
It’s a pity then seeing those pissed users, while they complain about Homey and after all, could be device itself… and nobody can advice anything, because simply the supporting details, like a routing network, is simply not there.

2 Likes

Well, maybe it’s time for some kind of a user vote ‘post’, @Sharkys , as Athom said: “The more votes, the higher the chance we will consider fixing enabling it”
From what I understand they omitted the zigbee overview, and did not implement a mesh/route map because of the many(what is many?) questions about zigbee ‘issues’ when actually nothing was wrong. A simple “What are you looking at, and how does this work” would suffice imho

3 Likes

Very nice @martijnpoppen ! Hats off again my man. Maybe Athom can hire you to build something useful for the Pro 2023.

4 Likes

I don’t see any redundant connections between routers, which means the old Homey’s are using a suboptimal topology (cluster tree instead of mesh).

That would explain a lot, right ;-(

I wasn’t going to make any statements about that… :stuck_out_tongue:

2 Likes

[quote=“Caseda, post:8, topic:104966, full:true”]
This script will only work on the older Homey Pro’s (2016-2019), the data is just not available for Homey Pro (early 2023).[/quote]

That is a shame. It’s damned hard to figure out why my Zigbee nodes keep dropping out of the mesh, without any kind of info. I guess I have to keep bugging Athom about it.

1 Like