Skip to content

Commit

Permalink
Merge pull request #61 from ssenart/develop
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
ssenart committed Dec 16, 2022
2 parents a6247fd + e11db13 commit 251b110
Show file tree
Hide file tree
Showing 26 changed files with 23,111 additions and 497 deletions.
35 changes: 24 additions & 11 deletions .github/workflows/python-publish-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Firefox
run: |
sudo apt -y update
sudo apt -y install firefox
sudo apt -y --only-upgrade install firefox
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -128,13 +122,32 @@ jobs:
replace-with: 'py$1$2'
flags: 'g'

- name: Version PreReleaseLabel alpha replaced by a letter
uses: frabert/replace-string-action@master
id: alpha_PreReleaseLabel
with:
pattern: 'alpha'
string: '${{ steps.gitversion.outputs.preReleaseLabel }}'
replace-with: 'a'
flags: 'g'

- name: Version PreReleaseLabel beta replaced by b letter
uses: frabert/replace-string-action@master
id: PreReleaseLabel
with:
pattern: 'beta'
string: '${{ steps.alpha_PreReleaseLabel.outputs.replaced }}'
replace-with: 'b'
flags: 'g'

- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python updateVersion.py --nextVersion ${{ steps.gitversion.outputs.majorMinorPatch }}.dev${{ steps.gitversion.outputs.buildMetaData }}
python updateVersion.py --nextVersion ${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.PreReleaseLabel.outputs.replaced }}${{ steps.gitversion.outputs.preReleaseNumber }}
python setup.py sdist bdist_wheel --python-tag ${{ steps.python-tag.outputs.replaced }}
twine upload --skip-existing --repository testpypi dist/*
if: ${{ matrix.python-version == 3.10 && github.repository == 'ssenart/PyGazpar' }}
# twine upload --skip-existing --repository testpypi dist/*
twine upload --skip-existing dist/*
if: ${{ github.repository == 'ssenart/PyGazpar' }}

8 changes: 1 addition & 7 deletions .github/workflows/python-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Firefox
run: |
sudo apt -y update
sudo apt -y install firefox
sudo apt -y --only-upgrade install firefox
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -88,4 +82,4 @@ jobs:
python updateVersion.py --nextVersion ${{ github.event.release.tag_name }}
python setup.py sdist bdist_wheel --python-tag ${{ steps.python-tag.outputs.replaced }}
twine upload --skip-existing dist/*
if: github.repository == 'ssenart/PyGazpar'
if: ${{ github.repository == 'ssenart/PyGazpar' }}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0](https://github.com/ssenart/PyGazpar/compare/1.1.6...1.2.0) - 2022-12-16

### Changed
- [#59](https://github.com/ssenart/PyGazpar/issues/59): [Feature] Support both Excel and Json data source format from GrDF site.

- [#60](https://github.com/ssenart/PyGazpar/issues/60): [Feature] Permit to load data at multiple frequencies with one method call.

### Fixed
- [#47](https://github.com/ssenart/PyGazpar/issues/47): [Bug] No temperature field available.

- [#58](https://github.com/ssenart/PyGazpar/issues/58): [Issue] No data update - GrDF web site is half broken - Download button does not work anymore.

## [1.1.6](https://github.com/ssenart/PyGazpar/compare/1.1.5...1.1.6) - 2022-11-16
### Fixed
- [#55](https://github.com/ssenart/PyGazpar/issues/55): Problème de connexion.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ include pygazpar/resources/hourly_data_sample.json
include pygazpar/resources/daily_data_sample.json
include pygazpar/resources/weekly_data_sample.json
include pygazpar/resources/monthly_data_sample.json
include pygazpar/resources/yearly_data_sample.json
243 changes: 84 additions & 159 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Their natural gas meter is called Gazpar. It is wireless and transmit the gas co

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

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

## Installation

Expand All @@ -18,7 +18,7 @@ With the new GrDF web site, it is possible to load the consumption data far easi
```bash
$ cd /path/to/my_project_folder/

$ python3 -m venv .venv
$ python -m venv .venv
```

### PyGazpar installation
Expand All @@ -42,195 +42,120 @@ python setup.py install

#### Command line:

```bash
$ pygazpar -u 'your login' -p 'your password' -c 'your PCE identifier' -t 'temporary directory where to store XSLX file (ex: /tmp)'
```

#### Library:

```python
import pygazpar

client = pygazpar.Client(username='your login',
password='your password',
pceIdentifier='your PCE identifier',
meterReadingFrequency=pygazpar.Frequency.DAILY,
lastNDays=10,
tmpDirectory='/tmp/pygazpar')

client.update()
1. Standard usage (using Json GrDF API).

data = client.data()
```bash
$ pygazpar -u 'your login' -p 'your password' -c 'your PCE identifier' --datasource 'json'
```

#### Output:
2. Alternate usage (using Excel GrDF document).

```json
data =>
[
{
"time_period": "16/04/2021",
"start_index_m3": 13685.0,
"end_index_m3": 13695.0,
"volume_m3": 9.9,
"energy_kwh": 111.0,
"converter_factor_kwh/m3": 11.268,
"temperature_degC": 8.0,
"type": "MES",
"timestamp": "2021-04-20T10:21:46.265119"
},
{
"time_period": "17/04/2021",
"start_index_m3": 13695.0,
"end_index_m3": 13702.0,
"volume_m3": 7.7,
"energy_kwh": 86.0,
"converter_factor_kwh/m3": 11.268,
"temperature_degC": 9.0,
"type": "MES",
"timestamp": "2021-04-20T10:21:46.265119"
},
{
"time_period": "18/04/2021",
"start_index_m3": 13702.0,
"end_index_m3": 13708.0,
"volume_m3": 6.2,
"energy_kwh": 69.0,
"converter_factor_kwh/m3": 11.268,
"temperature_degC": 10.0,
"type": "MES",
"timestamp": "2021-04-20T10:21:46.265119"
}
]
```bash
$ pygazpar -u 'your login' -p 'your password' -c 'your PCE identifier' -t 'temporary directory where to store Excel file (ex: /tmp)' --datasource 'excel'
```

## More features
By default, PyGazpar queries for daily consumption data.

However, it is also possible to get weekly or monthly consumption data :
3. Test usage (using local static data files, do not connect to GrDF site).

### Weekly

#### Command line:
```bash
$ pygazpar -u 'your login' -p 'your password' -c 'your PCE identifier' -t 'temporary directory where to store XSLX file (ex: /tmp)' -f WEEKLY
$ pygazpar -u 'your login' -p 'your password' -c 'your PCE identifier' --datasource 'test'
```

#### Library:

1. Standard usage (using Json GrDF API).

```python
import pygazpar

client = pygazpar.Client(username='your login',
password='your password',
pceIdentifier='your PCE identifier',
meterReadingFrequency=pygazpar.Frequency.WEEKLY,
lastNDays=10,
tmpDirectory='/tmp/pygazpar')

client.update()
client = pygazpar.Client(pygazpar.JsonWebDataSource(
username='your login',
password='your password')
)

data = client.data()
data = client.loadSince(pceIdentifier='your PCE identifier',
lastNDays=60,
frequencies=[pygazpar.Frequency.DAILY, pygazpar.Frequency.MONTHLY])
```
See [samples/jsonSample.py](samples/jsonSample.py) file for the full example.

#### Output:
2. Alternate usage (using Excel GrDF document).

```json
data =>
[
{
"time_period": "Du 29/03/2021 au 04/04/2021",
"volume_m3": 21.4,
"energy_kwh": 240.0,
"timestamp": "2021-04-20T09:22:12.166500"
},
{
"time_period": "Du 05/04/2021 au 11/04/2021",
"volume_m3": 58.9,
"energy_kwh": 663.0,
"timestamp": "2021-04-20T09:22:12.166500"
},
{
"time_period": "Du 12/04/2021 au 18/04/2021",
"volume_m3": 57.1,
"energy_kwh": 643.0,
"timestamp": "2021-04-20T09:22:12.166500"
}
]
```
```python
import pygazpar

### Monthly
client = pygazpar.Client(pygazpar.ExcelWebDataSource(
username='your login',
password='your password')
)

#### Command line:
```bash
$ pygazpar -u 'your login' -p 'your password' -c 'your PCE identifier' -t 'temporary directory where to store XSLX file (ex: /tmp)' -f MONTHLY
data = client.loadSince(pceIdentifier='your PCE identifier',
lastNDays=60,
frequencies=[pygazpar.Frequency.DAILY, pygazpar.Frequency.MONTHLY])
```
See [samples/excelSample.py](samples/jsonSample.py) file for the full example.

3. Test usage (using local static data files, do not connect to GrDF site).

#### Library:
```python
import pygazpar

client = pygazpar.Client(username='your login',
password='your password',
pceIdentifier='your PCE identifier',
meterReadingFrequency=pygazpar.Frequency.MONTHLY,
lastNDays=10,
tmpDirectory='/tmp/pygazpar')

client.update()
client = pygazpar.Client(pygazpar.TestDataSource())

data = client.data()
data = client.loadSince(pceIdentifier='your PCE identifier',
lastNDays=10,
frequencies=[pygazpar.Frequency.DAILY, Frequency.MONTHLY])
```
See [samples/testSample.py](samples/jsonSample.py) file for the full example.

#### Output:

```json
data =>
[
{
"time_period": "F\u00e9vrier 2021",
"volume_m3": 317.6,
"energy_kwh": 3547.0,
"timestamp": "2021-04-20T09:34:31.728125"
},
{
"time_period": "Mars 2021",
"volume_m3": 261.1,
"energy_kwh": 2937.0,
"timestamp": "2021-04-20T09:34:31.728125"
},
{
"time_period": "Avril 2021",
"volume_m3": 130.7,
"energy_kwh": 1472.0,
"timestamp": "2021-04-20T09:34:31.728125"
}
]
```

### Test mode

In testing environment (unit test or debugging), it may be cumbersome to work with live data: slowness, values are always changing.

There is a test mode that permits to work with static data. Those data are taken from internal resource files.

#### Command line:
```bash
$ pygazpar -u 'your login' -p 'your password' -c 'your PCE identifier' -t 'temporary directory where to store XSLX file (ex: /tmp)' --testMode
```

#### Library:
```python
import pygazpar

client = pygazpar.Client(username='your login',
password='your password',
pceIdentifier='your PCE identifier',
tmpDirectory='/tmp/pygazpar',
testMode = True)

client.update()

data = client.data()
{
"daily": [
{
"time_period": "13/10/2022",
"start_index_m3": 15724,
"end_index_m3": 15725,
"volume_m3": 2,
"energy_kwh": 17,
"converter_factor_kwh/m3": 11.16,
"temperature_degC": null,
"type": "Mesur\u00e9",
"timestamp": "2022-12-13T23:58:35.606763"
},
...
{
"time_period": "11/12/2022",
"start_index_m3": 16081,
"end_index_m3": 16098,
"volume_m3": 18,
"energy_kwh": 201,
"converter_factor_kwh/m3": 11.27,
"temperature_degC": -1.47,
"type": "Mesur\u00e9",
"timestamp": "2022-12-13T23:58:35.606763"
}
],
"monthly": [
{
"time_period": "Novembre 2022",
"start_index_m3": 15750,
"end_index_m3": 15950,
"volume_m3": 204,
"energy_kwh": 2227,
"timestamp": "2022-12-13T23:58:35.606763"
},
{
"time_period": "D\u00e9cembre 2022",
"start_index_m3": 15950,
"end_index_m3": 16098,
"volume_m3": 148,
"energy_kwh": 1664,
"timestamp": "2022-12-13T23:58:35.606763"
}
]
}
```

## Limitation
Expand Down
1 change: 1 addition & 0 deletions pygazpar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pygazpar.enum import PropertyName, Frequency # noqa: F401
from pygazpar.client import Client # noqa: F401
from pygazpar.datasource import JsonWebDataSource, ExcelFileDataSource, JsonFileDataSource, ExcelWebDataSource, TestDataSource # noqa: F401
from pygazpar.version import __version__ # noqa: F401

0 comments on commit 251b110

Please sign in to comment.