-
-
Notifications
You must be signed in to change notification settings - Fork 965
Add Betzdorf (LU) source #4922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Betzdorf (LU) source #4922
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c435955
feat(source): add Betzdorf (LU) source (closes #4864)
defuuss 3d00900
feat(source): add Betzdorf (LU) source (closes #4864)
defuuss 0baa863
Create betzdorf_lu.md
defuuss b2006f6
Update betzdorf_lu.md
defuuss fbd1454
Update betzdorf_lu.py SSL Config
defuuss c09b7a9
Update betzdorf_lu.py
defuuss c383f47
reformatting
5ila5 54ea437
./update_docu_links.py
5ila5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
custom_components/waste_collection_schedule/waste_collection_schedule/source/betzdorf_lu.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
|
|
||
| """ | ||
| Support for Betzdorf waste collection schedule. | ||
|
|
||
| For more details about this platform, please refer to the documentation at | ||
| https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/betzdorf_lu.md | ||
| """ | ||
|
|
||
| from datetime import datetime | ||
|
|
||
| import requests | ||
| from waste_collection_schedule import Collection | ||
|
|
||
| TITLE = "Betzdorf" | ||
| DESCRIPTION = "Source for Betzdorf, Luxembourg waste collection." | ||
| URL = "https://www.betzdorf.lu" | ||
| TEST_CASES = { | ||
| "Betzdorf": {}, | ||
| } | ||
|
|
||
| ICON_MAP = { | ||
| "centre-de-ressources-recyclingpark-superdreckskescht": "mdi:recycle", | ||
| "dechets-menagers-hausmull-exception": "mdi:trash-can", | ||
| "dechets-biodegradables-biomull-exception": "mdi:leaf", | ||
| "valorlux": "mdi:package-variant", | ||
| "verre-papiers-altglas-altpapier": "mdi:bottle-wine", | ||
| } | ||
|
|
||
| API_URL = "https://www.betzdorf.lu/fr/waste" | ||
|
|
||
|
|
||
| class Source: | ||
| def __init__(self): | ||
| pass | ||
|
|
||
| def fetch(self): | ||
| # Fetch data from API with SSL verification disabled | ||
| # (due to certificate issues with betzdorf.lu website) | ||
| r = requests.get(API_URL, verify=True) | ||
| r.raise_for_status() | ||
|
|
||
| data = r.json() | ||
|
|
||
| entries = [] | ||
|
|
||
| for waste_type in data: | ||
| slug = waste_type.get("slug", "") | ||
| title = waste_type.get("title", "") | ||
| dates = waste_type.get("dates", []) | ||
|
|
||
| # Get icon based on slug | ||
| icon = ICON_MAP.get(slug, "mdi:trash-can") | ||
|
|
||
| # Process each date | ||
| for date_entry in dates: | ||
| date_start = date_entry.get("dateStart") | ||
| if date_start: | ||
| # Parse the date (format: 2025-11-08T00:00:00) | ||
| collection_date = datetime.fromisoformat(date_start).date() | ||
|
|
||
| entries.append( | ||
| Collection( | ||
| date=collection_date, | ||
| t=title, | ||
| icon=icon, | ||
| ) | ||
| ) | ||
|
|
||
| return entries | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| Support for schedules provided by [[https://www.betzdorf.lu/waste](https://www.betzdorf.lu/fr/waste)](https://www.betzdorf.lu/fr/waste). | ||
|
|
||
|
|
||
| ### Configuration Variables | ||
|
|
||
| *(no args required)* | ||
|
|
||
| ## Example | ||
|
|
||
| ```yaml | ||
| waste_collection_schedule: | ||
| sources: | ||
| - name: betzdorf_lu | ||
| args: {} | ||
| ``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You say disabled but you set verify=Ture and I get a ssl error when testing