Skip to main content

Asynchronous Python client for MyLight Systems.

Project description

Python: MyLight Systems API Client

GitHub Release Python Versions Project Stage Project Maintenance License

Build Status Code Coverage

Asynchronous Python client for the MyLight Systems API, enabling programmatic control and monitoring of MyLight Systems solar energy and home automation devices.

Features

๐Ÿ”‹ Device Management - Control and monitor solar panels, batteries, relays, and sensors โšก Real-time Data - Get live power consumption, production, and device states ๐Ÿ  Home Automation - Switch devices on/off and automate energy management ๐Ÿ“Š Energy Monitoring - Track total energy production, consumption, and efficiency metrics ๐Ÿ” Secure Authentication - Token-based API authentication with error handling ๐Ÿš€ Async/Await - Built for modern Python with full async support

Installation

Install from PyPI:

pip install mylightsystems

Quick Start

import asyncio
from mylightsystems.client import MyLightSystemsApiClient

async def main():
    async with MyLightSystemsApiClient() as client:
        # Authenticate
        auth = await client.auth("your_email@example.com", "your_password")

        # Get user profile
        profile = await client.get_profile(auth.token)
        print(f"User: {profile.id} in {profile.city}, {profile.country}")

        # Get all devices
        devices = await client.get_devices(auth.token)
        print(f"Found {len(devices)} devices")

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

API Overview

The client provides methods to interact with all major MyLight Systems endpoints:

Method Description Documentation
auth(email, password) Authenticate and get access token ๐Ÿ“– Auth
get_profile(token) Get user profile information ๐Ÿ“– Profile
get_devices(token) List all connected devices ๐Ÿ“– Devices
get_states(token) Get real-time device states and sensor data ๐Ÿ“– States
get_measures_total(token, device_id) Get total energy measures for a device ๐Ÿ“– Measures
switch(token, device_id, state) Control device on/off state ๐Ÿ“– Switch

Device Types

The library supports all MyLight Systems device types:

  • ๐Ÿ  Master Device (mst) - Main control unit
  • ๐Ÿ”‹ Battery Device (bat) - Energy storage systems
  • ๐Ÿ”Œ Relay Device (sw) - Controllable switches and outlets
  • ๐Ÿ“Š Counter Device (cmp) - Energy measurement devices
  • ๐Ÿ“ˆ Composite Counter (gmd) - Multi-phase energy meters
  • ๐Ÿ’ป Virtual Device (vrt) - Software-defined devices
  • ๐ŸŒ Ethernet Device (eth) - Network-connected devices

Each device type has specific properties and capabilities. See the Device Models documentation for complete details.

Documentation

๐Ÿ“š Complete API Documentation - Comprehensive guide with examples and advanced usage patterns

Quick Links

API Reference

Reference Guides

Use Cases

Perfect for building:

๐Ÿ  Home Energy Management - Real-time monitoring dashboards and automated energy optimization ๐Ÿ”Œ IoT Integration - Home Assistant components, OpenHAB bindings, Node-RED flows ๐Ÿ“Š Energy Analytics - Historical analysis, solar forecasting, cost optimization ๐Ÿค– Smart Automation - Intelligent device control based on production and consumption

See the complete documentation for detailed examples and implementation patterns.

Requirements

  • Python 3.8+
  • aiohttp
  • Modern async/await support

Contributing

We welcome contributions! This project uses modern Python development tools:

  • mise for tool management
  • uv for dependency management
  • ruff for linting and formatting
  • pre-commit for automated checks

Development Setup

# Install mise for tool management
curl https://mise.run | sh

# Set up the project
mise install
mise run project:setup

Development Commands

# Run all checks and tests
mise run precommit:run

# Run tests only
mise run project:tests

# Run linting
mise run project:lint

# Fix linting issues
mise run project:lint-fix

See our Contributing Guidelines for detailed information.

Authors & Contributors

Created and maintained by Pierre-Emmanuel Mercier.

For a full list of contributors, see the contributor's page.

License

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


MyLight Systems is a trademark of MyLight Systems SAS. This project is an unofficial client library and is not affiliated with or endorsed by MyLight Systems SAS.

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

mylightsystems-0.0.9.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

mylightsystems-0.0.9-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file mylightsystems-0.0.9.tar.gz.

File metadata

  • Download URL: mylightsystems-0.0.9.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for mylightsystems-0.0.9.tar.gz
Algorithm Hash digest
SHA256 9ca8e0d0d75bdc9fe19a6730a2ddef0ec576859f8613444e9bd1e17a6167d709
MD5 02cf7fd62a33aad53be8af5750826461
BLAKE2b-256 255396679065d2fc45e3398718da590203271eda3e4d5f385f38af9f3a7d6a23

See more details on using hashes here.

Provenance

The following attestation bundles were made for mylightsystems-0.0.9.tar.gz:

Publisher: release.yaml on acesyde/python-mylight-systems-api-client

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

File details

Details for the file mylightsystems-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: mylightsystems-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for mylightsystems-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 45e2d91988ea17a1b8b05807807767c676f99302292ff2620e5fafd7f7ff9281
MD5 1829dda7c7c6856d4d9b8e4cca59f941
BLAKE2b-256 d7f98d21286f15cb5f57822289f8d1192ab06a3aff96a610ed3601e4fb3a55bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for mylightsystems-0.0.9-py3-none-any.whl:

Publisher: release.yaml on acesyde/python-mylight-systems-api-client

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