pippyn/Home-Assistant-Sensor-Ophaalkalender

Wrong date selected when json result from ophaalkalender is not sorted chronologically

Closed this issue · 3 comments

Hello pippyn

For 1650 Beersel (at least today) the JSON result coming back from ophaalkalender.be is not sorted chronologically. This results in wrong value in next_collection_date and thus wrong date shown in Home assistant interface

I adapted the code to loop through the whole result and select smallest date >= today instead of breaking on first date found.

I am not very familiar with Github so attaching the fix here below. Maybe it can still be improved but it seems to do the trick for me...
Modification done in "get_next_collection" function

sensor.py.txt

Thanks for this very useful sensor!

I said I wasn't familiar with Github and I was right! Just found the closed issues and realised the same problem was opened and closed before. @bverhalleman came up with a way more efficient fix!
Waiting for it to show up in HACS. This issue can be closed...

sod75 commented

Still not fixed in V1.1.4 installed via HACS while it says updated 5 days ago and the fix was added supposedly 2 months ago.

I integrated Ophaalkalender in my other sensor or just install "Home Assistant Sensor Afvalbeheer" through HACS. Could you check if this is fixed in that version?