Skip to main content

A modern Python library for interacting with the Tigo Energy API

Project description

Tigo Python API Wrapper

A modern, open-source Python library for interacting with the Tigo Energy API.

Features

  • 🔑 Automatic authentication with credentials from environment
  • 📊 Raw API access and convenient DataFrame helpers
  • Built-in rate limiting and error handling
  • 🧪 Well-tested with comprehensive test suite
  • 📈 Advanced analytics including system efficiency and panel performance
  • 🛡️ Type hints for better development experience

Installation

From PyPI (when published)

pip install tigo-python

From GitHub

pip install git+https://github.com/matt-dreyer/tigo-python.git

Development Installation

git clone https://github.com/matt-dreyer/tigo-python.git
cd tigo-python
pip install -e ".[dev]"

Quick Start

1. Set up credentials

Create a .env file in your project root:

TIGO_USERNAME=your_username
TIGO_PASSWORD=your_password

Or set environment variables:

export TIGO_USERNAME=your_username
export TIGO_PASSWORD=your_password

2. Basic usage

from tigo_python import TigoClient

# Credentials loaded automatically from environment
with TigoClient() as client:
    # Get your systems
    systems = client.list_systems()
    system_id = systems["systems"][0]["system_id"]
    
    # Get current performance
    summary = client.get_summary(system_id)
    print(f"Current power: {summary['summary']['last_power_dc']} W")
    
    # Get historical data as DataFrame
    df = client.get_today_data(system_id)
    print(df.head())

3. Advanced analytics

# System efficiency analysis
efficiency = client.calculate_system_efficiency(system_id, days_back=30)
print(f"System efficiency: {efficiency['average_efficiency_percent']:.1f}%")

# Panel performance comparison
panel_perf = client.get_panel_performance(system_id)
print(panel_perf.head())

# Find underperforming panels
problems = client.find_underperforming_panels(system_id, threshold_percent=85)
for panel in problems:
    print(f"Panel {panel['panel_id']}: {panel['efficiency_percent']:.1f}% efficiency")

API Coverage

Core Endpoints

  • Authentication - Login/logout with token management
  • Users - User information and preferences
  • Systems - List systems, get details and layouts
  • Sources - Hardware sources and configurations
  • Objects - System components and hierarchy
  • Data - Combined and aggregate data endpoints
  • Alerts - System alerts and notifications

Data Formats

  • Raw API responses - Direct JSON from Tigo API
  • CSV strings - For integration with other tools
  • Pandas DataFrames - For data analysis and visualization

Error Handling

The library provides specific exceptions for different error scenarios:

from tigo_python.exceptions import TigoAPIError, TigoAuthenticationError

try:
    client = TigoClient("wrong_user", "wrong_pass")
except TigoAuthenticationError as e:
    print(f"Login failed: {e}")
except TigoAPIError as e:
    print(f"API error: {e}")

Rate Limiting

The library automatically handles API rate limits by:

  • Limiting data requests to safe time ranges (≤20,150 minutes)
  • Using appropriate data resolution (minute/hour/day) based on time span
  • Providing helpful warnings when requests are adjusted

Development

Setup

git clone https://github.com/mattdreyer/tigo-python.git
cd tigo-python
pip install -e ".[dev]"

Running Tests

pytest tests/ -v

Code Quality

# Linting
ruff check tigo_python/

# Type checking  
mypy tigo_python/

# Formatting
ruff format tigo_python/

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Ensure code quality checks pass
  5. Submit a pull request

Requirements

  • Python ≥ 3.8
  • httpx ≥ 0.27.0
  • pandas ≥ 2.0.0
  • numpy ≥ 1.24.0

Acknowledgments

This project is inspired by the Rust tigo client by @mrustl.

License

MIT License - see LICENSE for details.


This library is not affiliated with or endorsed by Tigo Energy.

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

tigo_python-0.1.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

tigo_python-0.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file tigo_python-0.1.0.tar.gz.

File metadata

  • Download URL: tigo_python-0.1.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tigo_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0299d8e03c538137e2ac6db5843938784d55a3d100d565a2b0fe6809ac6100ee
MD5 a3470d94349cd93cc349bf0891f463bd
BLAKE2b-256 cb776224292e8e9d353be8a0af4bfbbd597439639ca2e556bc87171c7603cebe

See more details on using hashes here.

File details

Details for the file tigo_python-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tigo_python-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tigo_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ceeafb9c8a8aaf6891159addef3d7c206cee103b7d39ee2e237e41cc5b84f5d
MD5 f0158ffaa85d7cbf677036c4a11382d5
BLAKE2b-256 aad39f5f74962d1ec4f274cad412a0e3f0b213dc86a2714bcc7b8ad5147ca673

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