Trashcan Calendar in Homey and HDashboard

NOTE: Because of a new API version for the script that you need to put in Homey, this will only works on Homey2023, because you need to make a manual API Key in Homey.


Introduction:


Depending on how you want to use it, you'll need to download and install different apps.

- Afval Herinnering 2.0 to see which trashcan, of course.

- Gallery If you want to use images for HDashboard (I don't use this myself) or Whatsapp (see below).

- Device Capabilities if you want it to appear on a dashboard.

- Custom logic, this is used in the flows.

- HomeyScript to use the script below.



OLD - It seems that there has been an update on Homey about the API's. Below seems to only work on the old API version.

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Additional script for the Waste Reminder 2.0 app:Borrowed from this website, which also contains a brief explanation: https://community.homey.app/t/trashcan-reminder-future-dates/95186/12?u=true


==================================

const LOCAL_IP = '192.168.X.X'; 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;

==================================

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


New script that has been created by Syntex is the following:


==================================

const LOCAL_IP = '192.168.x.x';

const localIpDashed = LOCAL_IP.replaceAll('.', '-');

const API_KEY = 'xxx-xxx-xxx-xxx-xxx-xxx-xxxx';

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();


if (collectingDays?.statusCode ?? 200 === 401) {

 console.log('Wrong api token')

 throw ('Wrong api token');

 return false;

}


const today = parseInt((new Date()).toJSON().split('T')[0].replaceAll('-', ''));


const nextCollectingDays = {};


Object.keys(collectingDays).forEach(key => {

 days = collectingDays[key].filter(day => parseInt(day.replaceAll('-', '')) > today);


 nextCollectingDays[key] = days[0];

});


console.log(nextCollectingDays)


tag("nextCollectingDays", JSON.stringify(nextCollectingDays));

return true;

==================================


Below is the outcome as I currently have it configured. As soon as it becomes shorter than 2 days, the line in question becomes white.

cvZZ0SNv55ymJiipOJNPBXY1C44tBb2wiXHJpt4a.png


Now the configuration:


We will first import the above script. To do this, you must first ensure that your Homey gets a fixed IP address. You must set this in your router. Once this is done, you can make a API Key for the new script we going to use.

Go to Homey and click on:


Then click on API Keys:


Then click on:


In the new screen give it a name and select the option below that need to be active. At this moment I have select everything, but I don't know if it can with less.

Something like this:


Click on Create, then you get the API Key, that you need to select


NOTE: You get the complete key 1 time, so when you see it, you need to copy and use it right away or save it temporary in notepad as example.


When you have copied the key temporary in notepad or somehwere else you can click on done.


Now you can continue with the script import.

Import the script. You go to Homey website: https://my.homey.app/login


Click on the +


kLRbkFSTkhXiq0gkoaS1gODBNK07eiR6OpGPwNGt.png


Then click on New HomeyScript.


Wrxuk9lLqtzvLx2VW6MNyGhRusqmY2FaVHCQNQ9B.png


Come up with a nice name and click save.


tk2KwLFoeYjHUHUJf3AqoIfyX68MZ468kFOiyAoC.png


In the new window you get, paste the script and click test.



If your Homey has been assigned a fixed IP address in your router and you have entered this correctly, as above, you should receive a script success.

On line number 3 you can fill in the API key you have copied.


When you click on </> on the left in the menu, you will go to the scripts and you should also find your own script.


Wkg4WIsCSK7gk2JbCxcRDEj5sRodNIUb8pWIIa8j.png


We are now going to configure the Trashcan reminder app.


Go to the gear


iNnQGs3yqoyRJ9cgZTDdxxRY5cxdHmiPatq2Ll5G.png


Search and Click:


kUyi5G4vhGSU6DaPXRe0pgVDIenALJVv9PLxJHKW.png


Then click on configure:


00JQxcwRQi6Fsp8qlugKL96d95b3qsFfvBY606zv.png


Enter your zip code, house number, country and source.


H7XeTAc5dyNj1SWqDmjqqnWLVa6q17nuG3ppRbeq.png


Now we are going to create a virtual device, with Device Capabilities.


Go to the gear


YKCfrGz0D0NNuwRgqSKFBtkDVXZVIT2F1oMY74mo.png


Click on the +


KNuakWVGYf9E6AfbHXYKz6SC7cavJOdt7GAzdaPB.png


Click on: New Device


pYe78ZzWrqWHql7vWmSuMcUpoFXjwDo5ypNaFlZr.png


Click on: Device Capabilities


0H02IRHVbJj11KaWbFtEGpKPaPRkW0boNpticVYD.png


Click on: Advanced Virtual Device


K8e9Xuie32qZAlVT5v5M47gnwLOSdl2UotQD6wYW.png


Click on: Connect


fMmAFCJwpBZnokRQwUYpExfhT4foiJr3FkNHfZSV.png


We're going to create a blank AVD, so click Create a Blank AVD


092XuLknAfCE7E4J5PEw1fKul0jMtsXrZPZSAy1C.png


Now give the device a name and an icon/image. As soon as the icon/image is clicked, your device has been created.


NpHI4YP6Zxn7WDR1iJGZIXW2acEQhM38CrAR4sIw.png


Now it looks like this:


G5sGKdInhufsyinxx4j1wQNOwowNBRyMFu6lGoZR.png


Now go find your virtual device and right-click repair.


iJ9otbozuNj8ThZ6P4wnP1QUBFqKKwcTcqer43CK.png


Now you will create as many text fields as you need. GFT, paper, plastic, rest, etc….

Below you can see what that looks like:


pKBaNA57pVF0FmohYcmkcLpRup0MmASQjID5HVvY.png


2ViTaQk6NYU6JhymfFHXgRWJhYcyiBBEd8SH8yOe.png


UZAC6y4Rf6zUxhn7obo5GCEFJRYmliUb1ugFpNz1.png


Once these have been created, click Save device at the bottom.


z6F4tRlxcbJCgQZDQmTgjq5wcH1FBY1s7AMKecSS.png


Once this is done, we can start working on the flows.


I am not going to write out the flows, but I will put my flows in as overlapping pictures. I mean overlapping, so you can see how they are linked to each other. Make sure you also link each flow card together to bring up the tags you need.

PLEASE NOTE: in some flow cards a space may be hidden 😉.


Qu57Vq5hHNqqDxdglpSOlqADSRLMcdGV6CSsv456.png


EuRv0vO24KxhRcz9dVBwd5XKlJs63GO7Zhlbw1P8.png


I use 2 background colors, black and if it comes within 2 days, the line will become white. You can of course ignore/skip this and then you don't have to make the 2 flow maps below.


rAmChoZq6ktqkNiRk0T1iNxhwSlf1fMji6Srzajk.png


HDasboard configuration.


Now go to HDashboard and log in, then go to the dashboard where it should be located and click on the pencil so that you enter the edit menu.


1uM44b8e3gWrtEiX4mingFv9rTTYEPPMLzcYXZ4Q.png


Then click on the +


lsq897n8X03fHLaoGvyZUlrLW3SSGEcRn0HyU7Kb.png


Now create a new multicard.


M6PKBMmtlLvtqGF1Ip8vo9aArpwXKSnN9LboSq4X.png


Multicard has been created:


jYxzrC6vARAzWFVXX23h77JND1oCWF08lS1ANlKx.png


Now we are going to add the devices.

Click on the + above add your first device.


1yPfK25XBvgQiLJQH4E4NH6FXUj8bqiaHwpxkNsR.png


Under Device (bottom dropdown), look for Kliko (as I called it).


hcXDP8ONpDIYpWt2ZQhuuD8b2TKm6rB0pKFntnGD.png


Once you have selected it, you will see that a “menu” has been added. If you click on that, you will see “wheelie bins” that you have, in my case 4 pieces.


RgP5mMqPp1TUfMkkqDlanKch4GHuep0B5K8yHS6J.png


I select the top one and arrive at the screen below:


dwsospjSHVjL2iC0FlKMMRtDpD4zfTzJ1PbSsv5Z.png


Now you have to change the title to which trashcan it is. It is therefore important to find out once when which "trashcan" is emptied, so that it is properly placed in the multicard.

Once you have added these, you can also add the others you need into the multicard. Then you can make the multicard even bigger, wider, etc., whatever you want. Make sure you leave the slider in the screenshot above turned on, otherwise you will not get the date.


If all is well, the end result should be this:


A6x6rE8DwDD9TRyV3B2d5JGuWP41kImpnonyvEXL.png


In my case it is now of course with black backgrounds, because I have set this in the flows.


We now go to the Gallery app for the images (if you want to use this).


Now we are going to upload the images that you want to use in the Gallery app. You can search for images on Google that you want to use.


Go to the gear


mmrYhYugfcPQQzXOzg0sLGiH6yT5jJ4bOrr7fUQe.png


Click on Gallery:


mjRRvjQHkWc99tWfd7bq6P6KatzTwoLiULBztc61.png


Click configure:


6rNO1ePkyki070jkCZym51fXbOSoBuIfszfUmtda.png


Click on the + to add your images:


ecrAEBVsU53VADu5QB37pE4zzLKaEZRE0g2fo6pJ.png


I personally use the images I get from Google via WhatsApp as an extra reminder. Below is the flow for WhatsApp.I assume that you have already configured WhatsApp.


5ZhmOR4gRN9qP8I5zA7gOQzuHGAnILwwlAd9gouS.png


To send Image messages to HDashboard you can use the DAN flows below.I don't use them myself.


4EZf78f6vByHnavIOB1wOSS2bCNR4M28scricw0e.png


I know there are also people who even have it sent to their TV etc...


Once it works, see how you can fine-tune it more to yourself and if you have any tips for my manual, I'd love to hear them 😊.


Regards,


Sven