[HomeyScript] Find deprecated Flowcards before migrating to Homey Pro (Early 2023)

Hiya, I didn’t know where to put this, but I found this place to be most helpful so I thought I would add it to the mix.

I just got my HP2023 and am doing some maintenance to the old one to ensure a smooth migration.

I wanted to know which of my flows had some of the deprecated stuff, like NFC, LED-ring, and apps that will not be available on the new device.

I couldn’t find a check for that, so I wrote this bit of code and wanted to share it if anyone would like to use it. Copy/Paste it to HomeyScript and run it!

Homey.flow.getAdvancedFlows().then(flowsResponse => {
    const visitedCards = new Set(); // Keep track of visited cards to avoid duplicates
    const cardsArray = []; // Array to store card objects
    
    for (const itemId in flowsResponse) {
        const item = flowsResponse[itemId];
        const flowName = item.name; // Get the flow name
        const exportsData = item.cards;
        
        for (const cardId in exportsData){
            const card = exportsData[cardId];
            const cardItemsUri = card.ownerUri;
            const cardItemsType = card.type;
            const key = flowName + '-' + cardItemsUri + '-' + cardItemsType; // Combine flow name, URI, and type into a single string
            
            if ((cardItemsUri === "homey:manager:ledring" || cardItemsUri === "homey:app:homey.countdown" || cardItemsUri === "homey:manager:nfc") &&  
                !visitedCards.has(key)) {
                // Add card object to the cardsArray
                cardsArray.push({
                    flowName: flowName,
                    cardType: cardItemsType,
                    cardUri: cardItemsUri
                });
                visitedCards.add(key);
            }
        }
    }
    
    // Sort the cardsArray by URI
    cardsArray.sort((a, b) => {
        return a.cardUri.localeCompare(b.cardUri);
    });
    
    // Output the sorted cards
    cardsArray.forEach(card => {
        console.log("Flow: " + card.flowName + "\nType: " + card.cardType + "\nURI: " + card.cardUri + "\n\n");
    });
});

Have a nice weekend! :slight_smile:

4 Likes

Hiya JW,
I guess as it isn’t an App is is kind of Off-topic here,
But I like the Script!

Thanks for Contributing and I think it deserves an own Topic!
So therefore Moved, or better: Promoted to your Own Topic!

3 Likes