Skip to main content

Async Python wrapper for Netro API (HTTP-agnostic, HA-friendly)

Project description

pynetro

Async Python wrapper for Netro API — HTTP-agnostic (works with adapters). Designed to integrate with Home Assistant but usable anywhere.

Installation

🚀 Quick Installation

# Clone the project
git clone https://github.com/kcofoni/pynetro.git
cd pynetro

# Install in development mode
pip install -e .

🛠️ Complete Development Setup

1. Prerequisites

  • Python 3.10 or higher
  • git

2. Environment Setup

# Clone the project
git clone https://github.com/kcofoni/pynetro.git
cd pynetro

# Create a virtual environment
python -m venv .venv

# Activate the virtual environment
# On Linux/macOS:
source .venv/bin/activate

# On Windows:
# .venv\Scripts\activate

# Verify the environment is activated (prompt should show (.venv))
which python  # Should point to .venv/bin/python

3. Install Dependencies

# Install the project in development mode
pip install -e .

# Install development dependencies (tests, linting, etc.)
pip install -r requirements-dev.txt

4. Verify Installation

# Run unit tests to verify everything works
pytest tests/test_client.py -v

# Check linting
ruff check src/ tests/

🧪 Testing

Run tests using pytest commands:

5. Integration Tests Configuration (optional)

# Create an .env file with your Netro device serial numbers
cp .env.example .env
# Then edit .env with your actual values

# Generate reference files for development (contains real serial numbers, ignored by git)
python tests/generate_references.py

# Test integrations (requires internet connection and Netro devices)
pytest tests/test_integration.py -v -m integration

Security Note: Reference files are automatically ignored by git as they contain real device serial numbers. Template files with anonymized data are provided for understanding the API structure.

🔧 Common Troubleshooting

Virtual environment not activated

# Check that the environment is activated
which python  # Should point to .venv/bin/python
echo $VIRTUAL_ENV  # Should display the path to .venv

# If not activated:
source .venv/bin/activate  # Linux/macOS
# .venv\Scripts\activate   # Windows

Import errors during tests

# Reinstall the project in development mode
pip install -e .

Integration tests skipped

# Integration tests require environment variables
export NETRO_SENS_SERIAL="your_sensor_serial"
export NETRO_CTRL_SERIAL="your_controller_serial"

# Verify variables are set
echo $NETRO_SENS_SERIAL $NETRO_CTRL_SERIAL

Tests

The project has a comprehensive test suite with 14 tests (7 unit + 7 integration).

# Run all tests
pytest tests/ -v

# Unit tests only (always available)
pytest tests/test_client.py -v

# Integration tests (require environment variables)
pytest tests/test_integration.py -v -m integration

📚 Complete testing documentationtests/README.md

Security & Reference Files

For security reasons, files containing real device serial numbers are automatically ignored by git:

  • tests/reference_data/sensor_response.json
  • tests/reference_data/sprite_response.json

What's available for fresh clones:

  • ✅ Anonymized templates showing API structure (*_template.json)
  • ✅ Generation script to create real reference files when needed
  • ✅ All functionality works without these files - they're optional documentation

If you need the real reference files:

# Set your device serial numbers
export NETRO_SENS_SERIAL="your_sensor_serial" 
export NETRO_CTRL_SERIAL="your_controller_serial"

# Generate the files (will be ignored by git)
python tests/generate_references.py

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

pynetro-0.1.4.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

pynetro-0.1.4-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file pynetro-0.1.4.tar.gz.

File metadata

  • Download URL: pynetro-0.1.4.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for pynetro-0.1.4.tar.gz
Algorithm Hash digest
SHA256 146c96910bcd54bc0a0e33c9ec0b3a57a807458903de4a4d0aa9297ca3210a37
MD5 7ad2ff81e1044573679ce8f0d8736789
BLAKE2b-256 eda7aeeddb9dc2a60d3a904ad225f2f4639c7b390366c1b1d651178bac2c46d1

See more details on using hashes here.

File details

Details for the file pynetro-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pynetro-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for pynetro-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 98d7f7d504b49597cb52d5e218430fb0b5bd7b62f58499ad9a01836f3d33b57e
MD5 48ad6326ab89d8a2b596b4f7edaf4438
BLAKE2b-256 cb8308ae68ed256c7dc9c6714a7086297049473006a4d7c69527da91587a9e4c

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