Toon app: waste collection (Afvalwijzer)

Forum about the tweaking of the Eneco Toon.

Moderator: marcelr

Re: Software: modifications and extensions Toon

Postby Toonz » Fri Apr 14, 2017 3:21 pm

Hi all,

A nice Easter to all of you.
Happy to share my latest project: showing which type of garbage needs to be put at the street: paper waste, organic waste, plastic/metal/cartons or other waste.
The icon for the right type of waste is shown under the temperature at the side panel in dim state.

I am absolutely not in favour of modifying system apps but I ran out of space for a new tile ;-).
I made changes to two thermostat app files: ThermostatApp.qml and ThermostatSidePanel.qml
I added wasteCalendar.js with the actual data for waste collection at my place and the icons in the drawables folder.
All changes made to the two system files are clearly marked with '//waste display start' and '//waste display end lines'.
To make the screen more balanced I am showing the temperature a bit higher to make room for the waste icon. If there is no Icon to show the original position is used.

The attached Thermostat app is from 3.1.2. I am not sure if the app has changed over time. I suggest you to apply the changes between the two markers in your own version on your Toon.
You also need to edit wasteCalendar.js to enter the waste collection dates for your place.
The icon is updated every 2 hours, so a change will become visible between 00:00 and 02:00

I have asked my 'waste' company for an xml feed of the dates but no response so far ;-)

Happy to hear your comments/suggestions or complaints :-)

Screenshot showing the icon for plastic/metal and cartons waste:

Screenshot_with_waste.png
Screenshot_with_waste.png (29.59 KiB) Viewed 2379 times
Attachments
thermostat_show_waste_mod_V0.1.zip
(109.05 KiB) Downloaded 47 times
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Ierlandfan » Tue Apr 18, 2017 9:56 pm

My trash calendar is a little more structured so I want to use the weeknumbers and days to show the bin. I did it in Lua but qml is "a different cookie"
I was thinking something along this line:

Code: Select all
/* In accordance with ISO 8601, weeks start on Monday and the first Thursday of a year is always in week 1 of that year. Most years have 52 weeks, but some have 53. */

QDate date;
QDate::weekNumber(* weekNumber = 0) <<< Semantically wrong and compiled?(No experience with QT)
var specialdays; // like holidays and things like that
= {
//Insert special days
}

if (lookupdate != specialdays)
if (*weekNumber == afvalSoort ) 

switch (date.dayOfWeek()) { //You get the idea
case 1:
  //Monday
  break;
case 2:
  //Tuesday, it's subconcious in our head
//Show Icon
case 3:
//Wednesday, it's concious in our head, put it on the street in the evening
//Show Icon
case 4:
//Thursday morning, just in case I forgot and I am watching the thermostat
  ///Show Icon

case 5:
//Just in case like some holiday on thursday
  //Show Icon
case 6:
  //Saturday, don't bother me, too late
  break;
case 7:
//Sunday, don't bother me,
  break;
Ierlandfan
Member
Member
 
Posts: 73
Joined: October 2013

Re: Software: modifications and extensions Toon

Postby Toonz » Tue Apr 18, 2017 11:05 pm

I made a small change in the function updateWasteIcon to show the icon from ~17:00 onwards (ThermostatApp.qml):

Code: Select all
      var now = new Date( (new Date)*1 + 1000*3600*7); //current date/time plus 7 hours to show icon from 17:00 the day before onwards


@Ierlandfan: I like the idea to make a formula for the correct 'waste days' but we still need to edit special dates (holidays) in the code to make it 100% correct.
I am leaning towards the idea of putting the calendar in a separate text file which you can easily update without the need for restarting qt-gui (could be a local file on Toon or a file on your webserver)

EDIT 19/4: first bug found: waste icon isn't removed properly the next day, fix being tested.....
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Toonz » Thu Apr 20, 2017 7:52 pm

Here the next beta for the waste icon display functionality.
Installation preferably manual to keep your own version of the thermostat app (see some posts above)

Changelog:
- fix for removing the icon after 24 hours
(The function updateWasteIcon in ThermostatApp.qml was lacking proper initialisation of the variables which caused the icon to stay on screen if the next day was not a waste day.)
- waste icon is now shown from around 18:00 the day before (see post above) and is removed same time next day


To do (not in the coming 2 weeks):
- read the waste calendar from an external file instead of hardcoding in wasteCalendar.js
Attachments
thermostat_show_waste_mod_V0.2.zip
(122.74 KiB) Downloaded 27 times
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Ierlandfan » Thu Apr 20, 2017 8:40 pm

In our case they shift the pickup day for the the bin so I was thinking along this line:

function getIconName(lookupDate) {
if (lookupdate == specialweek)
// return the text "special week", show correct bin with arrow and the day+date in text (So you know there something different)
else
return afvalSoortURL[afvalSoort[lookupDate]];

But first make your script work, for some reason it doesn't show a bin. Do I have to wait untill some time of day to show up or is a killal -9 qt-gui enough to make it instant show?
Ierlandfan
Member
Member
 
Posts: 73
Joined: October 2013

Re: Software: modifications and extensions Toon

Postby Toonz » Thu Apr 20, 2017 10:46 pm

Ierlandfan wrote:In our case they shift the pickup day for the the bin so I was thinking along this line:

function getIconName(lookupDate) {
if (lookupdate == specialweek)
// return the text "special week", show correct bin with arrow and the day+date in text (So you know there something different)
else
return afvalSoortURL[afvalSoort[lookupDate]];

But first make your script work, for some reason it doesn't show a bin. Do I have to wait untill some time of day to show up or is a killal -9 qt-gui enough to make it instant show?

killall qt-gui should be sufficient as the timer is also fired at start, so the icon should be there instantly. Updated every hour thereafter.
Just double checking - did you:
- copy the new waste icons into the drawables folder?
- copy all the code blocks between "//waste display start" and "//waste display end" in both ThermostatApp.qml and ThermostatSidepanel.qml?
- added '21 april 2017 in this case' to the wasteCalender.js file? (case sensitive, no leading zeroes in day numbers)
var afvalSoort = {
"21 april 2017" : 3,
.....



Regarding your suggestion above, how do we know which week is a special week? Still needs to be hardcoded somehow I think
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Ierlandfan » Fri Apr 21, 2017 7:00 am

Well, we could check a public calender for (Dutch) special days

It's working now. The case-sensitive part did the trick, I wrote all months with leading Capital :-)
Ierlandfan
Member
Member
 
Posts: 73
Joined: October 2013

Re: Software: modifications and extensions Toon

Postby Ierlandfan » Fri May 05, 2017 1:34 pm

At domoticz.com we created a trash plugin for dashticz and Rob implemented live dates.
The json calls to several trash services are known by now, even for HVC so that takes care of the manual adding of the dates. (Including special days)
The plugin is javascript so maybe we can use the idea of the script to implement it in QT.
Ierlandfan
Member
Member
 
Posts: 73
Joined: October 2013

Re: Software: modifications and extensions Toon

Postby Toonz » Sat May 06, 2017 1:17 pm

Ierlandfan wrote:At domoticz.com we created a trash plugin for dashticz and Rob implemented live dates.
The json calls to several trash services are known by now, even for HVC so that takes care of the manual adding of the dates. (Including special days)
The plugin is javascript so maybe we can use the idea of the script to implement it in QT.

Hi,

thanks for the tip, although I haven't found the source code of the Trashcan app there, I got the idea.
Challenge is that you have to create a dedicated routine to parse the (different) responses from all different trash collector companies.

I found the right URL for mine (mijnafvalwijzer.nl), by the way, this gives the whole, full year calendar ;-).
I am happy to implement others as well if you let me know which trash collector company/website I need to access (if you PM me a valid zipcode/housenr/street for testing that would be helpful). Not sure how many people are actually using this, probably don't need to implement all.

Also need to build a data entry screen on Toon to select your waste collector and enter your zipcode / house nr etc

I also plan to list the first next collection date in text under the icon....

Looking forward to hear your views, tips, ideas for implementing this.....

Regardz,

Toonz
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby Toonz » Wed May 10, 2017 6:24 pm

TerrorSource wrote:Some traffic websites offer a free xml service.
Here's an example for fileindex.nl: https://pastebin.com/vzCvLnR2


Is on my to-do list.
Currently working on a new waste collection app which retrieves waste collection dates from mijnafvalkalender.nl.
Got the engine working now but need to add a config screen to enter your zipcode/house nr.
I will also make a selection box to select other waste collection companies/websites but each new one will need it's own function to parse the output from that http call.
It will be a separate app with its own tile showing the next three waste collection events and in dim state a big icon with the waste type for that day (if any).

I will rewrite the thermostat_mod to use the collected dates from the new app instead of the built-in dates as in the current thermostat_mod posted earlier.
In this way you can choose to use a tile or do the thermostat mod.

Regardsz,

Toonz
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Waste collection App

Postby Toonz » Tue May 16, 2017 7:46 pm

Hi all,

I hereby show you my latest addition to Toon: the waste collection app.
It is able to retrieve online the waste collection dates for all communities which are supported via mijnafvalwijzer.nl
The code is setup in such a way that other waste data providers can be easily added (happy to do this for you if you send me the URL plus a working zipcode/housenr for testing).
The app contains a tile showing the first three waste collection dates, in dim state a big icon is shown for the specific type of waste that day. On days without waste collection the tile is empty in dim state.
The icon in dim state is shown from 18:00 onwards the day before, for folks who put their waste on the street the evening before.
Dates retrieved from the internet are stored in /var/volatile/tmp/wasteDates.txt
Each day at 18:00 the app is checking for new dates and whether an icon has to be shown, the path to the icon is stored in /var/volatile/tmp/wasteDateIcon.txt
Tile in dim state and normal:
TileDim.png
TileDim.png (1.11 KiB) Viewed 1609 times
Tile.png
Tile.png (10.4 KiB) Viewed 1609 times
wastecollection_V1.0.zip
(12.49 KiB) Downloaded 23 times


Because I hate empty spaces on Toon in dim state :D I also tweaked the thermostat mod posted earlier. This mod will display a big waste icon underneath the temperature in dim state. You probably guess that the url for the image is taken from /var/volatile/tmp/wasteDateIcon.txt. This icon is update daily at 18.01 to allow the tile to refresh the data first. If you prefer this mod than of course you also need to install the wastecollection app but you don't need to put the waste collection tile on any of your homepages. For backwards compatibility I also kept the javascript waste date option but that value will be overwritten by the wasteDateIcon file if exists.

I made changes to two thermostat app files: ThermostatApp.qml and ThermostatSidePanel.qml
I added wasteCalendar.js with the actual data for waste collection at my place and the icons in the drawables folder.
All changes made to the two system files are clearly marked with '//waste display start' and '//waste display end' lines.
To make the screen more balanced I am showing the temperature a bit higher to make room for the waste icon. If there is no Icon to show the original position is used.

The attached Thermostat app is from 3.7.9. I am not sure if the app has changed over time. I suggest you to apply the changes between the two markers in your own version on your Toon.
You also need to edit wasteCalendar.js to enter the waste collection dates for your place or install the wastecollection app.
The icon is updated daily at 18.01.
Thermostat_dimstate.png
Thermostat_dimstate.png (7.49 KiB) Viewed 1609 times
wastecollection_thermostat_show_waste_mod_V1.0.zip
(123.04 KiB) Downloaded 23 times


Summarizing:
If your hometown is supported by mijnafvalwijzer.nl: {
--> install wastecollection app. Edit in the WastecollectionApp.qml your own zipcode and housenr.
--> if you want the thermostat mod as well in combination with the wastecollection app:
----> add the code between the markers in ThermostatApp.qml and ThermostatSidePanel.qml to your Toon
----> add the wasteCalender.js to the Thermostat folder just for backwards compatibility. It must be there otherwise Thermostat app can't boot up. No need to enter dates there.
----> icons are displayed from wastecollection/drawables
}
if your hometown is not supported by mijnafvalwijzer.nl (or any other provider which can be implemented): {
--> waste collection app cannot be used.
--> the only option is the Thermostat mod, plus populate wasteCalender.js with the dates for your hometown and restart the gui.
--> icons are displayed from thermostat/drawables (copy them over!!) and refreshed at 18.01
}

My next post will be shorter for sure :oops:

Regardz,

Toonz
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Re: Software: modifications and extensions Toon

Postby TerrorSource » Tue May 16, 2017 7:52 pm

Woow nice app! Going to use it for sure! :D

Maybe its better to make new topics for each new app so the replies/issues will be sorted in the topic instead of all in 1 topic.
TerrorSource
Starting Member
Starting Member
 
Posts: 41
Joined: May 2017

Re: Toon app: waste collection (Afvalwijzer)

Postby Toonz » Sun May 21, 2017 9:55 pm

Hi all,

On request of Marijn I have added support for "deafvalapp.nl".
Currently supported:
"mijnafvalwijzer.nl"
"deafvalapp.nl"

You need to edit WastecollectionApp.qml at the top to select one of these two waste providers and edit your zipcode/house nr.
Fully compatible with the thermostat_mod version 1.0 posted earlier.

While testing I found out it is possible to have two waste types collected on the same day.
But currently just the first waste type icon is shown for that day.

In the next version I will add support for two waste types on the same day.
If you want me to add more waste providers just let me know (it helps if you send me the URL to retrieve the dates).

Regardz,

Toonz
Attachments
wastecollection_V1.1.zip
(13.15 KiB) Downloaded 12 times
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Re: Toon app: waste collection (Afvalwijzer)

Postby Marijn » Mon May 22, 2017 10:36 am

Thanks for adding deafvalap.nl and i'm happy that I raised the 2 types of waste collecting issue. [emoji12]
Marijn
Starting Member
Starting Member
 
Posts: 32
Joined: July 2013

Re: Toon app: waste collection (Afvalwijzer)

Postby Toonz » Mon May 22, 2017 8:26 pm

Hi all,

I enhanced the waste collection app to show two icons in dim state if two types of waste are collected the same day.
The same change was applied to the thermostat_mod to show the waste in dim state.

Screenshots with both options enabled with one and two types of waste:
SingleWaste.png
SingleWaste.png (11.54 KiB) Viewed 1377 times
DoubleWaste.png
DoubleWaste.png (10.78 KiB) Viewed 1377 times


The main app with tile:
wastecollection_V1.2.zip
(13.23 KiB) Downloaded 17 times


The Thermostat mod (thermostat app firmware 3.7.9, apply changes manually as described in earlier posts)
wastecollection_thermostat_show_waste_mod_V1.2.zip
(117.03 KiB) Downloaded 24 times


Regardsz,

Toonz
Toonz
Member
Member
 
Posts: 163
Joined: December 2016

Next

Return to Eneco Toon as Domotica controller

Who is online

Users browsing this forum: No registered users and 1 guest