We have a laser cutter at our space and wanted to track how long and often it runs. So we connected an ESP8266 to it, that measures the time it's running and posts it to this API thing here.
Index page, lists all devices registered.
Usage details for a specific device.
We're sort of REST conform, but not really, due to simplifications on the ESP
Returns a list of all devices being tracked, and their usage counts
Gets the usage counts of a specific device
Adds a new usage entry to the specified device. The duration of usage is to be passed as the "time" parameter in the URL, in seconds.
Example: curl -X PUT http://hourcounter.hackerspace.example/api/device/laser01/?time=42
Gets all usage entries for a specific device, paged by 100 entries each.
Get device usage by day, for a specific device.
Gets usage statistics of a specific device, by hour and day of the week
We decided to run the counter in a docker container. The database all usage data is tracked in, is stored in the /data
volume.
docker build -t munichmakerlab/hourcounter .
docker run -d \
--name=hourcounter \
-v /data/hourcounter:/data \
-e "VIRTUAL_HOST=hourcounter,hourcounter.intern.munichmakerlab.de" \
munichmakerlab/hourcounter