Skip to main content

Python library for the ista calista service

Project description

PyCalista-ista

PyPI version Downloads GitHub issues GitHub forks GitHub stars GitHub license GitHub Release Date codecov OpenSSF Best Practices


Unofficial async Python library for the Ista Calista service API. This library allows you to interact with your Ista Calista account to retrieve consumption data from heating and water meters using asyncio and aiohttp.

This project is based on ecotrend-ista and adapted for the Calista portal and asynchronous operation.

Features

  • Asynchronous: Uses asyncio and aiohttp for non-blocking I/O.
  • Login and session management with automatic cookie handling.
  • Retrieve consumption data for heating and water meters.
  • Parse Excel reports (.xls, .xlsx) from Ista Calista using pandas and openpyxl.
  • Support for different meter types (heating, hot water, cold water).
  • Automatic handling of session expiration and relogin attempts.
  • Data interpolation for missing readings.
  • Configurable retries for network requests.

Installation

Requires Python 3.12+

pip install pycalista-ista

This will install the library along with its dependencies (aiohttp, pandas, openpyxl, unidecode, yarl).

Usage

import asyncio
from datetime import date
import aiohttp

from pycalista_ista import PyCalistaIsta, IstaLoginError, IstaConnectionError

async def main():
    # It's recommended to reuse aiohttp ClientSession
    async with aiohttp.ClientSession() as session:
        # Initialize the client, optionally passing the session
        client = PyCalistaIsta("your@email.com", "your_password", session=session)

        try:
            # Login to the service (async)
            await client.login()
            print("Login successful!")

            # Get device history for a date range (async)
            start_date = date(2025, 1, 1)
            end_date = date(2025, 1, 31)
            devices = await client.get_devices_history(start_date, end_date)
            print(f"Retrieved data for {len(devices)} devices.")

            # Access device data
            for serial, device in devices.items():
                print("-" * 20)
                print(f"Device Serial: {serial}")
                print(f"Type: {device.__class__.__name__}")
                print(f"Location: {device.location}")
                if device.last_reading:
                    print(f"Last Reading: {device.last_reading.reading} on {device.last_reading.date.date()}")
                else:
                    print("Last Reading: N/A")
                # Access full history if needed: device.history

        except IstaLoginError as err:
            print(f"Login failed: {err}")
        except IstaConnectionError as err:
            print(f"Connection error: {err}")
        except Exception as err:
            print(f"An unexpected error occurred: {err}")

        # No need to explicitly call client.close() if session is managed externally
        # If client created its own session, call await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Development

Setup Development Environment

  1. Clone the repository:

    git clone [https://github.com/herruzo99/pycalista-ista.git](https://github.com/herruzo99/pycalista-ista.git)
    cd pycalista-ista
    
  2. Create and activate a virtual environment (recommended):

    python -m venv .venv
    source .venv/bin/activate # or .venv\Scripts\activate on Windows
    
  3. Install development dependencies:

    pip install -e ".[dev]"
    

    This installs the package in editable mode plus dev tools like pytest, pytest-asyncio, aresponses, black, isort, mypy, ruff.

  4. Set up pre-commit hooks (optional but recommended):

    pre-commit install
    

Running Tests

The project uses pytest and pytest-asyncio.

# Run all tests
pytest

# Run with coverage report
pytest --cov=pycalista_ista

# Run specific test file
pytest tests/test_virtual_api.py

Tests require mocking external requests, which is handled using aresponses.

Code Style and Linting

  • Code is formatted using black.
  • Imports are sorted using isort.
  • Linting is done using ruff.
  • Type checking is done using mypy.

Run checks manually:

black . --check
isort . --check-only
ruff check .
mypy pycalista_ista tests

Or run pre-commit hooks: pre-commit run --all-files

Contributing

Contributions are welcome! Please follow the guidelines in CONTRIBUTING.md.

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/amazing-feature).
  3. Make your changes, ensuring tests pass and coverage is maintained.
  4. Update documentation if necessary.
  5. Commit your changes following Conventional Commits.
  6. Push to the branch (git push origin feature/amazing-feature).
  7. Open a Pull Request.

Interact with the Project

Get the Software

  1. Install from PyPI:
    pip install pycalista-ista
    
  2. Clone the repository:
    git clone [https://github.com/herruzo99/pycalista-ista.git](https://github.com/herruzo99/pycalista-ista.git)
    

Provide Feedback

Use GitHub Issues and Discussions:

  1. Bug Reports: Open an issue
  2. Feature Requests: Submit an enhancement
  3. Questions: Start a discussion

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

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

Source Distribution

pycalista_ista-0.5.3.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

pycalista_ista-0.5.3-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file pycalista_ista-0.5.3.tar.gz.

File metadata

  • Download URL: pycalista_ista-0.5.3.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycalista_ista-0.5.3.tar.gz
Algorithm Hash digest
SHA256 6c3f28dd2c0f7771ab32da08527e289728920973475397590bf87aa956a1ba80
MD5 4cc165c4d6ddd29b53e5dd3b0d7d9f2e
BLAKE2b-256 30c7d9b59789af05af640aa34798287cbb6e6ce02bb9c91c624c26cb3ff3745d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycalista_ista-0.5.3.tar.gz:

Publisher: python-publish.yml on herruzo99/pycalista-ista

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycalista_ista-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: pycalista_ista-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycalista_ista-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7565daf425a5b248e58a5d1de95b7281dec12b72dd6ffd622ebda0f7e5262220
MD5 8a946afe43f53ba421bf34e85b2bc623
BLAKE2b-256 36ed4028dbf0f40f2491acef614d98d521aac8b68e2b3c31e47459a706e0bf89

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycalista_ista-0.5.3-py3-none-any.whl:

Publisher: python-publish.yml on herruzo99/pycalista-ista

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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