mampfes / hacs_waste_collection_schedule

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

Support request for Breckland #499

Closed danwooller closed 1 year ago

danwooller commented 1 year ago

https://www.breckland.gov.uk/mybreckland

Post Code: IP22 2LJ

I'm running HA in VirtualBox and can't find a way to run the python script, but digging into the code this looks promising...

{"jsonrpc":"2.0","id":"1671645668056","method":"Breckland.Whitespace.JointWasteAPI.GetBinCollectionsByUprn","params":{"uprn":"100091308629","environment":"live"}}

bbr111 commented 1 year ago

@danwooller

i got this response:

{
    "id": "",
    "result": [
        {
            "collectiontype": "Refuse Collection Service",
            "roundname": "BR6",
            "schedule": "FriFort1",
            "day": "Friday",
            "nextcollection": "03/01/2023 00:00:00"
        },
        {
            "collectiontype": "Garden Waste Service",
            "roundname": "BGarden2",
            "schedule": "GWFriFort2",
            "day": "Friday",
            "nextcollection": "09/01/2023 00:00:00"
        },
        {
            "collectiontype": "Recycling Collection Service",
            "roundname": "BR6",
            "schedule": "FriFort2",
            "day": "Friday",
            "nextcollection": "09/01/2023 00:00:00"
        },
        {
            "collectiontype": "Refuse Collection Service",
            "roundname": "BR6",
            "schedule": "FriFort1",
            "day": "Friday",
            "nextcollection": "14/01/2023 00:00:00"
        },
        {
            "collectiontype": "Garden Waste Service",
            "roundname": "BGarden2",
            "schedule": "GWFriFort2",
            "day": "Friday",
            "nextcollection": "20/01/2023 00:00:00"
        },
        {
            "collectiontype": "Recycling Collection Service",
            "roundname": "BR6",
            "schedule": "FriFort2",
            "day": "Friday",
            "nextcollection": "20/01/2023 00:00:00"
        }
    ],
    "jsonrpc": "2.0"
}

Looks like a response of the next 2 schedules.

danwooller commented 1 year ago

That's looks good.

I guess I need to build a system I can run python on.

bbr111 commented 1 year ago

@danwooller are the next to schedules ok? or shoud we try to make a future projection based of the informations? I can try to write the code.

danwooller commented 1 year ago

@bbr111

That response is exactly what I was expecting, refuse one week then recycling and garden the following. That dates are a little skewed because of holidays, but those are the next collection days. Thanks.

danwooller commented 1 year ago

I don't understand python, but got as far as a response:

Testing source breckland_gov_uk ... found 1 entries for house_uprn 2020-04-11: Waste Type [None]

Well beyond my knowledge for the next bit...

`import datetime from waste_collection_schedule import Collection

TITLE = "Breckland Council" DESCRIPTION = "Source script for Breckland Council" URL = "https://www.breckland.gov.uk/mybreckland" TEST_CASES = { "house_uprn": {"uprn": "100091308629", "postcode": "IP222LJ"}, }

API_URL = "https://www.breckland.gov.uk/mybreckland" ICON_MAP = { "Refuse Collection Service": "mdi:trash-can", "Recycling Collection Service": "mdi:recycle", "Garden Waste Service": "mdi:leaf", }

class Source: def init(self, uprn, postcode): # argX correspond to the args dict in the source configuration self._uprn = uprn self._postcode = postcode

def fetch(self):

    #  replace this comment with
    #  api calls or web scraping required
    #  to capture waste collection schedules
    #  and extract date and waste type details

    entries = []  # List that holds collection schedule

    entries.append(
        Collection(
            date = datetime.date(2020, 4, 11),  # Collection date
            t = "Waste Type",  # Collection type
            icon = ICON_MAP.get("Waste Type"),  # Collection icon
        )
    )

    return entries`