Trashcan Reminder future dates

I am a happy user of the Trashcan Reminder 2.0 app for the notifications on my phone for when the trash will be picked up.

Until recently I had a Home-Assistant dashboard, where I had a card which showed, for each type of trash, the future pickup dates (today or later). Currently, I am making the switch to a homey dashboard (Hdashboards.app). I got all the functionality I had on HA, working on the new dashboard, except for the trash pickup card.

I see that the trashcan reminder app has all the correct pickup dates available, but the app itself only gives the option “today, tomorrow, or day after tomorrow”, not for example “01-12-2023” as next date.
There is a JSON available with all the dates, but I have no clue how to get the data out of there.

Anyone has any tips how I could achieve this?
As long as I can get the next date for, for example, Plastic as a tag or something like that; then I should be able to get it shown on my dashboard.

Any help is very much appreciated!

My wish also

I think you can better ask here: Trashcan Reminder 2.0 | com.trashchecker
This is the support address that’s on the app page.

Unfortunately, I cannot find anywhere on there where I can post the question

Then click on the link “View on GitHub”. And there you can ask your question.

1 Like

Hi all, just to clearify

You would like a variable for trigger, such as: textile, organic or plastic - so you can use the value of this for future/following flows?

I want to show the next date for the trash pickup on my dashboard. So one date for plastic, 1 for organic, etc. The date should either be today, or the first date after today.

To be able to show it on the dashboard, i somehow need to obtain that date in some format. Then I can indeed use it in a flow, or virtual device, or something like that.

Hey,

I have no experience with HDashboard, so I do not know how to get the string value to there. (Perhaps via an advanced virtual device or something?)
However, I do know how to use HomeyScript to fetch the data the Trashcan Reminder 2.0 app shows as debug info and use that to get the next date per type.

First get yourself an API key via Settings/API Keys ( https://my.homey.app/homeys/HOMEY_ID/settings/system/api-keys ) with permissions to View and Control Apps (make sure you’re logged in as the owner of the Homey and I believe you need a 2023 pro homey for this)

Then go to Scripts and create a new one ( https://my.homey.app/homeys/HOMEY_ID/scripts ) (make sure HomeyScript is installed)

const LOCAL_IP = '___YOUR_LOCAL_HOMEY_IP_GOES_HERE___';
const localIpDashed = LOCAL_IP.replaceAll('.', '-');
const API_KEY = '____API_KEY_GOES_HERE_____';
const collectingDays = await (await fetch(`https://${localIpDashed}.homey.homeylocal.com/api/manager/apps/app/com.trashchecker/setting/collectingDays`, {
  method: 'GET',
  headers: {
    "Content-Type": "application/json",
    'authorization': `Bearer ${API_KEY}`
  }
})).json();
const nextCollectingDay = Object.fromEntries(Object.entries(collectingDays).map(([type, days]) => {
  days.sort();
  return [type, days[0].split('-').reverse().join('-')];
}));
console.log(nextCollectingDay);

Then in the console you’ll see something like

{
  PMD: '14-12-2023',
  GFT: '13-12-2023',
  PAPIER: '15-12-2023',
  REST: '22-12-2023'
}

I hope that helps somewhat with getting things to work.
If you have an idea of how to get the string to the HDashboard and/or experience difficulties, let me know.

1 Like

Wow thanks! Indeed exactly what I was looking for.
I installed the HomeyScript app, but i still have a question regarding the mentioned API.

What kind of API are you referring to? Of the Homey itself?
I have a homey (early 2019). Would it work with the Local API App for example?

And how would you setup a flow that would translate those 4 dates (console output) into a (advanced) virtual device?

Edit: For me it’s also okay if it’s not linked to trashcan reminder app. If I can simply type the list in homey script (once a year), and that the homeyscript looks up the next date (today or later) and outputs that; then that also works.
Guess i’ll have to investigate further into HomeyScript, to see how it works.

I made a homeyscript using chatgtp (since I do not know much about this language). Would the following work?:

// Specify a list with 10 pre-defined dates
const dateList = [
new Date(‘2023-01-01’),
new Date(‘2023-02-15’),
new Date(‘2023-03-10’),
new Date(‘2023-04-05’),
new Date(‘2023-05-20’),
new Date(‘2023-06-15’),
new Date(‘2023-07-01’),
new Date(‘2023-08-10’),
new Date(‘2023-09-05’),
new Date(‘2023-10-20’)
];

// Get the current date
const today = new Date();

// Find the first date after today in the list
let selectedDate = null;
for (const date of dateList) {
if (date >= today) {
selectedDate = date;
break;
}
}

// Save the selected date as a variable
let DatumPickup= selectedDate ? selectedDate.toISOString() : null;

// Output the result
console.log(‘Selected Date:’, DatumPickup);

Done. I run this in a homeyscript block that returns a text-value.

// Specify a list with pre-defined dates

const dateList = [

new Date(‘2023-01-01’),

new Date(‘2023-02-15’),

new Date(‘2023-03-10’),

new Date(‘2023-04-05’),

new Date(‘2023-05-20’),

new Date(‘2023-06-15’),

new Date(‘2023-07-01’),

new Date(‘2023-08-10’),

new Date(‘2023-09-05’),

new Date(‘2023-10-20’),

new Date(‘2023-12-04’),

new Date(‘2023-12-20’)

];

// Get the current date

const today = new Date();

// Find the first date after today 00:00 in the list

let selectedDate = null;

for (const date of dateList) {

if (date >= today) {

selectedDate = date;

break;

}

}

// Format the date without the time yyyy-mm-dd

const formattedDate = selectedDate ? selectedDate.toISOString().split(‘T’)[0] : null;

// Return the formatted date

return formattedDate;

I don’t know what your script does, but I doubt it solved your problem. :wink:

Regarding the API, it seems the internal token of HomeyScript also works fine, so I adjusted the script to not require an API token anymore

As said previously I have no experience with HDashboard, but if it is capable to show any device with it’s (text-)capabilities an Advanced Virtual Device may do the trick.
To create an Advanced Virtual Device, you need to install the Device Capabilities app ( Device Capabilities App voor Homey | Homey ).

While adding a new Advanced Virtual Device, you can choose the option to import a TEF file.
You can use this code to add a device with 4 text labels for PMD/GFT/PAPIER/REST:
[tef:AVD:"H4sIAAAAAAACA4WUWZOiMBSF/wuvdlcLCSL9xuIS3HBBxKmprogRo0AQCIJT898Hp3WWLqs7L6k6J/eej7okP4QtKahPkM9i4VXowwxp78vQgDirJMUY6WY7nLvxMkMb0mhCwxswa4YGTqjZ6hgdTNLZTz0LzZBRKJdkesKE2BZbX6Cygg1c7UlROqaz2KhESuR+sRWlfuxvWoW9tOY8upyhPSx4FamrFZ2v9WChzXVE22sTTr3zoOJufCiqk9cID5oSVkvPshbnnTcBpsvTpFpoC3cPS73t0heGGhvITg1vtwcqnNjVmILGugtWy4Ohj70d6+rcPSttc+QnillW5/7eZQhvmnymGN7uRYmKiyXyBABJbA4tFLdcwFdjbyYv5xo6eqV9Al6/BSPgmImm7Zc0Mvhg2p1Eg6XTGzsToI9yFBxWw5jxnEmTTc91hlt4FBdkmHTlE+6zjNCLPOof58hs8tPaoz219PTSUwMaVHYoR1XvNDYGHdR1Ej06RpKB0pnKd9ywzgjIo2nbHw5KD3e9xDNMqtO11qnQaN1Yy7lcNh1uj8/B0hePsVHax0urUuRqe1BfbMtsTweLAO61QNOEJ8HnWc6i69wz4fXHzyeBpTSgMQ7Rtv4R2r4iEZ+QZ7Jpgmfok+0zVqH6LKoqFOXWVtpiqW6SkTyncXDtIJCYpEH1VuCQk7dr2xzHufAa8zB8EmIebUg62S1ImXcpCbd1Cfwrj3/vd6P519AZCwmOHzk8z9kjw8ARSfEDY0iz/B/ZD+tdYPmepPWX5DWYOK5La63XXdwVIyU4J92QnQ2cXgt3OMzIzZyTBKe1beAEb2hIc0o+ntizs3aNyUicsT85t9v2PoI3Ubzp0i3f1mzUmd3FzxCkLxGkxwjS/wiSctPBHWFk3pXP8sGX+eBxPviQD246vOXPOvP7DOBnAPBLAPgYAH6YARDqK/D+Ft4QBiE9svo0Fl6/ff/5C2bi9SwpBQAA":/tef]

After that, make a HomeyScript “Kliko Next Days” with the following content:

const LOCAL_IP = '192.168.2.16';
const localIpDashed = LOCAL_IP.replaceAll('.', '-');
const API_KEY = Homey._token;
const collectingDays = await (await fetch(`https://${localIpDashed}.homey.homeylocal.com/api/manager/apps/app/com.trashchecker/setting/collectingDays`, {
  method: 'GET',
  headers: {
    "Content-Type": "application/json",
    'authorization': `Bearer ${API_KEY}`
  }
})).json();
const today = (new Date()).toJSON().split('T')[0];
const nextCollectingDay = Object.fromEntries(Object.entries(collectingDays).map(([type, days]) => {
  days.sort();
  days = days.filter(day => day > today);
  return [type, days[0].split('-').reverse().join('-')];
}));
tag("nextCollectingDays", JSON.stringify(nextCollectingDay));
return true;

And finally make an advanced flow that runs daily and fills the labels with the right values:


[tef:FLOWS:"H4sIAAAAAAACA8WWW4vbRhTHv0oY8rhTZkZz1VvoJmkpLSHJ22LMmZujxraMrYQ12/3uPSPJu7GjggqGNVi2pZlzzv93LuMH0pH6gYR28wt0X/CK73Q8hH2z6x9sSU1+K7c+DbduhvXbdN/92q7XKXTNdnULx8Np8cSTfg85dHu8QR7xdUOA1HcPpMHbICvFmRI0e1tRCSJQLx2jxvjsnI9WC48Wiuk/1s3X9tVf6ODVLXSpGA7FrcVNjDNOJX6j0hhJXcBLSFILFiOvnCvr7klt2Q05kpqXzyEo2BdRGP4dCTpllmKmTjOgMvhIgTtHY5WENsGLrDVZYPRCK68hVVSr4jVaQa1OQAGM5tyATDqMDpUYPEqGny167PnWG9jCKu3rdbtqAvovJFapWw6QlnnfbpZ/H9rtyA4QZv+jj9NIoUU0gcaAniVwjNjxSEXFUHxl8ZrJoof8QHaYVrTw/t1n3L58Hfftrmu/pu3r5VMwsNvVkwXwz0QyS/ZsUM4CC5gzYakUFUqXmVEvghSecZk8u9BfXVF/ANAWcqCG64xJ5xLxYwzSRZetgaBtutT/4c/b6+mHkIWKFaPRSEZReUW9DpxmcMYL8JCwUM71qyvqdyYYlYWmKUcsP4Ml6qTz1APjVkWeZax+0v/mw+9vP14PQRDSCic4ZR4wBgcWcxAk5T4KDpXMPLgLBPqKCGyqIBmjad+GsgJJPdOMJhU105IBU+YSwce3n67YA7OGxQBAjAD4OYD/dDnC2H87aQ/tNjaj/LYr+qvkvcqeUeFtopJZTa3ShnKhE5PSJI9T86T/eZo3Ea1pHBYaQkVZ9Dg+BLYwSAxfoBKvZFbgoExc2KTLodtrR/Gz3I/i2TgATyMXtsenLM6ZIzPH7cyunFm5ZcrjsoxHENoLDqNLgB1m0LfB/CI1xYKDUeQgcbK8w75PW0lo12zSMt1jJa+PY2ax1le46v+dQGNaizk0wVzN2FCSc+biELCTk2M5pu9NSLUNRqSQEkX+2F0hYRg4YSiGIrnSUUQQo6bvzb77Buth4/KA/dthqVz2bB9vbtI6PlVhWVY9l9kwn2MaarXsqsnnUnQVQWW9zZrc3Q0W63pO5dTIPuH/hLjsYLVYoPlNG4uvbdt9Gf6K3Mw7S8+ZyRdlxp+ZDWf6BDM+yWxOG81iNuv8OWemXpSZ+KHOTufgBDYxiW3OWJmFbdaZdY5Nvyg2+YxtPDsnoMlJaHOG7Axoj4+Lx38BjTPtqqIMAAA=":/tef]

I hope this solution also works with HDashboard or that you can modify it so it does work. (e.g. fill variables if it can show that)

Hi!
Tried to copy-paste the script to Homey but got an error. I’ve replaced the IP-address with my own static IP-address.

Any idea why it doesn’t accepts the script?

it is a script for HomeyScript, not for the Web API Playground.

1 Like

Hi all,
when testing the script, I get the following script error. Who can help me further?

:x: Script Error
:warning: FetchError: request to https://192-168-178-100.homey.homeylocal.com/api/manager/apps/app/com.trashchecker/setting/collectingDays failed, reason: getaddrinfo ENOTFOUND 192-168-178-100.homey.homeylocal.com
at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1491:11)
at ClientRequest.emit (node:events:517:28)
at TLSSocket.socketErrorListener (node:_http_client:501:9)
at TLSSocket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Thanks

Quite an old topic, but for the ones interested. Homey Dashboard is now live and there is a native Widget available :slight_smile:

Please provide feedback either in the Trashcan App topic ([APP][Pro] Trashcan Reminder 2.0) or on GitHub (GitHub - robertraaijmakers/com.trashchecker: Trashcan Reminder 2.0 is an app for Homey (Home Automation Hub) and gives you the ability to get notifications when your trash is being collected.).

2 Likes

Unfortunately, this again gives only yesterday/today/tomorrow; but not “on 14 oktober (in 10 days)”

1 Like

Do you set your trash on the street in two weeks?

With this widget you are able to see all next trash dates for every type. So if GFT is collected in 14 days, you will see it in the widget :wink: if it collected today and in 14 days, you will only see today. But I guess that is the most important right?

1 Like

This is indeed what i am looking for. So the app now supports this? Or just the new widget for the new dashboard?

The dashboard widget supports this now indeed! The data has always been available in the app, so you can retrieve it (just as the new widget does). But then you need to create some virtual devices somehow (some options are described above in this thread). However they are all quite complex.

Think the new widget will serve its purpose. And if someone with some UI/UX skills comes along I might make some variants.

So if you have specific requirements then please let me know. A mock-up / wireframe helps to realise the requirements :slight_smile: