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

Add Cleanprofs data to Afvalwijzer #393

Closed
HenkdeVlaam opened this issue Feb 17, 2025 · 20 comments
Closed

Add Cleanprofs data to Afvalwijzer #393

HenkdeVlaam opened this issue Feb 17, 2025 · 20 comments
Labels
enhancement New feature or request

Comments

@HenkdeVlaam
Copy link

Feature request

Now that the Afvalwijzer runs on our Home Assistant instance we would like to have the information of the Cleanprofs added to the integration.
After some search on Github we found a Cleanprofs integration for the MMM (Magic Mirror Module) See: (https://github.com/gertperdZA/MMM-Afvalwijzer)
It would be nice if this function can be integrated in the Afvalwijzer for Home Assistant without the need for installing the MMM integration in Home Assistant in order to keep things less complex.

What version of the integration are you using?

Afvalwijzer 2025.01.01

Anything in the logs that might be useful for us?

Additional information

No response

@HenkdeVlaam HenkdeVlaam added the enhancement New feature or request label Feb 17, 2025
@Dennis-Rosenbaum
Copy link

Extra context

I have added the Cleanprofs integration to the MMM-Afvalwijzer module.

The data from Cleanprofs can be retrieved through a simple API call. No API key is needed whatsoever. After calling the API, the Cleanprofs data is appended to the afvalwijzer data. Just with a visual of a waterdrop.

This is how it looks on the Magic Mirror:

Image

API Example

https://cleanprofs.jmsdev.nl/api/get-plannings-address?zipcode=${zipCode}&house_number=${houseNumber}&start_date=${startdate}&end_date=${enddate}&code=crm

Example input:

  • zipCode = 1234AB
  • houseNumber = 4
  • startdate = 2025-02-17
  • enddate = 2025-04-17

@PatrickSt1991
Copy link
Contributor

@Dennis-Rosenbaum @HenkdeVlaam hebben jullie een postcode met huisnummer combinatie die ik kan gebruiken? dan kan ik de api results even bekijken en misschien verwerken

@HenkdeVlaam
Copy link
Author

@Dennis-Rosenbaum @HenkdeVlaam hebben jullie een postcode met huisnummer combinatie die ik kan gebruiken? dan kan ik de api results even bekijken en misschien verwerken

1312ET nr 5
Api result zie screenshotimage

PatrickSt1991 added a commit to PatrickSt1991/homeassistant-afvalwijzer that referenced this issue Feb 19, 2025
Requested in xirixiz#393 implementation of cleanprofs function.

Created format_postal_code function to prevent code duplicate and improve maintainablity
@PatrickSt1991
Copy link
Contributor

@HenkdeVlaam tnx! you're request is implemented in this PR #391

After it's merged it will become available

@HenkdeVlaam
Copy link
Author

Thanks!
Any idea how long it takes for this to become available?

@PatrickSt1991
Copy link
Contributor

No idea.. that's up to the repo owner and that's not me.

Just to clarify, I've added cleanprofs as a new garbage collection, that's what you wanted right?

It will show up in the list and when chosen it will show the next pickup dates.

Or do you want it to append to a existing one, like MMM-Afvalwijzer module does?

Cause if it's the latter, I need to change it and test it with the company that's collecting your waste..

If so, can you provide me with the company that's collecting your waste?

@HenkdeVlaam
Copy link
Author

HenkdeVlaam commented Feb 19, 2025 via email

@PatrickSt1991
Copy link
Contributor

Okay, no problem, I'll start working on it today to implement it as option a option

@HenkdeVlaam
Copy link
Author

HenkdeVlaam commented Feb 19, 2025 via email

@PatrickSt1991
Copy link
Contributor

@HenkdeVlaam Your request is now partially implemented in the pull request.

I've removed it as a garbage collector because it isn't a collector—it's a cleaning company.

Once the PR is merged, the plugin will contain a new option:

Image
For now, Cleanprofs is the only cleaning provider, so it will be displayed as a radio button. However, when more providers are added, it will automatically become a combobox, just like the garbage provider selection.

Image
When the sensors are created, you'll see additional sensors named "afvalwijzer cleaning_****".

Image
These are your new cleaning sensors. They work exactly the same as the others. In this screenshot, I've renamed them to make the names more visually friendly.

Image

So, all in all, it's not exactly the same as what @Dennis-Rosenbaum created with two images side by side. Instead, it's a new sensor but still within the same afvalwijzer instance, so there's no need to run them in parallel.

The only thing that isn't implemented yet is the option to reconfigure it on the fly. That would require a significant code change, so I might start working on it another day.

I hope this is what you were looking for!

And this is what I used for the image for the sensor, in configuration.yaml

homeassistant:
  customize_glob:
    "sensor.afvalwijzer_cleaning*":
      entity_picture: /local/afvalwijzer/cleaning.jpg

Image

@HenkdeVlaam
Copy link
Author

Great!! And a surprisingly fast implementation it is
Thanks for your cooperation.

One question.
Does your script now require a totally new installation of the Afvalwijzer? I hope not, because it took me quite some time and effort to get it running.

Regards,
Henk

@PatrickSt1991
Copy link
Contributor

Unfortunately, yes. Since there's a change to config_flow.py, and those values are written to core.config_entries, your current core.config_entries does not contain "clean_provider": "cleanprofs". Re-adding it will create that key-value pair and, in turn, generate the required sensors.

That said, this PR still needs to be merged. However, if you don’t want to wait, you can use my fork: Afvalwijzer with cleaning company

If you need any help setting up Afvalwijzer, just let me know. Do you have a lot of custom work done? If not, the benefit of running Verwijderen is that it will only delete the sensors but won’t affect any of your custom YAML files.

Image

Once you reinstall it, the sensors will return with the same names.

@HenkdeVlaam
Copy link
Author

Thanks!
The only changes (still troublesome at the moment) are related to the fact that the collector in Almere starting jan 1 2025 does not any longer collect pmd and restafval in separate streams/containers but the mixed waste types in one container called PMD+Rest.
The Afvalwijzer does not cover that change of waste streams (yet?)

Maybe I will try to implement your fork. If I need some support will let you know.
Regards

@PatrickSt1991
Copy link
Contributor

That doesn't sound like a hard thing to fix, probably just have to add it in main_functions.py

The waste mapping happens there.

So if your json return is PMD+Rest then I'll just add "PMD+Rest":"pmd-restafval" and Bob's your uncle

@HenkdeVlaam
Copy link
Author

HenkdeVlaam commented Feb 24, 2025 via email

@PatrickSt1991
Copy link
Contributor

PatrickSt1991 commented Feb 24, 2025

Ik heb hem nu als dit toegevoegd:
"bulkyrestwaste": "pmd-restafval"

Zo blijft de sensor in lijn met de rest van de sensoren.

Je sensor wordt dan;
sensor.afvalwijzer pmd-restafval

@HenkdeVlaam
Copy link
Author

HenkdeVlaam commented Feb 24, 2025 via email

xirixiz pushed a commit that referenced this issue Feb 28, 2025
…s functionality (#391)

* Add Irado as garbarge provider (next pickups)

* Update README.md

clarification to prevent questions as in #389

* Updated Irado to pickups API for longer date range

* Implementation of Cleanprofs

Requested in #393 implementation of cleanprofs function.

Created format_postal_code function to prevent code duplicate and improve maintainablity

* empty commit to rebase

* Removal of cleanprofs as a garbage collector, needs to be addition to existing garbage collectors

* Implemented the cleaning provider functionality.

Added cleanprofs as the first cleaning provider

* Update main_functions.py
added PMD+Rest

* Update main_functions.py
change to lower

* Update main_functions.py

added "bulkyrestwaste": "pmd-restafval"
@xirixiz
Copy link
Owner

xirixiz commented Feb 28, 2025

#390 & #393 - Added garbarge providers, implemented cleaning providers functionality

@xirixiz xirixiz closed this as completed Feb 28, 2025
@xirixiz
Copy link
Owner

xirixiz commented Feb 28, 2025

Sorry for the late response folks, but many thanks for the great contribution!

@HenkdeVlaam
Copy link
Author

HenkdeVlaam commented Feb 28, 2025 via email

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

No branches or pull requests

4 participants