Skip to content

Commit

Permalink
Add Hamilton City Council source
Browse files Browse the repository at this point in the history
  • Loading branch information
danzel committed Jul 28, 2023
1 parent 5fab369 commit adb332c
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Christchurch City Council](/doc/source/ccc_govt_nz.md) / ccc.govt.nz
- [Dunedin District Council](/doc/source/dunedin_govt_nz.md) / dunedin.govt.nz
- [Gore, Invercargill & Southland](/doc/source/wastenet_org_nz.md) / wastenet.org.nz
- [Hamilton City Council](/doc/source/hcc_govt_nz.md) / fightthelandfill.co.nz
- [Horowhenua District Council](/doc/source/horowhenua_govt_nz.md) / horowhenua.govt.nz
- [Waipa District Council](/doc/source/waipa_nz.md) / waipadc.govt.nz
- [Wellington City Council](/doc/source/wellington_govt_nz.md) / wellington.govt.nz
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import datetime
from waste_collection_schedule import Collection
from waste_collection_schedule.service.SSLError import get_legacy_session

TITLE = "Hamilton City Council"
DESCRIPTION = "Source script for Hamilton City Council"
URL = "https://www.fightthelandfill.co.nz/"
TEST_CASES = {
"1 Hamilton Parade": {"address": "1 Hamilton Parade"}
}

API_URL = "https://api.hcc.govt.nz/FightTheLandFill/get_Collection_Dates"
ICON_MAP = {
"Rubbish": "mdi:trash-can",
"Recycling": "mdi:recycle"
}


class Source:
def __init__(self, address):
self.address = address

def fetch(self):

s = get_legacy_session()

r = s.get(API_URL,
params={"address_string": self.address},
)
json = r.json()

#Extract entries from RedBin/YellowBin fields
entries = [
Collection(
date = datetime.datetime.strptime(json[0]["RedBin"], "%Y-%m-%dT%H:%M:%S").date(),
t = "Rubbish",
icon = ICON_MAP.get("Rubbish"),
),
Collection(
date = datetime.datetime.strptime(json[0]["YellowBin"], "%Y-%m-%dT%H:%M:%S").date(),
t = "Recycling",
icon = ICON_MAP.get("Recycling"),
)
]

return entries
45 changes: 45 additions & 0 deletions doc/source/hcc_govt_nz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Hamilton City Council

Support for schedules provided by [Hamilton City Council](https://www.fightthelandfill.co.nz/).

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: hcc_govt_nz
args:
address: STREET_NUMBER_AND_STREET_NAME
```
### Configuration Variables
**address**
*(string) (required)*
## Bin Names example - Rubbish, Recycling
```yaml
waste_collection_schedule:
sources:
- name: hcc_govt_nz
args:
address: "1 Hamilton Parade"
```
## Bin Colours example - Red, Yellow
```yaml
waste_collection_schedule:
sources:
- name: hcc_govt_nz
args:
address: "1 Hamilton Parade"
customize:
- type: Rubbish
alias: Red
- type: Recycling
alias: Yellow
calendar_title: "HCC Bins"
separator: " & "
```
2 changes: 1 addition & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Waste collection schedules from service provider web sites are updated daily, de
| Lithuania | Kauno švara |
| Luxembourg | Esch-sur-Alzette |
| Netherlands | ACV Group, Alpen an den Rijn, Area Afval, Avalex, Avri, Bar Afvalbeheer, Circulus, Cyclus NV, Dar, Den Haag, GAD, Gemeente Almere, Gemeente Berkelland, Gemeente Cranendonck, Gemeente Hellendoorn, Gemeente Lingewaard, Gemeente Meppel, Gemeente Middelburg + Vlissingen, Gemeente Peel en Maas, Gemeente Schouwen-Duiveland, Gemeente Sudwest-Fryslan, Gemeente Venray, Gemeente Voorschoten, Gemeente Waalre, Gemeente Westland, HVC Groep, Meerlanden, Mijn Blink, PreZero, Purmerend, RAD BV, Reinis, Spaarnelanden, Twente Milieu, Waardlanden, Ximmio, ZRD |
| New Zealand | Auckland Council, Christchurch City Council, Dunedin District Council, Gore, Invercargill & Southland, Horowhenua District Council, Waipa District Council, Wellington City Council |
| New Zealand | Auckland Council, Christchurch City Council, Dunedin District Council, Gore, Invercargill & Southland, Hamilton City Council, Horowhenua District Council, Waipa District Council, Wellington City Council |
| Norway | Min Renovasjon, Movar IKS, Oslo Kommune, ReMidt Orkland muni, Stavanger Kommune, Trondheim |
| Poland | Ecoharmonogram, Poznań/Koziegłowy/Objezierze/Oborniki, Warsaw, Wrocław |
| Slovenia | Moji odpadki, Ljubljana |
Expand Down

0 comments on commit adb332c

Please sign in to comment.