My waste handling service has a website with a REST backend. I want to integrate waste collection moments into HA. I can write python scripts, but am unsure about the HA ecosystem. I hope somebody can nudge me into the right principles of handling this data for Home Assistant
Functionality:
- An API call to get all waste “streams” (normal, plastics, glass, paper etc). This gives per stream a waste ID, icon, description etc
- An API call to get the collection moments of a certain year. Currently, only 2018 works so far and 2019 gives zero results. A waste moment is a waste stream ID + date stamp
Idea in HA:
- Have a card which shows the upcoming collection moments together with the proper icon, per waste stream (e.g. in 2 days stream A, in 9 days stream B)
- Fire events before collection, customizable (so 12h/24h before e.g.) so you can automate notifications etc
I would like to query the waste streams once and cache the results (in memory cache will do) so when HA starts. Then I want to query the collection moments. However, for now I can only query 2018 and somewhere around half December I need to query 2019 already.
I use imports from datetime
and requests
, so I cannot use python_scripts anymore. A few of my questons:
- I think for the first use case (the upcoming collection moments) I need to use states. How can I regularly update state? So daily adjust the state with the upcoming events?
- How can I program an event at exactly Monday 19th November 00:00 minus 12 hours = a trigger at Sunday 18th november 12:00 (local time)?