Skip to content
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

Initial support for Slam (Sludge) pickup/week handling #2355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

morotsgurka
Copy link
Contributor

I got a question if it was possible to also get the sludge pickup date. I looked into it with the Borås Test 3 address. It does not return a NextWastePickup date but it does return a week number in WastePickupFrequency eg "Vecka 27".
There was already an implementation when i merged SSAM into edpevent_se where the NextWastePickup can be returned as "v32 Aug 2024". The previous implementation checked if it contained the letter "v" and then created a date from the string using a month map etc. I built on top of this to also work with a simple "Vecka 27" return value.

Not sure if this is the optimal solution for this? I guess this is a bit hard to solve for everything since different municipalities might write their NextWastePickup in a different way.

@@ -192,19 +192,38 @@ def fetch(self):
response = requests.get(getUrl, params=params, timeout=30)

data = json.loads(response.text)

#print(json.dumps(data, indent=2))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#print(json.dumps(data, indent=2))
#print(json.dumps(data, indent=2))

Looks like a debug left over.


# When no date is provided, check the frequency for week number
if(next_pickup == ""):
#print(item["WastePickupFrequency"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug left over

# Check if it contains the swedish word for week
if date_parts[0].lower() == "vecka":
# Assemble date from week number
#print("Week number: " + date_parts[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again. Debug left over.

#print("Week number: " + date_parts[1])
current_year = datetime.now().year
next_pickup_date = datetime.strptime(f"{current_year} {date_parts[1]} 1", "%Y %W %w").date()
#print("Next pickup date: " + str(next_pickup_date))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again. Debug left over.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i left the debug messages but commented them out since I thought they could be of use if this (somewhat hacky version to get the date from week numbers) doesn't work for some provider/municipality. But if it's preferred to not include them then sure

@5ila5
Copy link
Collaborator

5ila5 commented Jul 30, 2024

You could put the debug messages in the debug logs: _LOGGER.debug("DEBUG MESAGE")

I think cleaning the fetch function a bit might be a good idea here. Moving out some conventions in additional functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants