Skip to main content

A python library to access GivEnergy inverters via Modbus TCP, with no dependency on the GivEnergy Cloud.

Project description

GivEnergy Modbus

pypi python GitHub branch status release workflow codecov PyPI - License Ruff

A python library to access GivEnergy inverters via Modbus TCP on a local network, with no dependency on the GivEnergy Cloud. Inspired by and originally built on pymodbus, it now provides its own asyncio-based framer, decoder and PDUs specific to the GivEnergy implementation.

⚠️ This project makes no representations as to its completeness or correctness. You use it at your own risk — if your inverter mysteriously explodes because you accidentally set the BOOMTIME register or you consume a MWh of electricity doing SOC calibration: you really are on your own. We make every effort to prevent you from shooting yourself in the foot, so as long as you use the client and its exposed methods, you should be perfectly safe.

Features

  • Reading all registers and decoding them into their representative datatypes
  • Writing data to holding registers that are deemed to be safe to set configuration on the inverter

How to use

The client is async. Use it inside an asyncio event loop; commands are plain functions that return request lists which you send via one_shot_command or execute:

import asyncio
from givenergy_modbus.client.client import Client
from givenergy_modbus.client import commands
from givenergy_modbus.model import TimeSlot
from givenergy_modbus.model.inverter import Model

async def main():
    client = Client(host="192.168.99.99", port=8899)
    await client.connect()

    # change configuration on the device:
    await client.one_shot_command(commands.set_charge_target(80))
    # set a charging slot from 00:30 to 04:30
    await client.one_shot_command(commands.set_charge_slot_1(TimeSlot.from_components(0, 30, 4, 30)))
    # set the inverter to charge from excess solar and discharge to meet demand
    await client.one_shot_command(commands.set_mode_dynamic())

    await client.refresh_plant(full_refresh=True)
    plant = client.plant

    assert plant.inverter_serial_number == 'SA1234G567'
    assert plant.inverter.model == Model.HYBRID
    assert plant.inverter.enable_charge_target
    assert plant.inverter.charge_slot_1 == TimeSlot.from_components(0, 30, 4, 30)
    assert plant.inverter.model_dump() == {
        'serial_number': 'SA1234G567',
        'device_type_code': '3001',
        'charge_slot_1': TimeSlot.from_components(0, 30, 4, 30),
        ...
    }
    assert plant.inverter.model_dump_json() == '{"serial_number": "SA1234G567", "device_type_code": "3001", ...'

    assert plant.batteries[0].serial_number == 'BG1234G567'
    assert plant.batteries[0].v_cell_01 == 3.117
    assert plant.batteries[0].model_dump() == {
        'bms_firmware_version': 3005,
        'cap_design': 160.0,
        ...
    }
    assert plant.batteries[0].model_dump_json() == '{"serial_number": "BG1234G567", "v_cell_01": 3.117, ...'

    await client.close()

asyncio.run(main())

Credits

This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.

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

givenergy_modbus-1.1.1.tar.gz (57.3 kB view details)

Uploaded Source

Built Distribution

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

givenergy_modbus-1.1.1-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file givenergy_modbus-1.1.1.tar.gz.

File metadata

  • Download URL: givenergy_modbus-1.1.1.tar.gz
  • Upload date:
  • Size: 57.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for givenergy_modbus-1.1.1.tar.gz
Algorithm Hash digest
SHA256 fe12d802e5b5a766089525c75a27c9dde0025c6c6a8a6d0680d8ee5f3ea15a62
MD5 1380b66687f429806447699911ba5218
BLAKE2b-256 c4932273bff8129519edf603ace2a92f2bebf6b550d319ef4d4e8f6af46052a9

See more details on using hashes here.

File details

Details for the file givenergy_modbus-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for givenergy_modbus-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 555e41308cebfde51929400cf9ec4d81932cb52baa62270d8d0d08f2c921ba97
MD5 2a6b35f887595d9ed0e3066f064e7f82
BLAKE2b-256 216907371acc33f27b172b37857e301a185ec2b982875e32c7f57ad667613472

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