Home-Assistant-Sensor-Afvalbeheer
Home-Assistant-Sensor-Afvalbeheer copied to clipboard
Added Calendar support
I invested some time to add a afvalbeheer calendar in order to support the calendar.
In order to support multi platform component I needed to create a setup in init and therefore moving items out of sensor.py
- Moved all constants to const.py.
- Moved the core of getting data from API endpoints and storage to API.py
- Created new function in API to create WasteData from Config
- Created new async_setup function in __ init __.py to allow multi platform type support and updated the async_platform config in sensor.py to handle both ways of defining the config
- Created new Calendar Entity in calendar.py reading all data from WasteData
- Updated readme with how the new config should look like to support the Calendar entity
I didn't test thoroughly with multiple configurations in the same config there is an issue with the schema the way I tried to test it. But there will be partial support for multiple configurations as data will be stored uniquely based on wastecollector, postcode, streetnumber.
The calendar entity has currently a fixed name and is not looking at the configured resources but will generate from all waste_types an event. Each event inside the calendar will be named according to the waste_type only.
In order to get the calendar working from existing configuration you will have to update the config. The "old" config style will still load successful
Let me know what you think about it.
Wouter
Nice work! Thanks for your contribution.
Give me some time to review the code and test all the possible configs
Multiple instances of Afvalbeheer is not working yet.
Initially thought that getting the config working for multiple instance would be challenging but found out it was relatively easy.
With this latest version I don't get any data at all. Not for a single instance or multiple.
Now it should be working
A remaining error I found so far is line 6 in calander.py
from homeassistant.components.aa_test.API import WasteData
should be
from .API import WasteData
Updated the reference
A few issues I found:
- The calendar entities do not have an unique ID (_attr_unique_id)
- if you use the old setup (i.e. add as a sensor and not a platform) the default values for the config are not loaded. Most importantly
CONF_UPDATE_INTERVALandCONF_DATE_FORMAT
Added the unique ID for calendar entities and included waste collector name to the name
Fixed the default values the config didn't get validated when using sensor due schema was missing in sensor.py
Thank you @WouterTuinstra for your contribution to this project! I've just released v5.0.0