Asynchronous UDP client for Marstek energy storage systems
Project description
py-marstek
Python client for Marstek energy storage systems. Provides asynchronous UDP helpers to discover devices and query status information.
Features
- UDP broadcast discovery of Marstek devices
- Helpers to query ES mode, battery statistics, and PV status
- Complete device status retrieval with
get_device_status()method - Data parsing utilities for ES mode and PV status responses
- Simple command builder utilities
- Optional support for multi-interface broadcast via
psutil
Installation
pip install py-marstek
Usage
Basic Usage
import asyncio
from pymarstek import MarstekUDPClient, get_es_mode
async def main():
client = MarstekUDPClient()
await client.async_setup()
devices = await client.discover_devices()
if not devices:
print("No devices found")
return
device_ip = devices[0]["ip"]
response = await client.send_request(get_es_mode(0), device_ip, 30000)
print(response)
await client.async_cleanup()
asyncio.run(main())
Get Complete Device Status
import asyncio
from pymarstek import MarstekUDPClient
async def main():
client = MarstekUDPClient()
await client.async_setup()
# Get complete device status (battery + PV data)
device_status = await client.get_device_status(
device_ip="192.168.1.100",
port=30000,
include_pv=True, # Include PV status
delay_between_requests=2.0 # Delay between ES and PV requests
)
print(f"Battery SOC: {device_status['battery_soc']}%")
print(f"Battery Power: {device_status['battery_power']}W")
print(f"Device Mode: {device_status['device_mode']}")
print(f"PV1 Power: {device_status['pv1_power']}W")
await client.async_cleanup()
asyncio.run(main())
Using Data Parsers
from pymarstek import (
MarstekUDPClient,
get_es_mode,
get_pv_status,
parse_es_mode_response,
parse_pv_status_response,
merge_device_status,
)
# Parse individual responses
es_response = await client.send_request(get_es_mode(0), device_ip, 30000)
es_data = parse_es_mode_response(es_response)
pv_response = await client.send_request(get_pv_status(0), device_ip, 30000)
pv_data = parse_pv_status_response(pv_response)
# Merge into complete status
complete_status = merge_device_status(es_data, pv_data, device_ip=device_ip)
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_marstek-0.2.0.tar.gz
(6.6 kB
view details)
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 py_marstek-0.2.0.tar.gz.
File metadata
- Download URL: py_marstek-0.2.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28089c38eac3417389111e8e7bf7a9b9ca2227ff3e2244012b8e6b0dc554c54c
|
|
| MD5 |
cf318af12b3407b2ed9c0f89afbaac32
|
|
| BLAKE2b-256 |
78561d9810367274e8ec1798212f5bb4443a99fc8dd78fed147593ac44fd5adc
|
File details
Details for the file py_marstek-0.2.0-py3-none-any.whl.
File metadata
- Download URL: py_marstek-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1b21991c0a54415b928272d97a235783f05b54e8e68c3094cf9f0d7aa52adb1
|
|
| MD5 |
e2c0146f6b26cd8ebfe401b5dbd2a6c9
|
|
| BLAKE2b-256 |
e044932b6cd995dbf52ad0713c4b85406505e776d0e8b2f810eb6f3c9c26a4ce
|