├── README.md ├── LICENSE ├── elicznik.py └── example_output.json /README.md: -------------------------------------------------------------------------------- 1 | # tauron-elicznik-scraper 2 | Simple python3 script that outputs JSON with energy meter data from Tauron eLicznik service 3 | 4 | 5 | # **Important: in 2023 Tauron changed its website and the script is currently not working!** 6 | 7 | 8 | 9 | 1. Add login info and energy meter ID into script 10 | 2. Run with ```python3 elicznik.py``` 11 | 3. Get JSON output with energy meter data from last day 12 | 13 | Energy meter ID can be obtained from https://elicznik.tauron-dystrybucja.pl/ website under "Punkt poboru:" field. 14 | 15 | Script is currently tested only with G11 tariff. 16 | 17 | Optionally you can save JSON as file - just uncomment 2 last lines. 18 | 19 | You can change dane[chartDay] to get data from another day (not only the last one). 20 | 21 | If JSON **should not** contain energy produced from solar panels, please comment the "dane[checkOZE]": "on". 22 | 23 | Enjoy :) 24 | 25 | ![Example usage with Grafana](https://i.imgur.com/vueg6uj.png) 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Michał Zaniewicz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /elicznik.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import requests 4 | from requests import adapters 5 | import ssl 6 | from urllib3 import poolmanager 7 | import datetime 8 | 9 | #Add login details & meter ID here: 10 | username = 'TAURON_USERNAME' 11 | password = 'TAURON_PASSWORD' 12 | meter_id = TAURON_ENERGY_METER_ID 13 | 14 | payload = { 15 | 'username': username, 16 | 'password': password , 17 | 'service': 'https://elicznik.tauron-dystrybucja.pl' 18 | } 19 | 20 | url = 'https://logowanie.tauron-dystrybucja.pl/login' 21 | charturl = 'https://elicznik.tauron-dystrybucja.pl/index/charts' 22 | headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'} 23 | 24 | class TLSAdapter(adapters.HTTPAdapter): 25 | 26 | def init_poolmanager(self, connections, maxsize, block=False): 27 | """Create and initialize the urllib3 PoolManager.""" 28 | ctx = ssl.create_default_context() 29 | ctx.set_ciphers('DEFAULT@SECLEVEL=1') 30 | self.poolmanager = poolmanager.PoolManager( 31 | num_pools=connections, 32 | maxsize=maxsize, 33 | block=block, 34 | ssl_version=ssl.PROTOCOL_TLS, 35 | ssl_context=ctx) 36 | 37 | session = requests.session() 38 | session.mount('https://', TLSAdapter()) 39 | 40 | p = session.request("POST", url, data=payload, headers=headers) 41 | p = session.request("POST", url, data=payload, headers=headers) 42 | 43 | chart = { 44 | #change timedelta to get data from another days (1 for yesterday) 45 | "dane[chartDay]": (datetime.datetime.now() - datetime.timedelta(1)).strftime('%d.%m.%Y'), 46 | "dane[paramType]": "day", 47 | "dane[smartNr]": meter_id, 48 | #comment if don't want generated energy data in JSON output: 49 | "dane[checkOZE]": "on" 50 | } 51 | 52 | r = session.request("POST", charturl, data=chart, headers=headers) 53 | print(r.text) 54 | 55 | #Optionally write JSON to file 56 | #with open('file.json', 'wb') as f: 57 | # f.write(r.content) 58 | -------------------------------------------------------------------------------- /example_output.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": { 3 | "chart": "Pob\u00f3r 04.03.2020", 4 | "OZE": "Generacja 04.03.2020" 5 | }, 6 | "dane": { 7 | "chart": [{ 8 | "EC": "0.089", 9 | "Date": "2020-03-04", 10 | "Hour": "1", 11 | "Status": "0", 12 | "Extra": "0", 13 | "Zone": "1", 14 | "Taryfa": "G11" 15 | }, { 16 | "EC": "0.083", 17 | "Date": "2020-03-04", 18 | "Hour": "2", 19 | "Status": "0", 20 | "Extra": "0", 21 | "Zone": "1", 22 | "Taryfa": "G11" 23 | }, { 24 | "EC": "0.081", 25 | "Date": "2020-03-04", 26 | "Hour": "3", 27 | "Status": "0", 28 | "Extra": "0", 29 | "Zone": "1", 30 | "Taryfa": "G11" 31 | }, { 32 | "EC": "0.078", 33 | "Date": "2020-03-04", 34 | "Hour": "4", 35 | "Status": "0", 36 | "Extra": "0", 37 | "Zone": "1", 38 | "Taryfa": "G11" 39 | }, { 40 | "EC": "0.084", 41 | "Date": "2020-03-04", 42 | "Hour": "5", 43 | "Status": "0", 44 | "Extra": "0", 45 | "Zone": "1", 46 | "Taryfa": "G11" 47 | }, { 48 | "EC": "0.088", 49 | "Date": "2020-03-04", 50 | "Hour": "6", 51 | "Status": "0", 52 | "Extra": "0", 53 | "Zone": "1", 54 | "Taryfa": "G11" 55 | }, { 56 | "EC": "0.358", 57 | "Date": "2020-03-04", 58 | "Hour": "7", 59 | "Status": "0", 60 | "Extra": "0", 61 | "Zone": "1", 62 | "Taryfa": "G11" 63 | }, { 64 | "EC": "0.075", 65 | "Date": "2020-03-04", 66 | "Hour": "8", 67 | "Status": "0", 68 | "Extra": "0", 69 | "Zone": "1", 70 | "Taryfa": "G11" 71 | }, { 72 | "EC": "0.151", 73 | "Date": "2020-03-04", 74 | "Hour": "9", 75 | "Status": "0", 76 | "Extra": "0", 77 | "Zone": "1", 78 | "Taryfa": "G11" 79 | }, { 80 | "EC": "0.14", 81 | "Date": "2020-03-04", 82 | "Hour": "10", 83 | "Status": "0", 84 | "Extra": "0", 85 | "Zone": "1", 86 | "Taryfa": "G11" 87 | }, { 88 | "EC": "0.236", 89 | "Date": "2020-03-04", 90 | "Hour": "11", 91 | "Status": "0", 92 | "Extra": "0", 93 | "Zone": "1", 94 | "Taryfa": "G11" 95 | }, { 96 | "EC": "0.091", 97 | "Date": "2020-03-04", 98 | "Hour": "12", 99 | "Status": "0", 100 | "Extra": "0", 101 | "Zone": "1", 102 | "Taryfa": "G11" 103 | }, { 104 | "EC": "0.09", 105 | "Date": "2020-03-04", 106 | "Hour": "13", 107 | "Status": "0", 108 | "Extra": "0", 109 | "Zone": "1", 110 | "Taryfa": "G11" 111 | }, { 112 | "EC": "0.091", 113 | "Date": "2020-03-04", 114 | "Hour": "14", 115 | "Status": "0", 116 | "Extra": "0", 117 | "Zone": "1", 118 | "Taryfa": "G11" 119 | }, { 120 | "EC": "0.634", 121 | "Date": "2020-03-04", 122 | "Hour": "15", 123 | "Status": "0", 124 | "Extra": "0", 125 | "Zone": "1", 126 | "Taryfa": "G11" 127 | }, { 128 | "EC": "0.216", 129 | "Date": "2020-03-04", 130 | "Hour": "16", 131 | "Status": "0", 132 | "Extra": "0", 133 | "Zone": "1", 134 | "Taryfa": "G11" 135 | }, { 136 | "EC": "0.132", 137 | "Date": "2020-03-04", 138 | "Hour": "17", 139 | "Status": "0", 140 | "Extra": "0", 141 | "Zone": "1", 142 | "Taryfa": "G11" 143 | }, { 144 | "EC": "1.32", 145 | "Date": "2020-03-04", 146 | "Hour": "18", 147 | "Status": "0", 148 | "Extra": "0", 149 | "Zone": "1", 150 | "Taryfa": "G11" 151 | }, { 152 | "EC": "1.221", 153 | "Date": "2020-03-04", 154 | "Hour": "19", 155 | "Status": "0", 156 | "Extra": "0", 157 | "Zone": "1", 158 | "Taryfa": "G11" 159 | }, { 160 | "EC": "0.447", 161 | "Date": "2020-03-04", 162 | "Hour": "20", 163 | "Status": "0", 164 | "Extra": "0", 165 | "Zone": "1", 166 | "Taryfa": "G11" 167 | }, { 168 | "EC": "0.388", 169 | "Date": "2020-03-04", 170 | "Hour": "21", 171 | "Status": "0", 172 | "Extra": "0", 173 | "Zone": "1", 174 | "Taryfa": "G11" 175 | }, { 176 | "EC": "0.154", 177 | "Date": "2020-03-04", 178 | "Hour": "22", 179 | "Status": "0", 180 | "Extra": "0", 181 | "Zone": "1", 182 | "Taryfa": "G11" 183 | }, { 184 | "EC": "0.119", 185 | "Date": "2020-03-04", 186 | "Hour": "23", 187 | "Status": "0", 188 | "Extra": "0", 189 | "Zone": "1", 190 | "Taryfa": "G11" 191 | }, { 192 | "EC": "0.101", 193 | "Date": "2020-03-04", 194 | "Hour": "24", 195 | "Status": "0", 196 | "Extra": "0", 197 | "Zone": "1", 198 | "Taryfa": "G11" 199 | }], 200 | "zone": [], 201 | "zoneN": 0, 202 | "other": [], 203 | "OZE": { 204 | "1": { 205 | "EC": "0", 206 | "Date": "2020-03-04", 207 | "Hour": "1", 208 | "Status": "0", 209 | "Extra": "0", 210 | "Zone": "1", 211 | "Taryfa": "G11" 212 | }, 213 | "2": { 214 | "EC": "0", 215 | "Date": "2020-03-04", 216 | "Hour": "2", 217 | "Status": "0", 218 | "Extra": "0", 219 | "Zone": "1", 220 | "Taryfa": "G11" 221 | }, 222 | "3": { 223 | "EC": "0", 224 | "Date": "2020-03-04", 225 | "Hour": "3", 226 | "Status": "0", 227 | "Extra": "0", 228 | "Zone": "1", 229 | "Taryfa": "G11" 230 | }, 231 | "4": { 232 | "EC": "0", 233 | "Date": "2020-03-04", 234 | "Hour": "4", 235 | "Status": "0", 236 | "Extra": "0", 237 | "Zone": "1", 238 | "Taryfa": "G11" 239 | }, 240 | "5": { 241 | "EC": "0", 242 | "Date": "2020-03-04", 243 | "Hour": "5", 244 | "Status": "0", 245 | "Extra": "0", 246 | "Zone": "1", 247 | "Taryfa": "G11" 248 | }, 249 | "6": { 250 | "EC": "0", 251 | "Date": "2020-03-04", 252 | "Hour": "6", 253 | "Status": "0", 254 | "Extra": "0", 255 | "Zone": "1", 256 | "Taryfa": "G11" 257 | }, 258 | "7": { 259 | "EC": "0", 260 | "Date": "2020-03-04", 261 | "Hour": "7", 262 | "Status": "0", 263 | "Extra": "0", 264 | "Zone": "1", 265 | "Taryfa": "G11" 266 | }, 267 | "8": { 268 | "EC": "0", 269 | "Date": "2020-03-04", 270 | "Hour": "8", 271 | "Status": "0", 272 | "Extra": "0", 273 | "Zone": "1", 274 | "Taryfa": "G11" 275 | }, 276 | "9": { 277 | "EC": "0", 278 | "Date": "2020-03-04", 279 | "Hour": "9", 280 | "Status": "0", 281 | "Extra": "0", 282 | "Zone": "1", 283 | "Taryfa": "G11" 284 | }, 285 | "10": { 286 | "EC": "0", 287 | "Date": "2020-03-04", 288 | "Hour": "10", 289 | "Status": "0", 290 | "Extra": "0", 291 | "Zone": "1", 292 | "Taryfa": "G11" 293 | }, 294 | "11": { 295 | "EC": "0", 296 | "Date": "2020-03-04", 297 | "Hour": "11", 298 | "Status": "0", 299 | "Extra": "0", 300 | "Zone": "1", 301 | "Taryfa": "G11" 302 | }, 303 | "12": { 304 | "EC": "0", 305 | "Date": "2020-03-04", 306 | "Hour": "12", 307 | "Status": "0", 308 | "Extra": "0", 309 | "Zone": "1", 310 | "Taryfa": "G11" 311 | }, 312 | "13": { 313 | "EC": "0", 314 | "Date": "2020-03-04", 315 | "Hour": "13", 316 | "Status": "0", 317 | "Extra": "0", 318 | "Zone": "1", 319 | "Taryfa": "G11" 320 | }, 321 | "14": { 322 | "EC": "0", 323 | "Date": "2020-03-04", 324 | "Hour": "14", 325 | "Status": "0", 326 | "Extra": "0", 327 | "Zone": "1", 328 | "Taryfa": "G11" 329 | }, 330 | "15": { 331 | "EC": "0", 332 | "Date": "2020-03-04", 333 | "Hour": "15", 334 | "Status": "0", 335 | "Extra": "0", 336 | "Zone": "1", 337 | "Taryfa": "G11" 338 | }, 339 | "16": { 340 | "EC": "0", 341 | "Date": "2020-03-04", 342 | "Hour": "16", 343 | "Status": "0", 344 | "Extra": "0", 345 | "Zone": "1", 346 | "Taryfa": "G11" 347 | }, 348 | "17": { 349 | "EC": "0", 350 | "Date": "2020-03-04", 351 | "Hour": "17", 352 | "Status": "0", 353 | "Extra": "0", 354 | "Zone": "1", 355 | "Taryfa": "G11" 356 | }, 357 | "18": { 358 | "EC": "0", 359 | "Date": "2020-03-04", 360 | "Hour": "18", 361 | "Status": "0", 362 | "Extra": "0", 363 | "Zone": "1", 364 | "Taryfa": "G11" 365 | }, 366 | "19": { 367 | "EC": "0", 368 | "Date": "2020-03-04", 369 | "Hour": "19", 370 | "Status": "0", 371 | "Extra": "0", 372 | "Zone": "1", 373 | "Taryfa": "G11" 374 | }, 375 | "20": { 376 | "EC": "0", 377 | "Date": "2020-03-04", 378 | "Hour": "20", 379 | "Status": "0", 380 | "Extra": "0", 381 | "Zone": "1", 382 | "Taryfa": "G11" 383 | }, 384 | "21": { 385 | "EC": "0", 386 | "Date": "2020-03-04", 387 | "Hour": "21", 388 | "Status": "0", 389 | "Extra": "0", 390 | "Zone": "1", 391 | "Taryfa": "G11" 392 | }, 393 | "22": { 394 | "EC": "0", 395 | "Date": "2020-03-04", 396 | "Hour": "22", 397 | "Status": "0", 398 | "Extra": "0", 399 | "Zone": "1", 400 | "Taryfa": "G11" 401 | }, 402 | "23": { 403 | "EC": "0", 404 | "Date": "2020-03-04", 405 | "Hour": "23", 406 | "Status": "0", 407 | "Extra": "0", 408 | "Zone": "1", 409 | "Taryfa": "G11" 410 | }, 411 | "24": { 412 | "EC": "0", 413 | "Date": "2020-03-04", 414 | "Hour": "24", 415 | "Status": "0", 416 | "Extra": "0", 417 | "Zone": "1", 418 | "Taryfa": "G11" 419 | } 420 | }, 421 | "myAverage": [], 422 | "weather": [], 423 | "cloudiness": [] 424 | }, 425 | "sum": 6.467, 426 | "sumOther": 0, 427 | "sumMyAverage": 0, 428 | "OZEValue": 0, 429 | "sLastReadOZE": "Stan licznika:
Strefa T1
000001<\/dd><\/span>", 430 | "sumTarget": 0, 431 | "pie": [], 432 | "TargetValue": 0, 433 | "TargetRange": 0, 434 | "legend": "", 435 | "countTarif": 1, 436 | "sCompareTable": "", 437 | "isFull": true, 438 | "isFullOther": true, 439 | "ok": 1 440 | } --------------------------------------------------------------------------------