Skip to main content

Waste management — smart collection

The problem. Fixed collection schedules get it wrong in both directions: bins in busy spots overflow between visits — a health and litter problem — while trucks burn fuel and hours emptying half-full bins on quiet streets. The operator needs collection driven by how full bins actually are, so crews go where the waste is and skip where it isn't.

What we solve here is collecting on demand instead of on a calendar — fewer overflows, fewer wasted trips.

Set up demo data

New workspace? Run this once (Python) to create a bin's fill-level series with a near-full reading — so the collection_due rule below fires. Safe to re-run.

import datahub_sdk, pandas as pd

client = datahub_sdk.DataHubClient.from_env()

client.timeseries.create([datahub_sdk.TimeSeries(external_id="bin_grunerlokka_114_fill_pct", name="Bin 114 fill", unit="pct", value_type="float")])
client.timeseries.insert_from_lists(timestamps=[pd.Timestamp.now(tz="UTC")], values=[87.0], ts="bin_grunerlokka_114_fill_pct")

1. Act on fill level, not the calendar

Each bin reports its fill level. When a bin crosses its collection threshold, raise a collection_due event that drops it onto the next route. See Turn readings into events.

var series = client.timeseries().retrieve(lastReadingOf("bin_grunerlokka_114_fill_pct"))
.getItems().get(0);

double fill = Double.parseDouble(series.getDatapoints().get(0).getValue());
if (fill >= 80.0) {
EventModel due = new EventModel();
due.setExternalId("collection_due_114_" + System.currentTimeMillis());
due.setType("collection_due");
due.setStatus("open");
due.setMetadata(Map.of("bin", "bin_grunerlokka_114", "fill_pct", String.valueOf(fill)));
due.setEventTime(Long.parseLong(series.getDatapoints().get(0).getTimestamp()));
client.events().create(List.of(due));
}

2. Plan routes from real demand

Fill levels across a district, rolled up over the week, show the fill-rate pattern — which areas fill fast and need frequent visits, which can be left longer. That pattern sizes routes and frequencies far better than a flat schedule. See Query & aggregate.

3. Flag contamination

A bin reading the wrong weight or material for its stream becomes a contamination event for the education and enforcement team.

See the result

The near-full bin in the demo trips the rule:

collection_due bin_grunerlokka_114 (fill 87%)

See also