Skip to main content

Retrieve gas consumption from GrDF web site (French Gas Company)

Project description

PyGazpar

PyGazpar is a Python library for getting natural gas consumption from GrDF French provider.

Their natural gas meter is called Gazpar. It is wireless and transmit the gas consumption once per day.

All consumption data is available on the client account at GrDF Web Site (https://monespace.grdf.fr).

PyGazpar automatically go through the Web Site and download the consumption data Excel file, and make it available in a Python structure (list of dictionaries).

Installation

Requirements

PyGazpar is working with Selenium Python library to automate navigation through GrDF Web site. Selenium requires a WebDriver that acts as gateway between automatic actions from PyGazpar and a native browser already installed on the system.

PyGazpar has been developped and tested with Firefox browser (version 68.8) and its corresponding Web Driver geckodriver (version 0.24).

Firefox browser installation

Follow instructions here

Firefox Web Driver (geckodriver) installation

Follow instructions here

Create your virtual environment

$ pip install virtualenv

$ cd /path/to/my_project_folder/

$ virtualenv venv

PyGazpar installation

Activate your virtual environment.

source venv/bin/activate

Use the package manager pip to install PyGazpar.

pip install pygazpar

You can also download the source code and install it manually.

cd /path/to/pygazpar/
python setup.py install

Usage

Command line

$ pygazpar -u 'your login' -p 'your password' -w 'path/to/Selenium Web Driver' -s 30 -t 'temporary directory where to store XSLX file (ex: /tmp)'

Library

import pygazpar

client = pygazpar.Client('your login',
                         'your password',
                         'path/to/Selenium Web Driver',
                         30,
                         'temporary directory where to store XSLX file (ex: /tmp)')

client.update()

data = client.data()

Output

data =>
[
  {
    "date": "01/07/2019",
    "start_index_m3": 9802.0,
    "end_index_m3": 9805.0,
    "volume_m3": 3.6,
    "energy_kwh": 40.0,
    "converter_factor": "11,244",
    "local_temperature": "",
    "type": "MES",
    "timestamp": "2019-08-29T16:56:07.380422"
  },
  {
    "date": "02/07/2019",
    "start_index_m3": 9805.0,
    "end_index_m3": 9808.0,
    "volume_m3": 2.8,
    "energy_kwh": 31.0,
    "converter_factor": "11,244",
    "local_temperature": "21",
    "type": "MES",
    "timestamp": "2019-08-29T16:56:07.380422"
  },
  {
    "date": "03/07/2019",
    "start_index_m3": 9808.0,
    "end_index_m3": 9811.0,
    "volume_m3": 2.9,
    "energy_kwh": 33.0,
    "converter_factor": "11,244",
    "local_temperature": "",
    "type": "MES",
    "timestamp": "2019-08-29T16:56:07.380422"
  }
]

Limitation

PyGazpar relies on how GrDF Web Site is built. It goes through each Web pages and automatically fill forms, click buttons using their internal identifiers.

Any change in the Web site structure or identifier naming may break this library.

We expect in close Future that GrDF makes available a standard API from which we can get safely their data.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project status

PyGazpar has been initiated for integration with Home Assistant.

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

0.1.25 - 2021-04-15

Fixed

  • Remove useless warning log messages (log message level has been decreased to debug).

0.1.24 - 2021-04-14

Added

  • README.md amendment (thanks to pbranly).

0.1.23 - 2021-04-09

Changed

  • Final release with CI/CD workflow improvement.

0.1.22 - 2021-04-09

Changed

  • Improve CI/CD workflow.

0.1.21 - 2021-04-07

Changed

  • Cleanup some codes managing Privacy Conditions popup.

0.1.20 - 2021-04-07

Changed

  • Close an eventual Privacy Conditions popup just before clicking the daily button (instead of Cookie banner).

0.1.19 - 2021-04-06

Added

  • Close an eventual Cookie popup just before clicking the daily button.
  • Add log messages and screenshot capture around click() and send_keys() methods.

0.1.18 - 2021-04-05

Fixed

  • Typo in logger usage.

0.1.17 - 2021-04-05

Fixed

  • Logger name must be different in each instance. Using name is a good practice, we can get the module hierarchy.

0.1.16 - 2021-04-05

Fixed

  • Logger 'pygazpar' initialization must be done inside the main program and not inside the library.

0.1.15 - 2021-04-05

Added

  • Many log message to help debugging if GrDF site changes something : pygazpar.log
  • Take a screenshot of the corresponding page where a selenium command fails : error_screenshot.png.

0.1.14 - 2020-09-23

Fixed

  • GrDF survey popup has to be closed at the home page.
  • GrDF Assistant popup may hide the Download button. We have to close it.
  • GrDF bottom banner that invite to accept cookies may also hide the Download button. We have to accept it.

Added

  • A new parameter 'lastNRows' to get only the last N most recent records.

0.1.13 - 2020-06-30

Fixed

  • GrDF data retrieval from Excel file is not limited to the 1000 first rows any more.

0.1.12 - 2020-06-30

Fixed

  • The previous 0.1.11 is not sufficient. Hence, 2 new changes : First, make configurable the waiting time so the user can adapt to its context usage. Second, the condition on clicking on Download button is now based on the corresponding event and not anymore on its identifier.

0.1.11 - 2020-06-29

Fixed

  • When GrDF Web site is slower than usual, the client may not wait enough time for pages to load and miss to reach the data file. It occurs with the page containing 'Jour' button which is very long to load (I increase the wait to load time from 5s to 30s).

0.1.10 - 2020-06-03

Fixed

  • Extract rows from Excel until line 1000 (instead of 365 as before).

0.1.9 - 2019-08-31

Fixed

  • WebDriver window size must be large enough to display all clickable components.

0.1.8 - 2019-08-31

Changed

  • Use PropertyNameEnum type to store all property names.

0.1.7 - 2019-08-29

Added

  • Add wait_time option to control how much time the library has to wait for Web page element to load (see https://selenium-python.readthedocs.io/waits.html for details).
  • Add LoginError exception raised when PyGazpar is unable to sign in the GrDF Web site with the given username/password.
  • Refactor all data property names.

0.1.6 - 2019-08-26

Added

  • Add README.md and CHANGELOG.md.
  • Add Client.data() method to get the updated data.

Removed

  • Remove Client.data property to get the updated data. Replaced with Client.__data private property.

MIT License

Copyright (c) 2019 Stéphane Senart

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygazpar-0.1.25.tar.gz (14.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pygazpar-0.1.25-py39-none-any.whl (13.1 kB view details)

Uploaded Python 3.9

pygazpar-0.1.25-py38-none-any.whl (13.1 kB view details)

Uploaded Python 3.8

pygazpar-0.1.25-py37-none-any.whl (13.1 kB view details)

Uploaded Python 3.7

pygazpar-0.1.25-py36-none-any.whl (13.1 kB view details)

Uploaded Python 3.6

File details

Details for the file pygazpar-0.1.25.tar.gz.

File metadata

  • Download URL: pygazpar-0.1.25.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9

File hashes

Hashes for pygazpar-0.1.25.tar.gz
Algorithm Hash digest
SHA256 23908434d55420d8be4f5d65ad2bce4dc37327f16d146a6e023b7d46907db2fd
MD5 288952b9d18b81692262ce1dea738a03
BLAKE2b-256 a236ccb5f44da49a8b4a3423b40811e27716d0fb75b2de4ed6b3a847c62f2889

See more details on using hashes here.

File details

Details for the file pygazpar-0.1.25-py39-none-any.whl.

File metadata

  • Download URL: pygazpar-0.1.25-py39-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for pygazpar-0.1.25-py39-none-any.whl
Algorithm Hash digest
SHA256 f0393aa21b838318fd7fec4dfef9ffb4591ed0b7fe2a81d6b28f9507a1c07ea5
MD5 a1c5743aa8f5965649a474131e0a1766
BLAKE2b-256 4fd6dcdf21cbe86c1579c3c1a0cbb6bb811f413528434f63bd70a6c4d5563119

See more details on using hashes here.

File details

Details for the file pygazpar-0.1.25-py38-none-any.whl.

File metadata

  • Download URL: pygazpar-0.1.25-py38-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9

File hashes

Hashes for pygazpar-0.1.25-py38-none-any.whl
Algorithm Hash digest
SHA256 987105131c4a992258793d85f918b8aba48cce66cb3324dd7071cdc5b220b318
MD5 ef8d7149402ce2c22303c7383c01430b
BLAKE2b-256 5f9a0a528a3424b82c3ff38f36550e3d0087e453e71554e0b40530cbf9df0654

See more details on using hashes here.

File details

Details for the file pygazpar-0.1.25-py37-none-any.whl.

File metadata

  • Download URL: pygazpar-0.1.25-py37-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10

File hashes

Hashes for pygazpar-0.1.25-py37-none-any.whl
Algorithm Hash digest
SHA256 7c227f0833ccd1235484e06a3e13d53273f2e68e6aadab528028bc50c0afaf32
MD5 bcb4b38947561de38d6fb4dab55e414c
BLAKE2b-256 366d6d9516a20bdd36faf990584d8647422a93dfa819ffab93e51fa98bfef616

See more details on using hashes here.

File details

Details for the file pygazpar-0.1.25-py36-none-any.whl.

File metadata

  • Download URL: pygazpar-0.1.25-py36-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.13

File hashes

Hashes for pygazpar-0.1.25-py36-none-any.whl
Algorithm Hash digest
SHA256 77bf6ae4d6b58410f7990d070fc3a4ab53dea575a5f44472c7334e6356168629
MD5 d9bcc315b76d2020bbf078bab160e44f
BLAKE2b-256 259a0a3e64db0f1d4d1a3bbdc4c56277ccf3dfff91bb1a4d56f97b589a31eaf8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page