[HOW-TO][Pro][Cloud] - Tool to FIX (advanced) flows after removing and re-adding devices

@Peter_Kawa Thank you for sharing this.
I will give it a try.

1 Like

For just device + ID overview use this code in HomeyScript:


const devices = await Homey.devices.getDevices();
console.log(`\nDevices overview`);
// Loop over all devices
for (const device of Object.values(devices)) {  
    // Return some properties. Just remove what you don't need
    console.log(`\nName:\t\t ${device.name} \nID:\t\t ${device.id} `);
};
return(true);

Tank you.

But when i try it in Homey at the Developers Tools i get this error.

Response

“root”:{

1 item

“error”:

string"await is only valid in async functions and the top level bodies of modules"

}

Or is this schript for the Homey app.

Oh, my bad it wasn’t clear: this is Homeyscript.
Create a new script
(@ my.homey.app hit the </> icon on the left, look for + New Homeyscript below all other scripts)
copy/paste the code,
save and run.

1 Like

@Peter_Kawa
Thank you.
It works good.

2 Likes

Thanks @martijnpoppen - I don’t know why that isn’t a native function that is built into the Homey UI

2 Likes

You’re welcome @K_S !

Wow this scripts is great! Should be applied basic to homey i think :slight_smile:

Thanks for making this!

1 Like

Thanks Martijn!

Today I re-added my Shelly devices using the new generic driver. Something that had to be done sooner or later. Thanks to your script, repairing my flows cost me so much less time.
Thanks, @martijnpoppen, enjoy the beer I bought you!

2 Likes

Thank you so much @Henk_Renting !

1 Like

Is it possible to adjust the above code that I can only search for 1 specific device name? I have so many devices (150+) that creating this list and then copy/past hangs the browser for minutes.

1 Like

@M_a_r_c_o yeah I can add a script for that. :slight_smile:

2 Likes

Alternative

@Peter_Kawa thats a good suggestion

1 Like

I got this HomeyScript as well

// Replace MyDevice with the desired device name

let deviceName = "MyDevice"


const myDevices = await Homey.devices.getDevices()

for (var iMyDevice in myDevices){

if (myDevices[iMyDevice].name == deviceName) {

log(`Device:\t ${myDevices[iMyDevice].name} \nZone:\t ${myDevices[iMyDevice].zoneName} \nType:\t ${myDevices[iMyDevice].type} \nValue:\t ${myDevices[iMyDevice].value} \nID:\t ${myDevices[iMyDevice].id}`)

}

}



1 Like

Sorry, HomeyScript I don’t use and do not want to activate it, I already are against memory limits in the Homey Pro (1GB RAM) version). Starting HomeyScript for only this, disrupt performance in my Homey.

Device search is maybe the option, but if we can replace a device id in a web dev tools script, whats the difficulty to search on device name in dev tools? (I am not a programmer, otherwise…).

2 Likes

I have send a pm (I think) earlier.

1 Like

@M_a_r_c_o
Yes saw the PM. I thought the suggestion for the device search was a good one. But i can still add a web api console script.
Will do end this week :slight_smile:

2 Likes

@M_a_r_c_o added the script to search based on device name. Added to the first message in this topic, but will link it here too: Fix flows by device name

TIP: Make sure to use unique device names. If you have duplicate names it might brick your flows.

And many thanks for your donation! Appreciated! :slight_smile:

3 Likes