Asynchronous Python client for MyLight Systems.
Project description
Python: MyLight Systems API Client
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
- Getting Started - Complete setup and usage examples
- Advanced Usage - Energy monitoring, automation, and health monitoring
- Error handling - Comprehensive error handling patterns
- Retry Patterns - Production-ready resilience strategies
API Reference
- Authentication - Login and token management
- User Profile - Get account information
- Device Management - List and identify devices
- Device States - Real-time monitoring
- Energy Measures - Total energy data
- Device Control - Switch devices on/off
Reference Guides
- Data Models - All data structures and fields
- Exception Handling - Error types and handling patterns
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mylightsystems-0.0.8.tar.gz.
File metadata
- Download URL: mylightsystems-0.0.8.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f53f83d12567a2472d956908f4c775706a1d1082a03566203beca22e9b60aeec
|
|
| MD5 |
a8f40af355ec38fc76b4ea25885231ba
|
|
| BLAKE2b-256 |
8a3da5657f69062941bd1aab5612a4b49ece34a4dc6fb837cf23144ec7bb4397
|
Provenance
The following attestation bundles were made for mylightsystems-0.0.8.tar.gz:
Publisher:
release.yaml on acesyde/python-mylight-systems-api-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mylightsystems-0.0.8.tar.gz -
Subject digest:
f53f83d12567a2472d956908f4c775706a1d1082a03566203beca22e9b60aeec - Sigstore transparency entry: 373090353
- Sigstore integration time:
-
Permalink:
acesyde/python-mylight-systems-api-client@5a8b452ab048c100b1fd78d2b1e06b462e25145f -
Branch / Tag:
refs/tags/v0.0.8 - Owner: https://github.com/acesyde
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5a8b452ab048c100b1fd78d2b1e06b462e25145f -
Trigger Event:
release
-
Statement type:
File details
Details for the file mylightsystems-0.0.8-py3-none-any.whl.
File metadata
- Download URL: mylightsystems-0.0.8-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e52922f92fcaa71b7c077ebb2e87859a77cac4702a3c9d2d802f8f2459c3b2e5
|
|
| MD5 |
ee9b6b3911d6f237fb240471ed2fda91
|
|
| BLAKE2b-256 |
c7de00096b4e75f4a5b144cc8cd744cfa00d2fed8ac6277ff35d2394ed312649
|
Provenance
The following attestation bundles were made for mylightsystems-0.0.8-py3-none-any.whl:
Publisher:
release.yaml on acesyde/python-mylight-systems-api-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mylightsystems-0.0.8-py3-none-any.whl -
Subject digest:
e52922f92fcaa71b7c077ebb2e87859a77cac4702a3c9d2d802f8f2459c3b2e5 - Sigstore transparency entry: 373090380
- Sigstore integration time:
-
Permalink:
acesyde/python-mylight-systems-api-client@5a8b452ab048c100b1fd78d2b1e06b462e25145f -
Branch / Tag:
refs/tags/v0.0.8 - Owner: https://github.com/acesyde
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5a8b452ab048c100b1fd78d2b1e06b462e25145f -
Trigger Event:
release
-
Statement type: