Homeyscript hdashboard trash reminder

Hello all,

I’m trying to setup a trash reminder in hdashboards.

I have copy and paste a tutorial script into homeyscript and make a textfield into device capabilities app (with repair).

When i run the flow i got a error that homey can’t create a tag from path PMD.

What i’m doing wrong?

You aren’t returning anything in that script, so it gets the information and then does nothing else with it? Add return jsonOutput; to the end of the script.

Edit: I mean to the end of the try code block

1 Like

You mean like this:

It should be below the const jsonOutput = JSON.stringify(nextCollectionDays, null, 2); line.

Seems like it’s not on the right place

i’m sorry i never worked with homeyscript.

Replace the return jsonOutput; with

if (jsonOutput) {
  return jsonOutput;
} else {
  console.error("jsonOutput is not defined");
}

Also, add console.log("Response: ", response); under the if (!res.ok) { console.error('Error: ${res.status} - ${res.statustext}'); return; } line.

This way you can easily check which part isn’t working correctly

Remove the return jsonOutput; that is under the const res = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${API_KEY}` } }); line.

Still the same message

Maybe it’s that last line?

Replace console.log("Response: ", response); with console.log("Response: ", res);

Something changed and seems to work i think?

In my flow i still got the same error:

Use this Flow card:

And then copy the code from your RD4.js script to the inline code editor inside the Flow card. You can then replace the “Ophaaldagen (JSON)“ tag in the Logic card with the “Result“ tag from the script

Did you copy the entire code? It seems like you didn’t copy the final line that catches the errors.

Whoops, my bad.

Thank you for your patience and help :slight_smile:

In Hdashboard it looks like below: Only issui is still the null value, but maybe i could figure this out by myself.

For my own learning. If you make a script in homeyscript, you always need some values returned in the bottom of the test page?

You don’'t always need to return values, only if you need to use something the script generates later on in your Flow. If the script for example takes an argument “temperature“ and sends a request to set the thermostat to that temperature, then you don’t need to return anything.

As for the null value, I think you created a virtual device for this? Is it possible to set the “Status indicator“ to None in Hdashboards, like you can in the Homey mobile app?

1 Like

Thank you!

Yes it’s indeed a virtual device. I could switch of the indicator for it, but then also dissapear the 02-12-2025 line, and that’s the line i would like to see.

It could maybe also comes from a flow card below. I try to replace some cards, maybe it would help