mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
Add RecycleSmart
This commit is contained in:
@@ -62,10 +62,11 @@ Currently the following service providers are supported:
|
||||
- [City of Canada Bay Council](./doc/source/canadabay_nsw_gov_au.md)
|
||||
- [Inner West Council (NSW)](./doc/source/innerwest_nsw_gov_au.md)
|
||||
- [Ku-ring-gai Council](./doc/source/kuringgai_nsw_gov_au.md)
|
||||
- [Maroondah City Council](./doc/source/maroondah_vic_gov_au.md)
|
||||
- [Macedon Ranges Shire Council, Melbourne](./doc/source/mrsc_vic_gov_au.md)
|
||||
- [Maroondah City Council](./doc/source/maroondah_vic_gov_au.md)
|
||||
- [Melton City Council, Melbourne](./doc/source/melton_vic_gov_au.md)
|
||||
- [North Adelaide Waste Management Authority, South Australia](./doc/source/nawma_sa_gov_au.md)
|
||||
- [RecycleSmart](./doc/source/recyclesmart_com.md)
|
||||
- [Stonnington City Council, Melbourne](./doc/source/stonnington_vic_gov_au.md)
|
||||
- [The Hills Council, Sydney](./doc/source/thehills_nsw_gov_au.md)
|
||||
- [Wyndham City Council, Melbourne](./doc/source/wyndham_vic_gov_au.md)
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "RecycleSmart"
|
||||
DESCRIPTION = "Source for RecycleSmart collection."
|
||||
URL = "https://www.recyclesmart.com/"
|
||||
TEST_CASES = {
|
||||
"pickup": {
|
||||
"email": "!secret recyclesmart_email",
|
||||
"password": "!secret recyclesmart_password"
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, email, password):
|
||||
self._email = email
|
||||
self._password = password
|
||||
|
||||
def fetch(self):
|
||||
# login is via Google Identity Toolkit, providing username and password.
|
||||
r = requests.post(
|
||||
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword",
|
||||
json={
|
||||
"returnSecureToken": True,
|
||||
"email": self._email,
|
||||
"password": self._password,
|
||||
},
|
||||
params={"key": "AIzaSyBnup3QFYYGwnvjZi7r5a39c8b94SNospU"},
|
||||
)
|
||||
data = json.loads(r.text)
|
||||
|
||||
# take the token returned from Google Identity Toolkit to get the API auth token (JWT) from Firebase
|
||||
r = requests.post(
|
||||
"https://www.app.recyclesmart.com/api/sessions/firebase",
|
||||
json={"id_token": data["idToken"]},
|
||||
headers={"content-type": "application/json"},
|
||||
)
|
||||
data = json.loads(r.text)
|
||||
|
||||
# use the auth token (jwt) from firebase to get pickups
|
||||
r = requests.get(
|
||||
"https://www.app.recyclesmart.com/api/pickups",
|
||||
# retrieves future pickups (if scheduled), then past pickups, until per_page is reached
|
||||
# the average user is scheduled for monthly pickups
|
||||
params={"page":"1", "per_page":"5"},
|
||||
headers={"Authorization": data["data"]["attributes"]["auth_token"]},
|
||||
)
|
||||
|
||||
data = json.loads(r.text)
|
||||
|
||||
entries = []
|
||||
for item in data["data"]:
|
||||
collection_date = datetime.strptime(item["attributes"]["pickup_on"], "%Y-%m-%d")
|
||||
entries.append(Collection(collection_date, "Pickup"))
|
||||
return entries
|
||||
33
doc/source/recyclesmart_com.md
Normal file
33
doc/source/recyclesmart_com.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# RecycleSmart
|
||||
|
||||
Support for schedules povided by [RecycleSmart](https://www.recyclesmart.com/)
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: recyclesmart_com
|
||||
args:
|
||||
email: EMAIL
|
||||
password: PASSWORD
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**username**<br>
|
||||
*(string) (required)*
|
||||
|
||||
**password**<br>
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: recyclesmart_com
|
||||
args:
|
||||
email: abc@example.com
|
||||
password: 8WdpR%TZPPdM$n5*$FiRz
|
||||
```
|
||||
5
info.md
5
info.md
@@ -48,13 +48,14 @@ Currently the following service providers are supported:
|
||||
- [City of Canada Bay Council](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/canadabay_nsw_gov_au.md)
|
||||
- [Inner West Council (NSW)](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/innerwest_nsw_gov_au.md)
|
||||
- [Ku-ring-gai Council](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/kuringgai_nsw_gov_au.md)
|
||||
- [Maroondah City Council](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/maroondah_vic_gov_au.md)
|
||||
- [Macedon Ranges Shire Council, Melbourne](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mrsc_vic_gov_au.md)
|
||||
- [Maroondah City Council](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/maroondah_vic_gov_au.md)
|
||||
- [Melton City Council, Melbourne](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/melton_vic_gov_au.md)
|
||||
- [North Adelaide Waste Management Authority, South Australia](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/nawma_sa_gov_au.md)
|
||||
- [RecycleSmart](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/recyclesmart.md)
|
||||
- [Stonnington City Council, Melbourne](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/stonnington_vic_gov_au.md)
|
||||
- [The Hills Council, Sydney](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/thehills_nsw_gov_au.md)
|
||||
- [Wyndham City Council, Melbourne](./doc/source/wyndham_vic_gov_au.md)
|
||||
- [Wyndham City Council, Melbourne](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/sourcewyndham_vic_gov_au.md)
|
||||
|
||||
### Austria
|
||||
|
||||
|
||||
Reference in New Issue
Block a user