[HOW-TO][Pro][Cloud] - Z-Wave Route map

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...');
    
    let state = await Homey.zwave.getState();
    let data = await Homey.zwave.runCommand({
        command: 'getNetworkTopology'
    });
    
    let failed = Homey.zwave.runCommand({command: 'getFailedNodes'});

    let nodes = [];
    let edges = [];
    let homeyID = 1;

    for (const [key, value] of Object.entries(data)) {
        if (value.base === true) {
            homeyID = parseInt(key);
        }
    }

    for (const [key, value] of Object.entries(data)) {
        const nodeState = get(state, `zw_state.stats.node_${parseInt(key)}_network`, null);
        let group = parseInt(key) === homeyID ? 'coordinator' : 'router';

        // if (value.base === true) {
        //     group = 'disconnected';
        // }

        nodes.push({
            name: encodeURIComponent(value.name),
            group,
            id: parseInt(key),
            nodeState: {
                id: parseInt(key),
                ...nodeState
            }
        });


        const routes = value.props.route.reverse();
        let filteredRoutes = routes.filter((route) => route !== 0);

        if (!value.base && filteredRoutes.length) {
            filteredRoutes.unshift(parseInt(key));
            // start from 1 because we want to start from the second element
                for (let i = 1; i < filteredRoutes.length; i++) {
                    edges.push({
                        from: parseInt(filteredRoutes[i]),
                        to: parseInt(filteredRoutes[i - 1])
                    });

                    console.log(value.name, 'Adding edge from', parseInt(filteredRoutes[i]), 'to', parseInt(filteredRoutes[i - 1]));
                }
        } else if (!value.base) {
            edges.push({ from: homeyID, to: parseInt(key) });

            console.log(value.name, 'Adding edge from', homeyID, 'to', parseInt(key));
        }
    }
console.log({ nodes, edges })
    const buf = window.btoa(JSON.stringify({ nodes, edges })).toString('base64');
    return `https://martijnpoppen.github.io/com.homey.map.mesh#${buf}`;
};

const get = function (obj, dirtyPath, defaultValue) {
    if (obj === undefined || obj === null) return defaultValue;
    const path = typeof dirtyPath === 'string' ? dirtyPath.split('.') : dirtyPath;
    let objLink = obj;
    if (Array.isArray(path) && path.length) {
        for (let i = 0; i < path.length - 1; i++) {
            const currentVal = objLink[path[i]];
            if (currentVal !== undefined && currentVal !== null) {
                objLink = currentVal;
            } else {
                return defaultValue;
            }
        }
        const value = objLink[path[path.length - 1]];
        return value === undefined || value === null ? defaultValue : value;
    }
    return defaultValue;
};

main();


  1. copy the url in the reponse and paste it in your browser. (remove quotes)
  2. Voila, you have a map of your Z-Wave 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


:laptop: Apps made by @martijnpoppen

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

Again, you are moving the boundaries !!! :+1: :+1: :+1: :tophat:
Working great !

Question : who has the biggest map ? I remember there were some users with really big Z-WAVE mesh :wink: Would be nice to see the visualization !

Thanks!

And yes feel free to share your setups in this thread!

Big meshes will never be shown here :face_holding_back_tears:

Error: URI Too Long

Ah nice :confused:

Im encrypting the JSON data to base64, probably not allowed.
I guess you see the issue in the developer portal right?

No, when I try to look at the url, it is github spouting that.

@Caseda can you share your url in a DM? Then i’ll try tomorrow to fix it :slight_smile:

@Caseda fixed the script. Should work now with long URI’s

Martijn, super nice. hopefully someday we can use the zigbee variant on HP23 as well.

by the way, is it weird that i have 2 separate mesh connections?

@Ranney Let see what you have! haha

@Robin_De_Lange Thanks!
that is strange indeed!

Can you run this code in the developer portal and send me your output in a DM? :slight_smile:

const main = async function () {

let state = await Homey.zwave.getState();

let data = await Homey.zwave.runCommand({command: 'getNetworkTopology'});


return {data, state}
}

main();

Haha, really nice script!! Just tried it in Safari. The script is running but the URL is not working. Also not working in Google Chrome. In Chrome it is working great! I don’t know how to interpret the picture. Overall I can say that devices (on the map) far away of homey are in fact close to Homey and visa versa. But hey, everything is working fine :wink:

Thanks for making this script! If I understand it right, the Zigbee script is only for the Homey <2023 series?

Here my Z-Wave device:


s

@Ranney correct Zigbee map is not working on HP23 (yet)

i need to make a small fix to prevent it from showing 2 different meshes. but will probably be done tonight :slight_smile:

Great and looking forward to it! Maybe that you can combine some scripts? So we can download a complete (pdf report?) overview of all devices, route maps and debug info? Anyway really nice script and work! Will donate you later (have to go to work now) Thanks :muscle:

This is the Z-Wave route map of my Z-Wave devices (79 pc., HP23):

And just one mesh.

Looks amazing. But script errored on my HP23 (using Z wave variant):

"root":{

1 item

"error":

string"The string contains invalid characters."

}

@Jonathan_Draper
Can you run this code in the developer portal and send me your output in a DM? :slight_smile:

const main = async function () {

let state = await Homey.zwave.getState();

let data = await Homey.zwave.runCommand({command: 'getNetworkTopology'});


return {data, state}
}

main();

@Ranney @Robin_De_Lange updated the script. shouldn’t show separate networks anymore.

@Robin_De_Lange tested with your data: link

haha Thanks and nice! when I tried it again it isn’t the same as the link which you tested.

Link

@Jonathan_Draper also your issue is fixed :slight_smile:

Amazing, thank you!

Here goes: