klein0r / ioBroker.trashschedule

Calculates trash pickup dates by using an ical calendar
https://haus-automatisierung.com/
MIT License
31 stars 13 forks source link

[Potential Bug?]: Concurring trash pickups causing incorrect notifications #237

Closed sargonphin closed 1 month ago

sargonphin commented 2 months ago

I'm sure that

Integration (ical, api, ...)

iCal

The problem

Hello, sorry but... this is an odd one :B

I have found out that when there are 2 concurring trash pickups, it seems that the adapter doesn't behave correctly and thus messes up notifications systems.

In my area, Paper (blue) trash and Bio (brown) trash are picked up the same day once every 2 weeks and right after the recycling (yellow) trash. Due to the implementation of the notifications, I have to use a different source for the "1 day left" but I will elaborate later.

Here is the trash pickup calendar for my area (it's AWB Köln): image

Here is what I receive the day just before yellow pickup (in this particular case, on June 5th at midnight, when the value for "Next pickup - Days left" for recycling trash is 1) image Notice here it says "in 3 days" which is incorrect because this trash pickup was the day after. It think it should be 1? I added a 10 second pause in my scripts because I thought the value was not updating properly. Not tested yet

But anyway here are the notifications I get when the next pickup occurs: image Notice how it repeats that bio and paper are being picked up in 2 days. This is fully incorrect, the next trash in calendar is waste trash (black) in 4 calendar days.

In the iCal, the days are correct. There is no error there, even in the readout from the adapter

Here is one Blocky... block I guess :D? image

This code block exists for each trash type. Implementation is a little heavy but I wanted to have the little colored square as a quick preview when looking at the notification from far away (or when driving......... oops :B). I could simplify it by not using the squares and basically re-creating the example in the Git... Or create a function that would parse what trash are being picked up and uses a list to compare and add circles to another list then append that to a text... That's not much simpler

In the objects list I have the following: image The dates don't coincide because while trying to troubleshoot this, I have removed messages in the Telegram channel so that's why I took an earlier example. That being said, it is exactly the same today

Even though the "bug" is mostly due to the implementation nature of my notification system, if we follow the example given in Git then we end up never notified of the bio and paper trash, because by the time it is the next day after the recycling is picked up, it will be "0 days left" before bio and paper. Remediation would be to change the = by <= in the comparison but still, you'd end up notified too late and likely after they already picked up the trash

My improvement idea is that an extra folder could be added called "today" that would have the trash picked up right now at the same day (0 days left), because afterwards we are interested in the next pickup directly (1 or more days left) and then the pickup after that (or nextAfter in the current version of the adapter). This would prevent this trash pickup concurrence like the one I am facing :)

iobroker.current.log (in debug mode!)

-- Will provide tomorrow

Version of nodejs

21.4.0

Version of ioBroker js-controller

5.0.19

Version of adapter

3.3.0

github-actions[bot] commented 2 months ago

Thanks for reporting a new issue @sargonphin!

  1. Please make sure your topic is not covered in the documentation
  2. Please attach all necessary log files (in debug mode!), screenshots and other information to reproduce this issue
  3. Search for the issue topic in other/closed issues to avoid duplicates!

    Otherwise this issue will be closed.

klein0r commented 1 month ago

Please attach all necessary log files (in debug mode!), screenshots and other information to reproduce this issue Otherwise this issue will be closed.