mampfes / hacs_waste_collection_schedule

Home Assistant integration framework for (garbage collection) schedules
MIT License
1.02k stars 642 forks source link

Whittlesea Council dates in HA appear 1 day early #912

Closed mikz-t closed 1 year ago

mikz-t commented 1 year ago

Hi, using the whittlesea council source, it appears that all collection dates appear 1 day earlier than the actual collection date

HA

image

Council Site (Source)

image

confirmed with my actual address along with test case address, dates are 1 day earlier for all waste collection types

5ila5 commented 1 year ago

That's interesting. I get for the same address, the correct dates reported by the integration. grafik It could be due to some kind of timezone missmatch (Tested with timezone Germany/Berlin UTC/GMT +2)

mikz-t commented 1 year ago

@5ila5 any chance you could change your timezone to GMT +10 (Melbourne) to test? i've checked my HA instance and timezone is set correctly. I'm assuming the council's website is displaying dates based on the browsers timezone.

also sorry for the noob question, but could you guide me on how i could run the python script manually, interested to see if the polling to the council's site is returning the dates in UTC or AEST (GMT +10)

5ila5 commented 1 year ago

The source file is: custom_components/waste_collection_schedule/waste_collection_schedule/source/whittlesea_vic_gov_au.py

test source (documentation):

custom_components/waste_collection_schedule/waste_collection_schedule/test/test_sources.py -s whittlesea_vic_gov_au -lt

Will run the script and return all processed entries.

I tried to change my IP address to an Australian one (using TOR) and to spoof my timezone but I still got the same output for the webpage and the source.

Are you sure, that your dates are the correct ones? Was this a one time display error?

mikz-t commented 1 year ago

ok, I've run the script from the CLI, and all dates still appear 1 day earlier for the test addresses, plus I even modified one of the test addressees to my actual on and its out by a day as well.

I've also checked date and time settings on my HA instance, all ok, also removed and reinstalled the integration.

mikz-t commented 1 year ago

@5ila5 bit of a hack workaround but I've imported timedelta and updated the date variables in the source file to read as "date=collection_date + timedelta(days=1)"

this has obviously corrected the dates for me, but I suspect the code in declaring the collection_date variable is omitting timezone info to some degree.

5ila5 commented 1 year ago

could be an option but this still produces wrong dates for other time zones. If you inspect the network traffic within your browser, are the dates correct?

The dates are requested with https://whittlesea.vic.gov.au/umbraco/api/cartomap/GetQueryResultsArcGisWasteCollection?...

the response is:

{
    "rows": [
        {
            "cartodb_id": 139,
            ...
            "zonename": "Friday Week 1: Glass - Week 1",
            "date": "2023-04-27T14:00:00.000Z",
            "recycling": 0,
            "green": 1,
            "glass": 0,
            ...
        },
        {
            "cartodb_id": 140,
            ...
            "zonename": "Friday Week 1: Glass - Week 1",
            "date": "2023-05-04T14:00:00.000Z",
            "recycling": 1,
            "green": 0,
            "glass": 1,
            ...
        },
       ...
    ],
    "time": 0,
    "fields": null,
    "total_rows": 4
}
mikz-t commented 1 year ago

@5ila5 ok i ran that i get the same dates as you,

"{\"rows\":[{\"cartodb_id\":139,\"the_geom\":null,\"the_geom_webmercator\":null,\"zonename\":\"Friday Week 1: Glass - Week 1\",\"date\":\"2023-04-27T14:00:00.000Z\",\"recycling\":0,\"green\":1,\"glass\":0,\"calendar\":\"https://www.whittlesea.vic.gov.au/media/9417/whittlesea-bin-calender_friday-w1.pdf\",\"pdf_size\":\"127.6\",\"zoneid\":null,\"start_date\":null,\"end_date\":null,\"et_id\":null,\"Ward\":null,\"District\":null,\"StateRegion\":null,\"time\":null,\"loc_unique\":null},{\"cartodb_id\":140,\"the_geom\":null,\"the_geom_webmercator\":null,\"zonename\":\"Friday Week 1: Glass - Week 1\",\"date\":\"2023-05-04T14:00:00.000Z\",\"recycling\":1,\"green\":0,\"glass\":1,\"calendar\":\"https://www.whittlesea.vic.gov.au/media/9417/whittlesea-bin-calender_friday-w1.pdf\",\"pdf_size\":\"127.6\",\"zoneid\":null,\"start_date\":null,\"end_date\":null,\"et_id\":null,\"Ward\":null,\"District\":null,\"StateRegion\":null,\"time\":null,\"loc_unique\":null},{\"cartodb_id\":141,\"the_geom\":null,\"the_geom_webmercator\":null,\"zonename\":\"Friday Week 1: Glass - Week 1\",\"date\":\"2023-05-11T14:00:00.000Z\",\"recycling\":0,\"green\":1,\"glass\":0,\"calendar\":\"https://www.whittlesea.vic.gov.au/media/9417/whittlesea-bin-calender_friday-w1.pdf\",\"pdf_size\":\"127.6\",\"zoneid\":null,\"start_date\":null,\"end_date\":null,\"et_id\":null,\"Ward\":null,\"District\":null,\"StateRegion\":null,\"time\":null,\"loc_unique\":null},{\"cartodb_id\":142,\"the_geom\":null,\"the_geom_webmercator\":null,\"zonename\":\"Friday Week 1: Glass - Week 1\",\"date\":\"2023-05-18T14:00:00.000Z\",\"recycling\":1,\"green\":0,\"glass\":0,\"calendar\":\"https://www.whittlesea.vic.gov.au/media/9417/whittlesea-bin-calender_friday-w1.pdf\",\"pdf_size\":\"127.6\",\"zoneid\":null,\"start_date\":null,\"end_date\":null,\"et_id\":null,\"Ward\":null,\"District\":null,\"StateRegion\":null,\"time\":null,\"loc_unique\":null}],\"time\":0,\"fields\":null,\"total_rows\":4}"

but the actual collection dates show the next (which is correct for this address image

the other way to see this is to click on the PDF link, these are static and it shows friday as the collection dates

5ila5 commented 1 year ago

fixed by #917 I added the 10 hours time difference (utc to utc+10).