Hi there everyone, long time no see!
So, a few months ago, I came across this write-up from a fellow member of the community, in which he detailed some concepts to detect activity when a garbage can is moved and/or returned to its original position.
Given I live in a small house, I wouldn’t really have much space indoors to keep the garbage can, but after looking into it, it seems that my county provides a platform to track in real time the route of the garbage trucks, and I was wondering how difficult it would be to extract the JSONP I get from cURL when visiting the platform into something that can not only show up as a tracker entity, but perhaps also automate a notification so I don’t miss the truck if I don’t happen to hear it.
The platform resides in this URL, and after enabling the public cleaning services layer, I can see the truck’s license place, velocity, identification and coordinates by hovering over its icon, like so:
From what I’m able to tell, the map itself is designed with OpenStreetMap in mind, and the API that populates the layers is provided by GeoTab, which I am able to query using the following string as an example:
curl 'https://my.geotab.com/apiv1/Get?JSONP=geotabJSONP.json4042248393841794&typeName=%22DeviceStatusinfo%22&credentials=%7B%22database%22%3A%22zapopan%22%2C%22sessionId%22%3A%22DcYAlOjKYx7ytQe-BPEtZw%22%2C%22userName%22%3A%22gustavo.rodriguez%40zapopan.gob.mx%22%7D' -H 'accept: */*' -H 'accept-language: en-US,en;q=0.9,es-MX;q=0.8,es;q=0.7' -H 'cache-control: no-cache' -H 'dnt: 1' -H 'pragma: no-cache' -H 'referer: https://ubica.zapopan.gob.mx/' -H 'sec-ch-ua: "Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"' -H 'sec-ch-ua-mobile: ?1' -H 'sec-ch-ua-platform: "Android"' -H 'sec-fetch-dest: script' -H 'sec-fetch-mode: no-cors' -H 'sec-fetch-site: cross-site' -H 'sec-fetch-storage-access: active' -H 'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36 Edg/135.0.0.0'
According to the Network tab in Chromium, this cURL one-liner is called every sixty seconds to update what’s displayed on the map, and I’m able to turn it into a readable-ish version in plain JSON with this other one-liner appended at the end:
| python -m json.tool > garbagetrucks.json
The only part of the URL that seems to change between visits is the sessionId
, so I’d have to add some sort of helper variable to generate and/or change this every so often.
Needless to say, I think the output (while valid) is a little too big to show in here, so I’ll upload it to a Gist just in case while also attaching a snippet:
{
"jsonrpc": "2.0",
"result": [
{
"bearing": 10,
"currentStateDuration": "00:13:24",
"dateTime": "2025-03-18T01:27:25.000Z",
"device": {
"id": "b78"
},
"driver": {
"driverGroups": [
{
"id": "b280E"
}
],
"id": "b44F",
"isDriver": true
},
"exceptionEvents": [],
"groups": [
{
"id": "GroupGasolinePetrolId"
},
{
"id": "GroupVehicleId"
},
{
"id": "b27C0"
}
],
"isDeviceCommunicating": true,
"isDriving": true,
"isHistoricLastDriver": false,
"latitude": 20.7123203,
"longitude": -103.393257,
"speed": 31
}
]
}
Considering what’s available, how much stuff should I keep in mind to develop some solution for this automation?
Thanks in advance!