Skip to main content

Async Python client for Pulsegrow API

Project description

aiopulsegrow

Async Python client for the Pulsegrow API - designed for Home Assistant integrations.

Features

  • Fully async using aiohttp
  • Type-safe with full type hints
  • Comprehensive API coverage for all Pulsegrow endpoints
  • Session management following Home Assistant best practices
  • Extensive test coverage
  • Automatic rate limit handling
  • ISO 8601 datetime support

Installation

pip install aiopulsegrow

Quick Start

import asyncio
from aiopulsegrow import PulsegrowClient
from aiohttp import ClientSession

async def main():
    async with ClientSession() as session:
        client = PulsegrowClient(api_key="your-api-key", session=session)

        # Get all devices
        devices = await client.get_all_devices()
        print(f"Found {len(devices.get('devices', []))} devices")

        # Get recent data for a device
        data = await client.get_device_recent_data(device_id=123)
        print(f"Temperature: {data.get('temperature')}°C")

asyncio.run(main())

Usage with Home Assistant Pattern

from aiopulsegrow import PulsegrowClient
from aiohttp import ClientSession

# In Home Assistant, create the session once and reuse it
session = ClientSession()
client = PulsegrowClient(api_key="your-api-key", session=session)

# Use the client throughout your integration
devices = await client.get_all_devices()

# Close when done (usually in async_unload_entry)
await client.close()
await session.close()

API Methods

Devices

  • get_all_devices() - Get all devices with latest data
  • get_device_ids() - List all device IDs
  • get_device_details() - Get detailed device information
  • get_device_recent_data(device_id) - Get last data point for a device
  • get_device_data_range(device_id, start, end=None) - Get data within timeframe
  • get_devices_range(start, end=None) - Get all device data (max 7 days)

Sensors

  • get_sensor_ids() - List all sensor IDs
  • get_sensor_recent_data(sensor_id) - Get last data point for a sensor
  • force_sensor_read(sensor_id) - Trigger immediate sensor reading
  • get_sensor_data_range(sensor_id, start, end=None) - Get sensor data in range
  • get_sensor_details(sensor_id) - Get sensor configuration

Hubs

  • get_hub_ids() - List all hub IDs
  • get_hub_details(hub_id) - Get hub details

Light Readings (Pro)

  • get_light_readings(device_id, page=None) - Get light spectrum readings
  • trigger_light_reading(device_id) - Trigger Pro light measurement

Timeline & Thresholds

  • get_timeline(event_types=None, start_date=None, end_date=None, count=None, page=None) - Get grow events
  • get_triggered_thresholds() - Get active/resolved threshold violations

Users

  • get_users() - Get user usage information
  • get_invitations() - Get pending invitations

Authentication

All requests require an API key. Get yours from your Pulsegrow account settings.

client = PulsegrowClient(api_key="your-api-key-here", session=session)

Rate Limits

  • Hobbyist: 4,800 datapoints/day
  • Enthusiast: 24,000 datapoints/day
  • Professional: 120,000 datapoints/day

Error Handling

from aiopulsegrow import PulsegrowError

try:
    data = await client.get_device_recent_data(device_id=123)
except PulsegrowError as err:
    print(f"API error: {err}")

Development

# Clone the repository
git clone https://github.com/yourusername/aiopulsegrow.git
cd aiopulsegrow

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=aiopulsegrow --cov-report=html

# Format code
ruff format aiopulsegrow tests

# Lint and fix issues
ruff check --fix aiopulsegrow tests

# Type checking
mypy aiopulsegrow

Generating Mock Data from Real API

You can fetch real data from your Pulsegrow account to generate realistic test fixtures:

python scripts/fetch_mock_data.py YOUR_API_KEY

This will create tests/fixtures/mock_data.py with real API responses that you can use in tests. See scripts/README.md for more details.

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

aiopulsegrow-25.12.1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

aiopulsegrow-25.12.1-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file aiopulsegrow-25.12.1.tar.gz.

File metadata

  • Download URL: aiopulsegrow-25.12.1.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiopulsegrow-25.12.1.tar.gz
Algorithm Hash digest
SHA256 d071d4e9668699498e17ebefaa9b6659f02bd22741227d47d45c7e7e2fb3aae9
MD5 b9ec61b83a437c8c65844aab8e1834de
BLAKE2b-256 1c4b17cae1d723f2a138fdb02ac5c3175f0b2fd34e96f904c24cf9b0b35e5fb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopulsegrow-25.12.1.tar.gz:

Publisher: publish.yml on pvizeli/aiopulsegrow

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

File details

Details for the file aiopulsegrow-25.12.1-py3-none-any.whl.

File metadata

  • Download URL: aiopulsegrow-25.12.1-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiopulsegrow-25.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce6e6ad3e1d1165c368a4a6f99f027aa0bd169d5b6b07dfdec93b2ebd18c8b80
MD5 44909a8e472dbb6fdc2cf2ed5cdfad02
BLAKE2b-256 99407e5925c38ae8a47a760ee721acdd84c9177707cf577cce8a08bb3da38ecf

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopulsegrow-25.12.1-py3-none-any.whl:

Publisher: publish.yml on pvizeli/aiopulsegrow

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