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

@sschot in the first post there’s nothing mentioned about homey script

The webapi playground is mentioned as that’s the only tool currently which has rights to update flows via the webapi

And please remove the links from your posts as those link to a specific version of my script. So when I update they will still go to the old version…

Hey Martijn,
Using the webapi playground, nothing happend. Using the method as described, it works.
I can not explain and will look soon again to webapi playground again, but for the moment glad that I could fix it my way.

edit: links removed

Hey
Alright :+1:t3:

Probably rights have changed for homey script as this was never possible

1 Like

Thanks for discovering this :blush:

Apparently somehow HS indeed has some new permissions, because the scripts never worked with HS. I’ve to admit I tested it once when the script was just published back in '22.

“Meten is weten” (a Dutch saying): I just tested with a Homeyscript and it managed to replace a device in standard+adv. flows.

Note: the other script, fix-flows-by-name.js also works @ Homeyscript.

Note 2:
Both scripts still work fine @ Web API Playground…

.

@sschot Steven, the reason why you didn’t see anything @ Playground:
When running the script with the softRun option set to true: you have to open the browser’s console to view the script logs;
Otherwise nothing happens onscreen, except “Request took xxxms”
It’s mentioned right below the true/false setting:
// Open the console in your browser and the result will be shown there // Howto open console: https://balsamiq.com/support/faqs/browserconsole/

1 Like

Peter,

Thanks for your confirmation regarding Homeyscripts.

When I used playground, my flows become not updated. So I will retry this soon when continuing to change devices from HP back to Dirigera.

Will post my final findings later on. Do you start the script with right click and start?

1 Like

Maybe run it using Playground and share screenshot from developer console from the Browser - eg. those showing some errors, that would also understand this better.

Problem determined, was not using true and false in the right way within Playground. Now both Playground and Homeyscript are working.

Thanks for all effort, sorry for my questions, this was all new for me!

2 Likes

I can confirm that it works in the Homey script. I created the script, entered the device ID or name, set it to false, saved it, and when you run the test within the script, it changes the flows where this device is connected. No need to do anything else.
Nice work :blush:.

1 Like

Hi.

This looks exactly what i want but i can´t seem to get it to work. I first tried with my heatpump to no avail, so now I´m experimenting with two virtual devices, that wouldn´t make a difference right? (They are same type and functions).
Collected the ID´s of the respective unit and pasted the “raw” version of the script from github. When running softRun = true i get no errors and it shows the simple flow it´s going to change but when changing to false, i get errors. Not sure what to do now, hope someone can help :slight_smile:

This is the error i get

@Matte_H sorry but i can’t tell you what is wrong that totally depends on your setup and your flows and devices

Ah, ok. Will try to search for other options. Now i saw …FIX (advanced) flows… on the headline. Does this only fix advanced flows? Those i tried were simple flows

@Matte_H advanced is in between brackets right? :stuck_out_tongue:
So it’s both

But if you want help from the people here, it’s best to share your flows and maybe also share the flow data so we can see what’s wrong

1 Like

Hi @martijnpoppen, yesterday I used your script for the first time. It worked great (after switching softRun from true to false:joy:) and it’s so much helpful! Thank you very much!

1 Like

@DirkG thanks! This should be default functionality in my opinion :stuck_out_tongue:

1 Like

Definitively

1 Like

Thanks for this great script. I have asked for that and it looks a lot of people are happy. Since I am not a programmer and I must say a bit overwhelmed by this script a question. Did anybody asked Athom if there is an option to build this into the software? Or does anybody from Athom reads this and is willing to help less IT software programming people?

@Ringler I think Athom is aware of this script and a lot of people have asked for such a feature. Until today there’s no alternative for this.

I understand that you might be overwhelmed by the script. However you only need to add 2 ID’s and change one field from true to false to let this script function.

Dear Martijnpoppen. Thanks for your reply. Yes, I think I should be able to use the script. Have already read through and could use it. What, and looks like I am the only one not understanding this, I was more wondering is the sequence of deleting the devices:

  1. Write down the Device ID
  2. Remove the Device
  3. Re-add the Device
  4. Get the Device ID of the new paired device

Bullet point 3 and 4. Do I need to delete the old device and add the old device again (or what means re-add?)

Sorry for that probably dumb question. Can you help? Thanks a lot :folded_hands:

@Ringler It depends on your situation of coruse. but some apps don’t allow you to add the same device multiple times to the same Homey.

So let’s take the following example.

We have a light bulb connected to homey but it doesn’t work anymore. So first we are going to get the device ID of this device. Then we remove the device from Homey. Flows will be broken after that.
Now we’re going to add the same device back to Homey (via the normal add device option in the app) and once it’s added we write down the id of this device.

hope this make it a bit more clear

Sorry. I feel too stupid. I delete the old device, then I add it again and I also add the new device? And then I run the script and then I delete the old device again? It is just a bit odd to me to add the old device again after I have deleted it (because I want to replace it with the new one). But if that sequence is required I would do so. Die I understand it correct. Sorry, for my confusion.