Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dala318 committed Oct 6, 2024
1 parent 15cb1a4 commit 5441ec6
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from datetime import datetime
import json
import logging
from datetime import datetime

import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule import Collection
from waste_collection_schedule.exceptions import (
SourceArgumentException,
SourceArgumentExceptionMultiple,
SourceArgumentNotFoundWithSuggestions,
)
Expand All @@ -14,58 +13,10 @@
DESCRIPTION = "Source for all Avfallsapp waste collection sources. This included multiple municipalities in Sweden."
URL = "https://www.avfallsapp.se"
TEST_CASES = {
# "https://edpmypage.roslagsvatten.se/FutureWebOS/SimpleWastePickup, Andromedavägen 1, Åkersberga": {
# "street_address": "Andromedavägen 1",
# "url": "https://edpmypage.roslagsvatten.se/FutureWebOS/SimpleWastePickup",
# },
# "Boden - Bodens Kommun": {
# "street_address": "KYRKGATAN 24",
# "service_provider": "boden",
# },
# "Boden - Gymnasiet": {
# "street_address": "IDROTTSGATAN 4",
# "url": "https://edpmobile.boden.se/FutureWeb/SimpleWastePickup",
# },
# "Uppsalavatten - Test1": {
# "street_address": "SADELVÄGEN 1",
# "url": "https://futureweb.uppsalavatten.se/Uppsala/FutureWeb/SimpleWastePickup",
# },
# "Uppsalavatten - Test2": {
# "street_address": "BJÖRKLINGE-GRÄNBY 33",
# "service_provider": "uppsalavatten",
# },
# "Uppsalavatten - Test3": {
# "street_address": "BJÖRKLINGE-GRÄNBY 20",
# "service_provider": "uppsalavatten",
# },
# "SSAM - Home": {
# "street_address": "Asteroidvägen 1, Växjö",
# "service_provider": "ssam",
# },
# "SSAM - Slambrunn": {
# "street_address": "Svanebro Ormesberga, Ör",
# "service_provider": "ssam",
# },
# "Skelleftea - Test1": {
# "street_address": "Frögatan 76 -150",
# "service_provider": "skelleftea",
# },
# "Borås - Test1": {
# "street_address": "Länghemsgatan 10",
# "service_provider": "boras",
# },
# "Borås - Test2": {
# "street_address": "Yttre Näs 1, Seglora",
# "service_provider": "boras",
# },
# "Borås - Test3": {
# "street_address": "Stora Hyberg 1, Brämhult",
# "url": "https://kundportal.borasem.se/EDPFutureWeb/SimpleWastePickup",
# },
# "Kretslopp Sydost Hägnevägen 1, Sävsjö": {
# "street_address": "Hägnevägen 1, Sävsjö",
# "service_provider": "kretslopp-sydost",
# },
"Söderköping - Söderköping Kommun": {
"api_key": "12345678",
"service_provider": "soderkoping",
},
}

COUNTRY = "se"
Expand Down Expand Up @@ -135,8 +86,8 @@
class Source:
def __init__(
self,
api_key: str,
street_address: str | None = None,
api_key: str | None = None,
service_provider: str | None = None,
):
self._street_address = street_address
Expand Down Expand Up @@ -219,13 +170,17 @@ def fetch(self):
for bin in entry.get("bins"):
icon = ICON_RECYCLE
waste_type = bin.get("type")
waste_type_full = f"{address} {waste_type}"
pickup_date = bin.get("pickup_date")
pickup_date = datetime.strptime(pickup_date, "%Y-%m-%d").date()
if waste_type and pickup_date:
_LOGGER.debug(
"Adding entry for %s with next pickup %s",
waste_type_full,
pickup_date.strftime("%Y-%m-%d"),
)
entries.append(
Collection(
date=pickup_date, t=f"{address} {waste_type}", icon=icon
)
Collection(date=pickup_date, t=waste_type_full, icon=icon)
)

return entries
76 changes: 76 additions & 0 deletions doc/source/avfallsapp_se.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# EDPEvent

This is a waste collection schedule integration for the Avfallsapp API. Avfallsapp is used in multiple municipalities in Sweden.

## Current supported service providers
<!--Begin of service section-->
- `soderkoping`: Söderköping
<!--End of service section-->

<!-- `atvidaberg`: Åtvidaberg (not supported but could be added)
`boras`: Borås (not supported but could be added)
`finspang`: Finspång (not supported but could be added)
`gullspang`: Gullspång (not supported but could be added)
`habo`: Habo (not supported but could be added)
`kil`: Kil (not supported but could be added)
`kinda`: Kinda (not supported but could be added)
`knivsta`: Knivsta (not supported but could be added)
`kungsbacka`: Hungsbacka (not supported but could be added)
`molndal`: Mölndal (not supported but could be added)
`motala`: Motala (not supported but could be added)
`sigtuna`: Sigtuna (not supported but could be added)
`soderhamn`: Söderhamn (not supported but could be added)
`ulricehamn`: Ulricehamn (not supported but could be added)
`vallentuna`: Vallentuna (not supported but could be added)
`vanersborg`: Vänerborg (not supported but could be added)
`avfallsappen`:
`munipal`:
`dalavatten`:
`june`:
`nodava`:
`nodra`:
`rambo`:
`sysav`:
`upplands-bro`:
`vafab`: -->

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: avfallsappen_se
args:
kpi_key: KEY_FROM_MOBILE_APP
service_provider: SERVICE_PROVIDER
```
### Configuration Variables
***kpi_key***
*(string) (required)*
**street_address**
*(string) (optional, not used at the moment)*
**service_provider**
*(string) (optional)*
## Examples
Support for Söderköping's municipality waste collection schedule.
```yaml
waste_collection_schedule:
sources:
- name: edpevent_se
args:
api_key: 1564ad55f23454
service_provider: soderkoping
```
## How to acquire a valid API_KEY
In your mobile phone app, navigate to "Om appen" in the options section and copy the "Enhets-ID"

0 comments on commit 5441ec6

Please sign in to comment.