There is already a github covering UK waste collections, however this scrapes the website for RBC, when they actually have an API accessible.
This integration is just a simple REST configuration for that API, rather than bringing in additional code.
rest:
- scan_interval: 36000 # Every 10 hours is more than enough
# Resource format is https://api.reading.gov.uk/rbc/mycollections/HOUSE_NUMBER,%20POSTCODE
# Note the escaped space before the postcode
resource: https://api.reading.gov.uk/rbc/mycollections/66,%20RG15RD
# Returned format is {"Collections"[array of collections]{collection details}]}
sensor:
# Add as many as you require. Iterate the collection number as needed.
# Code setting is just to map friendly names
- name: "First collection"
value_template: >
{% set codes =
{ "Domestic Waste Collection Service": "Black bin",
"Recycling Collection Service": "Red bin",
"Food Waste Collection Service": "Food bin",
"Garden Waste Collection Service": "Green bin"
} %}
{{ codes.get(value_json['Collections'][0]['Service']) }}
- name: "First Collection day"
value_template: "{{ value_json['Collections'][0]['Day']}}"
- name: "First Collection date"
value_template: "{{ value_json['Collections'][0]['Date']}}"
- name: "Second collection"
value_template: >
{% set codes =
{ "Domestic Waste Collection Service": "Black bin",
"Recycling Collection Service": "Red bin",
"Food Waste Collection Service": "Food bin",
"Garden Waste Collection Service": "Green bin"
} %}
{{ codes.get(value_json['Collections'][1]['Service']) }}
- name: "Second Collection day"
value_template: "{{ value_json['Collections'][1]['Day']}}"
- name: "Second Collection date"
value_template: "{{ value_json['Collections'][1]['Date']}}"