{"id":20116354,"url":"https://github.com/robinlinde/mapcomplete-mqtt","last_synced_at":"2025-03-02T19:22:45.230Z","repository":{"id":171321531,"uuid":"627499513","full_name":"RobinLinde/MapComplete-MQTT","owner":"RobinLinde","description":"Service to publish statistics about MapComplete Changesets to MQTT","archived":false,"fork":false,"pushed_at":"2025-02-16T00:04:46.000Z","size":315,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T01:17:48.660Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobinLinde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-13T15:37:58.000Z","updated_at":"2025-02-16T00:04:49.000Z","dependencies_parsed_at":"2023-10-15T18:11:52.001Z","dependency_job_id":"0add83c5-2e40-4f64-b490-7b7c5404db41","html_url":"https://github.com/RobinLinde/MapComplete-MQTT","commit_stats":null,"previous_names":["robinlinde/mapcomplete-mqtt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinLinde%2FMapComplete-MQTT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinLinde%2FMapComplete-MQTT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinLinde%2FMapComplete-MQTT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinLinde%2FMapComplete-MQTT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobinLinde","download_url":"https://codeload.github.com/RobinLinde/MapComplete-MQTT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241558292,"owners_count":19982067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T18:40:22.090Z","updated_at":"2025-03-02T19:22:45.215Z","avatar_url":"https://github.com/RobinLinde.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MapComplete-MQTT\n\nMapComplete-MQTT is a service publishing statistics about [OpenStreetMap](https://www.openstreetmap.org) changesets made with [MapComplete](https://github.com/pietervdvn/MapComplete) to an MQTT broker.\n\n## Running the service\n\nFor running the service, there needs to be an MQTT broker running and some environment variables set.\n\nBelow is a summary of the environment variables:\n\n| Variable          | Description                                               | Default     |\n| ----------------- | --------------------------------------------------------- | ----------- |\n| `MQTT_HOST`       | The host of the MQTT broker                               | `localhost` |\n| `MQTT_PORT`       | The port of the MQTT broker                               | `1883`      |\n| `MQTT_USERNAME`   | The username for the MQTT broker                          | empty       |\n| `MQTT_PASSWORD`   | The password for the MQTT broker                          | empty       |\n| `OSMCHA_TOKEN`    | The token for OSMCha (required)                           | empty       |\n| `DRY_RUN`         | If set to `True`, no data is published to the MQTT broker | `False`     |\n| `UPDATE_INTERVAL` | The interval in seconds between updates                   | `300`       |\n\nThese can be set in an `.env` file (see `.env.example`) or by setting the environment variables yourself.\nThe necessary OSMCha token can be obtained by logging in to [OSMCha](https://osmcha.org) and copying the token from the Account Settings page.\n\nThen the application can be either run directly with node or with Docker.\n\n### Running with node\n\nTo run the application with node, run `npm install` and `npm start`.\n\n### Running with Docker\n\nTo run the application with Docker, either build it locally using `docker build -t mapcomplete-mqtt .` or pull it from Docker Hub using `docker pull ghcr.io/RobinLinde/mapcomplete-mqtt`.\n\nThen run the container either by passing the environment variables directly or by using an `.env` file (see `.env.example`) using `docker run --name mapcomplete-mqtt --env-file .env mapcomplete-mqtt` or `docker run --name mapcomplete-mqtt -e MQTT_HOST=localhost -e MQTT_USERNAME=user -e MQTT_PASSWORD=pass -e OSMCHA_TOKEN=token mapcomplete-mqtt`.\n\n## Using the data\n\nData is published to the topic `mapcomplete/statistics` on the MQTT broker, with the payload being a JSON object as shown below.\n\nMost items are also available on their own topic, e.g. `mapcomplete/statistics/changesets/total` or `mapcomplete/statistics/users/top`.\n\nApart from this, some data is also published as a Home Assistant sensors, contained by a Home Assistant device (see [list](#home-assistant-sensors) below). There are also devices and sensors for each theme, but these are not individually listed.\n\n### Home Assistant sensors\n\n| Sensor ID                           | Description                                                            |\n| ----------------------------------- | ---------------------------------------------------------------------- |\n| `mapcomplete_changesets_total`      | The total number of changesets                                         |\n| `mapcomplete_changesets_last`       | The ID of the last changeset (disabled by default)                     |\n| `mapcomplete_changesets_last_color` | The color of the last changeset, as a hex string (disabled by default) |\n| `mapcomplete_changesets_last_rgb`   | The color of the last changeset, as an RGB array (disabled by default) |\n| `mapcomplete_users_total`           | The total number of users                                              |\n| `mapcomplete_users_last`            | The username of the last user                                          |\n| `mapcomplete_users_top`             | The username of the top user                                           |\n| `mapcomplete_themes_total`          | The total number of themes                                             |\n| `mapcomplete_themes_last`           | The name of the last theme                                             |\n| `mapcomplete_themes_top`            | The names of the top themes                                            |\n| `mapcomplete_questions_total`       | The total number of questions answered                                 |\n| `mapcomplete_images_total`          | The total number of images uploaded                                    |\n| `mapcomplete_points_total`          | The total number of points added                                       |\n| `mapcomplete_import_total`          | The total number of imported items                                     |\n\n### Example data\n\n```json\n{\n  \"changesets\": {\n    \"total\": 3,\n    \"last\": 1234,\n    \"lastUrl\": \"https://www.osm.org/changeset/1234\",\n    \"lastColor\": \"#fffe73\",\n    \"lastColorRgb\": [255, 254, 115],\n    \"colors\": [\"#70c549\", \"#e2783d\", \"#fffe73\"],\n    \"colorsStr\": \"#70c549,#e2783d,#fffe73\",\n    \"colorsRgb\": [\n      [112, 197, 73],\n      [226, 120, 61],\n      [255, 254, 115]\n    ],\n    \"colorsRgbStr\": \"112,197,73,226,120,61,255,254,115\",\n    \"changesets\": [\n      {\n        \"id\": 1231,\n        \"user\": \"user1\",\n        \"theme\": \"etymology\",\n        \"color\": \"#70c549\",\n        \"colorRgb\": [112, 197, 73],\n\n        \"url\": \"https://www.osm.org/changeset/1232\"\n      },\n      {\n        \"id\": 1233,\n        \"user\": \"user2\",\n        \"color\": \"#e2783d\",\n        \"colorRgb\": [226, 120, 61],\n        \"theme\": \"cyclofix\",\n        \"url\": \"https://www.osm.org/changeset/1233\"\n      },\n      {\n        \"id\": 1234,\n        \"user\": \"user2\",\n        \"color\": \"#fffe73\",\n        \"colorRgb\": [255, 254, 115],\n        \"theme\": \"advertising\",\n        \"url\": \"https://www.osm.org/changeset/1234\"\n      }\n    ]\n  },\n  \"users\": {\n    \"total\": 3,\n    \"last\": \"user2\",\n    \"top\": \"user2\",\n    \"users\": {\n      \"user1\": 1,\n      \"user2\": 2\n    }\n  },\n  \"themes\": {\n    \"total\": 3,\n    \"top\": \"etymology, cyclofix, advertising\",\n    \"last\": \"advertising\",\n    \"themes\": {\n      \"etymology\": 1,\n      \"cyclofix\": 1,\n      \"advertising\": 1\n    }\n  },\n  \"questions\": 10,\n  \"images\": 2,\n  \"points\": 3,\n  \"import\": 1\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinlinde%2Fmapcomplete-mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinlinde%2Fmapcomplete-mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinlinde%2Fmapcomplete-mqtt/lists"}