{"id":21327511,"url":"https://github.com/rare-magma/datadis-exporter","last_synced_at":"2026-02-04T06:03:36.193Z","repository":{"id":209537007,"uuid":"723799079","full_name":"rare-magma/datadis-exporter","owner":"rare-magma","description":"CLI tool that uploads the energy consumption data from the Datadis API to influxdb on a daily basis ","archived":false,"fork":false,"pushed_at":"2026-02-01T12:49:35.000Z","size":303,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-01T22:15:55.180Z","etag":null,"topics":["aseme","cide","datadis","e-distribuicion","e-redes","grafana","grafana-dashboard","iberdrola","influxdb","naturgy","pvpc","ufd","viesgo"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rare-magma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-26T19:44:20.000Z","updated_at":"2026-02-01T12:49:31.000Z","dependencies_parsed_at":"2024-11-01T13:17:12.488Z","dependency_job_id":"9a802c24-1f30-42b7-89f5-d45e89037b42","html_url":"https://github.com/rare-magma/datadis-exporter","commit_stats":null,"previous_names":["rare-magma/datadis-exporter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rare-magma/datadis-exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rare-magma%2Fdatadis-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rare-magma%2Fdatadis-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rare-magma%2Fdatadis-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rare-magma%2Fdatadis-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rare-magma","download_url":"https://codeload.github.com/rare-magma/datadis-exporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rare-magma%2Fdatadis-exporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29072474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["aseme","cide","datadis","e-distribuicion","e-redes","grafana","grafana-dashboard","iberdrola","influxdb","naturgy","pvpc","ufd","viesgo"],"created_at":"2024-11-21T21:17:59.257Z","updated_at":"2026-02-04T06:03:36.178Z","avatar_url":"https://github.com/rare-magma.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datadis-exporter\n\nCLI tool that uploads the energy consumption and maximum power usage data from the DATADIS API to influxdb on a daily basis\n\n## Dependencies\n\n- [go](https://go.dev/)\n- [influxdb v2+](https://docs.influxdata.com/influxdb/v2.6/)\n- Optional:\n  - [make](https://www.gnu.org/software/make/) - for automatic installation support\n  - [docker](https://docs.docker.com/)\n  - [systemd](https://systemd.io/)\n\n## Relevant documentation\n\n- [DATADIS](https://datadis.es/)\n- [InfluxDB API](https://docs.influxdata.com/influxdb/v2.6/write-data/developer-tools/api/)\n- [Systemd Timers](https://www.freedesktop.org/software/systemd/man/systemd.timer.html)\n- [compose-scheduler](https://github.com/reddec/compose-scheduler)\n\n## Installation\n\n### With Docker\n\n#### docker-compose\n\n1. Configure `datadis_exporter.json` (see the configuration section below).\n1. Run it.\n\n   ```bash\n   docker compose up --detach\n   ```\n\n#### docker build \u0026 run\n\n1. Build the docker image.\n\n   ```bash\n   docker build . --tag datadis-exporter\n   ```\n\n1. Configure `datadis_exporter.json` (see the configuration section below).\n1. Run it.\n\n    ```bash\n    docker run --rm --init --tty --interactive --read-only --cap-drop ALL --security-opt no-new-privileges:true --cpus 2 -m 64m --pids-limit 16 --volume ./datadis_exporter.json:/app/datadis_exporter.json:ro ghcr.io/rare-magma/datadis-exporter:latest\n    ```\n\n### With the Makefile\n\nFor convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph.\n\n```bash\nmake build\nmake install\n$EDITOR $HOME/.config/datadis_exporter.json\n```\n\n### Manually\n\n1. Build `datadis_exporter` with:\n\n    ```bash\n    go build -ldflags=\"-s -w\" -o datadis_exporter main.go\n    ```\n\n2. Copy `datadis_exporter` to `$HOME/.local/bin/` and make it executable.\n\n3. Copy `datadis_exporter.json` to `$HOME/.config/`, configure it (see the configuration section below) and make it read only.\n\n4. Copy the systemd unit and timer to `$HOME/.config/systemd/user/`:\n\n    ```bash\n    cp datadis-exporter.* $HOME/.config/systemd/user/\n    ```\n\n5. and run the following command to activate the timer:\n\n    ```bash\n    systemctl --user enable --now datadis-exporter.timer\n    ```\n\nIt's possible to trigger the execution by running manually:\n\n```bash\nsystemctl --user start datadis-exporter.service\n```\n\n### Config file\n\nThe config file has a few options:\n\n```json\n{\n \"InfluxDBHost\": \"influxdb.example.com\",\n \"InfluxDBApiToken\": \"ZXhhbXBsZXRva2VuZXhhcXdzZGFzZGptcW9kcXdvZGptcXdvZHF3b2RqbXF3ZHFhc2RhCg==\",\n \"Org\": \"home\",\n \"Bucket\": \"datadis\",\n \"DatadisUsername\": \"username\",\n \"DatadisPassword\": \"password\",\n \"Cups\": \"ES0000000000000000XX0X\",\n \"DistributorCode\": \"1\"\n}\n```\n\n- `InfluxDBHost` should be the FQDN of the influxdb server.\n- `Org` should be the name of the influxdb organization that contains the energy consumption data bucket defined below.\n- `Bucket` should be the name of the influxdb bucket that will hold the energy consumption data.\n- `InfluxDBApiToken` should be the influxdb API token value.\n  - This token should have write access to the `BUCKET` defined above.\n- `DatadisUsername` and `DATADIS_PASSWORD`should be the credentials used to access the DATADIS website\n- `Cups` should be the Código Unificado de Punto de Suministro (CUPS)\n- `DistributorCode` should be one of:\n  - 1: Viesgo,\n  - 2: E-distribución\n  - 3: E-redes\n  - 4: ASEME\n  - 5: UFD\n  - 6: EOSA\n  - 7: CIDE\n  - 8: IDE\n\n## Troubleshooting\n\nCheck the systemd service logs and timer info with:\n\n```bash\njournalctl --user --unit datadis-exporter.service\nsystemctl --user list-timers\n```\n\n## Exported metrics\n\nThe consumption DATADIS API call period is limited to the last 30 days by default.\nThe power call is limited to the current year's first and last day.\n\n- consumption: The energy consumption in kWh\n- period: The period type (p1: punta, p2: llano, p3: valle)\n- cups: The cups corresponding to the consumption point above\n- max_power: The highest electrical power demanded in kWh\n\n## Exported metrics example\n\n```bash\ndatadis_consumption,cups=ES0000000000000000XX0X,period=1 consumption=0.123 1672610400\ndatadis_power,cups=ES0000000000000000XX0X,period=1 max_power=0.123 1686869100\n```\n\n## Example grafana dashboard\n\nIn `datadis-dashboard.json` there is an example of the kind of dashboard that can be built with `datadis-exporter` data:\n\n\u003cimg src=\"dashboard-screenshot.png\" title=\"Example grafana dashboard\" width=\"100%\"\u003e\n\nImport it by doing the following:\n\n1. Create a dashboard\n2. Click the dashboard's settings button on the top right.\n3. Go to JSON Model and then paste there the content of the `datadis-dashboard.json` file.\n\n## Uninstallation\n\n### With the Makefile\n\nFor convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph.\n\n```bash\nmake uninstall\n```\n\n### Manually\n\nRun the following command to deactivate the timer:\n\n```bash\nsystemctl --user disable --now datadis-exporter.timer\n```\n\nDelete the following files:\n\n```bash\n~/.local/bin/datadis_exporter\n~/.config/datadis_exporter.json\n~/.config/systemd/user/datadis-exporter.timer\n~/.config/systemd/user/datadis-exporter.service\n```\n\n## Credits\n\n- [reddec/compose-scheduler](https://github.com/reddec/compose-scheduler)\n\nThis project takes inspiration from the following:\n\n- [MrMarble/datadis](https://github.com/MrMarble/datadis)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frare-magma%2Fdatadis-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frare-magma%2Fdatadis-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frare-magma%2Fdatadis-exporter/lists"}