{"id":16971639,"url":"https://github.com/thomastjdev/nim_eloverblik_api","last_synced_at":"2026-04-12T18:50:26.150Z","repository":{"id":87657452,"uuid":"247123382","full_name":"ThomasTJdev/nim_eloverblik_api","owner":"ThomasTJdev","description":"API for www.eloverblik.dk - samling af energiforbrug","archived":false,"fork":false,"pushed_at":"2020-04-20T19:59:33.000Z","size":872,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-26T14:48:38.456Z","etag":null,"topics":["elforbrug","eloverblik","energiforbrug","orsted","radius"],"latest_commit_sha":null,"homepage":null,"language":"Nim","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/ThomasTJdev.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-13T17:10:33.000Z","updated_at":"2023-10-02T16:08:24.000Z","dependencies_parsed_at":"2023-03-13T18:40:18.972Z","dependency_job_id":null,"html_url":"https://github.com/ThomasTJdev/nim_eloverblik_api","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_eloverblik_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_eloverblik_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_eloverblik_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_eloverblik_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasTJdev","download_url":"https://codeload.github.com/ThomasTJdev/nim_eloverblik_api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244860611,"owners_count":20522466,"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":["elforbrug","eloverblik","energiforbrug","orsted","radius"],"created_at":"2024-10-14T00:53:11.838Z","updated_at":"2026-04-12T18:50:26.092Z","avatar_url":"https://github.com/ThomasTJdev.png","language":"Nim","readme":"# nim_eloverblik\nAPI for www.eloverblik.dk - samling af energiforbrug.\n\nThis is an API for the website www.eloverblik.dk, which collects energy usage from Danish energy companies.\n\nYou use this as an library, which you import, or you can run it as a binary. It'll get your energy usage, format it to JSON, and sends the data with MQTT.\n\n# Requirements\nTo access the API, you need to generate a `refreshToken` and your meetering point.\n\n\n## Refresh token\n1) Go to www.eloverblik.dk\n2) Login as \"Privat\"\n3) Navigate to \"Min profil -\u003e Datadeling\"\n4) Generate a token and save it locally\n\n## Meetering ID\nYou'r already at www.eloverblik.dk, so now just navigate to the frontpage (https://eloverblik.dk/Customer/overview/) and copy your meetering ID - the 18 characters.\n\n# Data\nPlease be aware, that the data output comes within a time periode from 23:00-23:00 (11:00 PM): `\"start\":\"2020-03-16T23:00:00Z\",\"end\":\"2020-03-17T23:00:00Z\"`.\n\nTherefore the URL you are requesting look a bit strange. When you want the data from the 17th, you request needs to be from 16th to the 17th march.\n\nYour URL will be: `https://api.eloverblik.dk/CustomerApi/api/MeterData/GetTimeSeries/2020-03-17/2020-03-18/Year`\n\nFurthermore the datahub is updated 1 day to slow, which has the draw down, that you can't get yesterdays usage.\n\n\n# Usage\nYou have to copy the `config_default.cfg` to `config.cfg` and adjust the options.\n\n\n## Home Assistant (Hass.io)\nThe original purpose of this API was to enable an overview in HA. So running the API as a binary, it'll sends the stats everyday to HA, and you can visualize them - e.g. using mini-graph (HACS plugin).\n\n3 entities will automatic be added to Home assistant: Daily usage (`sensor.elforbrug_day`), Weekly usage (`sensor.elforbrug_week`) and Monthly usage (`sensor.elforbrug_month`). If you **dont** want the automatic creating of sensors, set the `autoDiscover=false` and follow the guide below with Node red.\n\nA birth message is also supported - if Hass restarts, the config needs to be resend, otherwise the sensor will be inactive. You can setup a birth topic and birth payload inside Hass, which will be send on each boot - we are using that payload to resend the sensors configuration.\n\nYou only need to update the `config.cfg` with details on below the fields `[MQTT]`, `[Eloverblik]` and `[Hassio]`. The topic in `[MQTT]` will not be used, if you are using the autoDiscovery function.\n\n~~Buuuut, you might want to use Node red to do the automation. You either follow the steps below to create the flow, or you can copy and paste the predefined flow. After that generate a graph with mini-graph in Lovelace and enjoy.~~\n\n~~You need to let the program run, cause it'll gather the data once a day - set the time in the `config.cfg`. A good choice would be 23:30 - the data is updated around 23:00.~~ This was quite annoying while testing, so now the api just runs every half hour. If there's no changes, nothing is send to HA with MQTT.\n\n### Auto run\n\nFirst compile the file:\n```nim\nnim c -d:ssl -d:release eloverblik.nim\n```\n\nThen edit the config file:\n```nim\ncp config/config_default.cfg config/config.cfg\nnano config/config.cfg\n```\n\nNow adjust the service file and deploy:\n```nim\nnano eloverblik.service\nsudo cp eloverblik.service /etc/systemd/system/eloverblik.service\nsudo systemctl enable eloverblik\nsudo systemctl start eloverblik\nsudo systemctl status eloverblik\n```\n\n\n### Node red\n\n**ONLY DO THIS IF YOU HAVE DISABLED AUTODISCOVERY**\n\nWe are making 3 nodes for: Daily usage, Weekly usage, Monthly usage.\n\n* MQTT-in node - convert to JSON object\n* HA entity node (monthl) - set state to:\n* HA entity node (week) - set state to:\n* HA entity node (day) - set state to:\n\n\u003cdetails\u003e\u003csummary\u003eNode red JSON code\u003c/summary\u003e\n\n```json\n[\n    {\n        \"id\": \"5ea40d22.fd6134\",\n        \"type\": \"mqtt in\",\n        \"z\": \"f9f7e30c.acb0a\",\n        \"name\": \"\",\n        \"topic\": \"eloverblik\",\n        \"qos\": \"2\",\n        \"datatype\": \"json\",\n        \"broker\": \"6e85e811.77a988\",\n        \"x\": 160,\n        \"y\": 220,\n        \"wires\": [\n            [\n                \"875fd707.470408\",\n                \"3f11ef06.a67ae\",\n                \"37c6eb5c.e52be4\"\n            ]\n        ]\n    },\n    {\n        \"id\": \"875fd707.470408\",\n        \"type\": \"ha-entity\",\n        \"z\": \"f9f7e30c.acb0a\",\n        \"name\": \"Eloverblik Month\",\n        \"server\": \"b95e3a52.453dc8\",\n        \"version\": 1,\n        \"debugenabled\": true,\n        \"outputs\": 1,\n        \"entityType\": \"sensor\",\n        \"config\": [\n            {\n                \"property\": \"name\",\n                \"value\": \"eloverblik_month\"\n            },\n            {\n                \"property\": \"device_class\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"icon\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"unit_of_measurement\",\n                \"value\": \"\"\n            }\n        ],\n        \"state\": \"payload.eloverblik.month.0.usage\",\n        \"stateType\": \"msg\",\n        \"attributes\": [\n            {\n                \"property\": \"start\",\n                \"value\": \"payload.eloverblik.month.0.start\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"end\",\n                \"value\": \"payload.eloverblik.month.0.end\",\n                \"valueType\": \"msg\"\n            }\n        ],\n        \"resend\": true,\n        \"outputLocation\": \"\",\n        \"outputLocationType\": \"none\",\n        \"inputOverride\": \"allow\",\n        \"x\": 450,\n        \"y\": 160,\n        \"wires\": [\n            []\n        ]\n    },\n    {\n        \"id\": \"3f11ef06.a67ae\",\n        \"type\": \"ha-entity\",\n        \"z\": \"f9f7e30c.acb0a\",\n        \"name\": \"Eloverblik Week\",\n        \"server\": \"b95e3a52.453dc8\",\n        \"version\": 1,\n        \"debugenabled\": true,\n        \"outputs\": 1,\n        \"entityType\": \"sensor\",\n        \"config\": [\n            {\n                \"property\": \"name\",\n                \"value\": \"eloverblik_week\"\n            },\n            {\n                \"property\": \"device_class\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"icon\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"unit_of_measurement\",\n                \"value\": \"\"\n            }\n        ],\n        \"state\": \"payload.eloverblik.week.0.usage\",\n        \"stateType\": \"msg\",\n        \"attributes\": [\n            {\n                \"property\": \"start\",\n                \"value\": \"payload.eloverblik.week.0.start\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"end\",\n                \"value\": \"payload.eloverblik.week.0.end\",\n                \"valueType\": \"msg\"\n            }\n        ],\n        \"resend\": true,\n        \"outputLocation\": \"\",\n        \"outputLocationType\": \"none\",\n        \"inputOverride\": \"allow\",\n        \"x\": 440,\n        \"y\": 220,\n        \"wires\": [\n            []\n        ]\n    },\n    {\n        \"id\": \"37c6eb5c.e52be4\",\n        \"type\": \"ha-entity\",\n        \"z\": \"f9f7e30c.acb0a\",\n        \"name\": \"Eloverblik Day\",\n        \"server\": \"b95e3a52.453dc8\",\n        \"version\": 1,\n        \"debugenabled\": true,\n        \"outputs\": 1,\n        \"entityType\": \"sensor\",\n        \"config\": [\n            {\n                \"property\": \"name\",\n                \"value\": \"eloverblik_day\"\n            },\n            {\n                \"property\": \"device_class\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"icon\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"unit_of_measurement\",\n                \"value\": \"\"\n            }\n        ],\n        \"state\": \"payload.eloverblik.day.0.usage\",\n        \"stateType\": \"msg\",\n        \"attributes\": [\n            {\n                \"property\": \"start\",\n                \"value\": \"payload.eloverblik.day.0.start\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"end\",\n                \"value\": \"payload.eloverblik.day.0.end\",\n                \"valueType\": \"msg\"\n            }\n        ],\n        \"resend\": true,\n        \"outputLocation\": \"\",\n        \"outputLocationType\": \"none\",\n        \"inputOverride\": \"allow\",\n        \"x\": 440,\n        \"y\": 280,\n        \"wires\": [\n            []\n        ]\n    },\n    {\n        \"id\": \"6e85e811.77a988\",\n        \"type\": \"mqtt-broker\",\n        \"z\": \"\",\n        \"name\": \"Main MQTT\",\n        \"broker\": \"192.168.1.100\",\n        \"port\": \"1883\",\n        \"clientid\": \"noderedmqtt\",\n        \"usetls\": false,\n        \"compatmode\": false,\n        \"keepalive\": \"60\",\n        \"cleansession\": true,\n        \"birthTopic\": \"\",\n        \"birthQos\": \"0\",\n        \"birthPayload\": \"\",\n        \"closeTopic\": \"\",\n        \"closeQos\": \"0\",\n        \"closePayload\": \"\",\n        \"willTopic\": \"\",\n        \"willQos\": \"0\",\n        \"willPayload\": \"\"\n    },\n    {\n        \"id\": \"b95a2a52.433dc8\",\n        \"type\": \"server\",\n        \"z\": \"\",\n        \"name\": \"Home Assistant\",\n        \"legacy\": false,\n        \"addon\": true,\n        \"rejectUnauthorizedCerts\": true,\n        \"ha_boolean\": \"y|yes|true|on|home|open\",\n        \"connectionDelay\": true,\n        \"cacheJson\": true\n    }\n]\n```\n\n\u003c/details\u003e\n\n### MQTT messages\nThe ouput will be like:\n```json\n{\n   \"eloverblik\":{\n     // Data from February 1st to February the 29\n      \"month\":[\n         {\n            \"start\":\"2020-01-31T23:00:00Z\",\n            \"end\":\"2020-02-29T23:00:00Z\",\n            \"usage\":\"114.62\",\n            \"unit\":\"KWH\"\n         }\n      ],\n      // Data from Monday 9 to Sunday the 15\n      \"week\":[\n         {\n            \"start\":\"2020-03-08T23:00:00Z\",\n            \"end\":\"2020-03-15T23:00:00Z\",\n            \"usage\":\"44.55\",\n            \"unit\":\"KWH\"\n         }\n      ],\n      // Data from Tuesday the 17th\n      \"day\":[\n         {\n            \"start\":\"2020-03-16T23:00:00Z\",\n            \"end\":\"2020-03-17T23:00:00Z\",\n            \"usage\":\"5.99\",\n            \"unit\":\"KWH\"\n         }\n      ]\n   }\n}\n```\n\n\n## Nim library\n\nImport eloverblik, set the types and call `eloverblikTimeSeries()`:\n\n```nim\neloverblikLoadData() # Loads the data from the config.cfg\nlet result = eloverblikTimeSeries(eloverblik, elperiode)\n```\n\nYou do not need to fill out the MQTT in the `config.cfg` file.\n\n**IMPORTANT:** You should set the `autoDiscovery=false`, since that will publish MQTT-messages specific for Home Assistant.\n\n### Options\n\nThe 2 data options in the config is `daysBack` and `daysSpecific`. For both these options you have to specify an aggregation.\nFor aggregation you can use `Actual | Quarter | Hour | Day | Month | Year`. If the aggregation is higher than the periode you are specifying, you'll get 1 result containing the whole usage.\n\nYou can use both of these options or have multiple dates in both of them - split the dates with a `;`.\n\nI could look like:\n```config\ndaysBack = \"1;7;365\"\naggregationBack = \"Hour;Day;Month\"\n\ndaysSpecific = \"2020-01-01,2020-03-01\" # 2020-01-01,2020-02-01;2020-02-01,2020-03-01\naggregationSpecific = \"Month\" # Month;Day\n```\n\n### Predefined calls\n\nDo you prefer the data returned to Home Assistant? You can use the same predefined calls, which returns the last mont, week and day.\n\n```nim\nlet url  = datesPredefined(mainPeriode, howLongBack, \"Year\")\n# mainPeriode = Month, Week or Day\n# howLongBack = How many months, weeks or days back, you want to see\n```\n```nim\n# The Year in aggregation is used to ensure, that data from the periode is used\n\nlet monthUrl  = datesPredefined(\"Month\", 1, \"Year\")\nlet month     = requestData(actualToken, \"month\", eloverblik.meeteringPoint, monthUrl)\n\nlet weekUrl   = datesPredefined(\"Week\", 1, \"Year\")\nlet week      = requestData(actualToken, \"week\", eloverblik.meeteringPoint, weekUrl)\n\nlet dayUrl    = datesPredefined(\"Day\", 1, \"Year\")\nlet day       = requestData(actualToken, \"day\", eloverblik.meeteringPoint, dayUrl)\n```\n\n# More\nYou can read more about the API the pdf `100120 Customer and Third party API for Datahub Eloverblik  Technical description.pdf`.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomastjdev%2Fnim_eloverblik_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomastjdev%2Fnim_eloverblik_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomastjdev%2Fnim_eloverblik_api/lists"}