Skip to main content

Python library for SystemNexa2 device integration

Project description

python-sn2

Python library for SystemNexa2 device integration.

This package provides a client library for communicating with SystemNexa2 smart home devices over WebSocket and REST APIs. It supports device discovery, real-time state updates, brightness control, and configuration management.

Supported Devices

  • Switches: WBR-01
  • Plugs: WPR-01, WPO-01
  • Lights: WBD-01, WPD-01

Key Features

  • Asynchronous communication via WebSocket and REST
  • Real-time device state updates
  • Brightness control for dimmable devices
  • Device settings management (433MHz, LED, DIY mode, etc.)
  • Automatic reconnection handling
  • Error handling and logging

Installation

pip install python-sn2

Usage

"""Example usage of the python-sn2 library."""

import asyncio
import logging

from sn2.device import Device

logger = logging.getLogger(__name__)


async def main() -> None:
    """Demonstrate device usage."""
    # Create a device instance
    device = Device(host="192.168.1.144")

    # Initialize the device
    await device.initialize()

    # Connect to the device
    await device.connect()

    # Set brightness
    await device.set_brightness(0.75)

    # Get device information
    info = await device.get_info()
    if info:
        logger.info("Device: %s", info.information.name)

    # Disconnect
    await device.disconnect()


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())

Development

This project uses uv for dependency management.

Setup the development environment:

./scripts/test-setup

Or manually:

# Create virtual environment and install package
uv venv
uv pip install -e ".[dev]"

Run tests:

uv run pytest

Run linting:

uv run ruff check .
uv run ruff format .

Release Process

This project uses automated versioning and releases. To create a new release:

Automated (Recommended)

# Bump patch version (0.1.0 -> 0.1.1)
./scripts/release.sh patch

# Bump minor version (0.1.0 -> 0.2.0)
./scripts/release.sh minor

# Bump major version (0.1.0 -> 1.0.0)
./scripts/release.sh major

This will:

  1. Run tests and linting
  2. Bump version in pyproject.toml and sn2/__init__.py
  3. Create a git commit and tag
  4. Push to GitHub
  5. Trigger GitHub Actions to build and publish to PyPI

Manual

# Install bump-my-version
pip install bump-my-version

# Bump version
bump-my-version bump patch  # or minor/major

# Push changes and tags
git push origin main --tags

The GitHub Actions workflow will automatically:

  • Create a GitHub release with release notes
  • Build the package
  • Publish to PyPI (via Trusted Publishing)

License

MIT License

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

python_sn2-0.2.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

python_sn2-0.2.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file python_sn2-0.2.2.tar.gz.

File metadata

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

File hashes

Hashes for python_sn2-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b929961fd6c0f1050d23ef624078a47b7f2983c4af2e8f745fbf37590a5c14f2
MD5 0686c93284aba9df024706512fd7a917
BLAKE2b-256 632326e7cb960f4a07249ed2af6c5944e19ebb78f54e9f2f7857f954254a439a

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_sn2-0.2.2.tar.gz:

Publisher: release.yml on konsulten/python-sn2

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

File details

Details for the file python_sn2-0.2.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for python_sn2-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 23cc1170770ad7633ce8b731ccfe7ee35039bdf2488a0181e9492794523a0247
MD5 c3355553261801f711a77c5be171e326
BLAKE2b-256 9145a48a64ebb7f7b040b53b7bbb2a705277c9bebf3b07f1993002ae7db6a917

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_sn2-0.2.2-py3-none-any.whl:

Publisher: release.yml on konsulten/python-sn2

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