Yesterday I started getting message notifications that a specific device is not responding. I looked through all the advanced flows I could think of to find the ghost message, to no avail. AI wrote me a short script to search all the flows for a specific phrase, and I found the culprit message source in a second or less.
I thought I would share the script here if someone needs a similar function.
Copy the script below and paste it into a Homey Script “‘Run my code’ with ‘MyArg’ and return Text-tag’”
Input Argument: Create a text tag with a simple json containing the search phrase, pass the text tag as the “argument”.
Add a Text-tag to receive the output of the script
Execute the flow and read the results in the text-tag.
It saved me hours of searching.
SCRIPT
// Search flows for phrase
let settings;
try {
settings = JSON.parse(args[0]);
} catch (e) {
return JSON.stringify({
error: “Invalid JSON argument”
});
}
const searchText = String(settings.search || “”).toLowerCase();
if (!searchText) {
return JSON.stringify({
error: “No search string supplied”
});
}
const result = {
search: settings.search,
matches: 0,
flows:
};
// ---------- Regular Flows ----------
const flows = await Homey.flow.getFlows();
for (const flowId in flows) {
const flow = flows[flowId];
const flowJson = JSON.stringify(flow).toLowerCase();
if (flowJson.includes(searchText)) {
result.flows.push({
type: "flow",
name: flow.name,
id: flow.id
});
}
}
// ---------- Advanced Flows ----------
const advancedFlows = await Homey.flow.getAdvancedFlows();
for (const flowId in advancedFlows) {
const flow = advancedFlows[flowId];
const flowJson = JSON.stringify(flow).toLowerCase();
if (flowJson.includes(searchText)) {
result.flows.push({
type: "advancedflow",
name: flow.name,
id: flow.id
});
}
}
result.matches = result.flows.length;
return JSON.stringify(result);



