Skip to content

Commit

Permalink
fix: Add get_consumption_details endpoint (#456)
Browse files Browse the repository at this point in the history
* fix(api): Add get_consumption_details endpoint

* fix(cli): Add consumption-details commant

* doc: fix set_invitation result example

* ci: Remove pypi cleanup job (need to do it manually)

* docs: Clean the pypi test releases
  • Loading branch information
germainlefebvre4 authored Jan 27, 2025
1 parent c2ff1aa commit ea4ff05
Show file tree
Hide file tree
Showing 11 changed files with 1,012 additions and 157 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/release-feat-dryrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ jobs:
poetry publish -r test-pypi
if: needs.release.outputs.new_release_published == 'true'

- name: Clean PyPi release
if: always()
run: |
poetry add pypi-cleanup
poetry run pypi-cleanup --host https://test.pypi.org --username '__token__' --package libtado --do-it
env:
PYPI_CLEANUP_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
# - name: Clean PyPi release
# if: always()
# run: |
# poetry add pypi-cleanup
# poetry run pypi-cleanup --host https://test.pypi.org --username $PYPI_CLEANUP_USERNAME --package libtado --do-it
# env:
# PYPI_CLEANUP_USERNAME: ${{ secrets.PYPI_TEST_USERNAME }}
# PYPI_CLEANUP_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
3 changes: 2 additions & 1 deletion check.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
# print(tado.set_away_configuration(6, "HEATING", "MEDIUM", 16))
# print(tado.set_zone_order([{"id":1},{"id":6},{"id":11},{"id":12}]))
# print(tado.set_invitation("germain@libtado.fr"))
print(tado.delete_invitation("aa21a793520c4b9eb4559bc5fb560291"))
# print(tado.delete_invitation("aa21a793520c4b9eb4559bc5fb560291"))
print(tado.get_consumption_details("2025-01"))
14 changes: 14 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,17 @@ tox -e py3.11,lint,generate_json_schemas,unittest
```

The pull request checking pipeline will run the same commands on several python versions to ensure the compatibility of the library.

## Clean the releases on PyPi

Every commit on feature branches will generate a new release on PyPi Test to ensure everything is working fine on release management.

Only admins can do this part.

Delete the release on PyPi Test:

```bash
export PYPI_CLEANUP_USERNAME=""
export PYPI_CLEANUP_PASSWORD=""
pypi-cleanup --host https://test.pypi.org --username $PYPI_CLEANUP_USERNAME --package libtado
```
20 changes: 20 additions & 0 deletions libtado/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,5 +521,25 @@ def schedule_block_day_type(tado, zone, schedule, day_type):
click.echo('')


@main.command()
@click.pass_obj
@click.option('--month-date', '-d', required=True, type=str, help='Month year (i.e. 2022-09)')
def consumption_details(tado, month_date):
"""Get the consumption details of your home."""
consumption_details = tado.get_consumption_details(month_date)

click.echo('Consumption for %s' % (month_date))
click.echo('')

click.echo('Summary:')
click.echo(' Consumption (%s): %d' % (consumption_details['summary']['unit'], consumption_details['summary']['consumption']))
click.echo(' Cost: %.2f' % (consumption_details['summary']['costInCents']/100))
click.echo('')

click.echo('Details:')
for cd in consumption_details['graphConsumption']['monthlyAggregation']['requestedMonth']['consumptionPerDate']:
click.echo(' %s\tConsumption (%s): %s\t\tCost: %.2f' % (cd['date'], consumption_details['graphConsumption']['unit'], cd['consumption'], cd['costInCents']/100))


if __name__ == "__main__":
main()
Loading

0 comments on commit ea4ff05

Please sign in to comment.