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

Updated @Sharkys :slight_smile:

2 Likes

It’s odd, while I had no problem running a softRun when Martijn added the feature, so I probably didn’t get what you were trying to tell :hugs:
But thanks for finding a bug✅

2 Likes

i updated 5 of mine ikea lights, and before i removed it i took both id’s. after updating and connecting to homey i tried this script. for most of my light the script work perfect. but for 2 of my light it doesnt work. the strange thing is that 2 advanced flows doesnt work and one normale flow does work.

i tried the script with the id codes and the script with the device name. both doesnt do the job.

it is also strange that when i look at the flow, the Cart not available id is the id from my button, which one you see at the left side of the picture. but that need to be an ikea light cart…

what do i wrong?

@Robin_De_Lange hard to say. It might be that the id’s were not correct or that the ID wasn’t found in the flow.

You can try the softrun option which is on top of the script.
There you can see what the script will change

1 Like

Thank you, I think I found the problem. I dont know why but my the button cart was switched with the light cart. maybe I didn’t write the good id on my paper the first time.

the key was to switch the button id with the new light id, so my button carts are gone now and the lights carts are back. de button carts is easier to put back in the flow again by hand :sweat_smile:

1 Like

Ok thats good to know.

That’s the drawback of the script :stuck_out_tongue:
I had it too while testing, broke 30 flows :joy:

Is there also a way (like this script) by changing the addresses that you can pass the data from the old device to the new one (eg for the insights) otherwise you will lose your history again.
:innocent:

@Roody that might be possible yes :stuck_out_tongue:

I’ll have a look

@Roody Unfortunately not possible. The insight will be removed once you remove the device :confused:

Okay, very unfortunate, but if you have a spare device so that you can replace it before removing.

Hi @martijnpoppen, would you have any idea why script do not work on anything like this (standard flow, THEN actions) ? It ussually works on almost anything… I wish it would be supporting also TIMER app but that probably use some else then IDs.

image
As you can see, device id is “ebb…” but using it with :

const oldIds = [‘ebb8843f-49a3-40e1-b5d5-c2e8a240d3c1’];
const newIds = [‘NEW_ID’];

…it doesn’t touch that flows at all…

Are you sure the New Device is the same Brand/Type/App as the Old device was?

1 Like

Hmm, it’s true it was app rewrite, so for sure the condition “app” might be not valid. I thought it will work simply based on the ID, just possibly not being functional action afterwards or partially broken. Just surprised that the script is actually not touching those at all if it’s ID based only.

@Sharkys it actually should replace anything it can find based on those ID’s.

1 Like

Exactly, so why it keeps the old records :wink: ? It’s true that those might be the oldest I have on my Homey…
Strange is that it always worked so far fine…

Looking on the JSON export and seems to be fine for replacement if that’s the URI part being replaced…

@Sharkys when you run this script do you see any results in the console?

To open console: press Ctrl + Shift + J (or Cmd + Shift + J on a Mac).

Thanks Martijn. Hmm, I guess I have some problem with my Homey…

One problem realized, I had enabled Rebind protection to discard upstream responses containing RFC1918 addresses. - that actually seems to disabled Homey check if Homey is connected locally or via Cloud :man_facepalming:

But that didn’t resolve the next :
softrun true

softrun false
(several attempts)

…rebooting Homey now.

I still don’t get why other replacements worked before/works…

Will report back if I find anything else.

1 Like

Strange…today I was fixing another flows for another devices (I (re)moved some of my Zigbee routers ;-))) )…it worked…then I came back to the device I originally tried to fix - again soft run is OK, but real run - getting errors :

obrazek

Is the /flow/flow part right ?

await Homey.flow.updateFlow({ id: f.id, flow: { id: f.id, actions: actions } });

The script runs fine when commeting out actions part for updating actions cards…???

I will probably fix it manually but still I find it interesting.

1 Like

Will have a look!

1 Like

Martijn I know what is different when it doesn’t work. I’m actually trying to fix same device BUT from different app ! It’s for sure the reason, do you think that this could be somehow adjusted for such cases ? Might be VERY useful mainly when some devs have abandoned their apps and are even not willing to transfer - it means new app is available then but as you know, with completely different ID…so even the device type, flows, triggers etc. are the same, script doesn’t work.
Btw I will try also based on name script, if that will not resolve the issue…
udpate so nope, even based on name it do not work.