Skip to main content

pymyenergi

An async Python library for myenergi API

This is a very early release, things are changing rapidly so use at your own risk!

[!IMPORTANT] This work is not officially supported by myenergi and functionality can stop working at any time without warning

Installation

The easiest method is to install using pip (pip/pip3):

pip install pymyenergi

Installing within a Python virtual environment is often a good idea:

python -m venv .venv
source .venv/bin/activate
pip install pymyenergi

To update to the latest version:

pip install pymyenergi -U

Setup will add a CLI under the name myenergicli. See below for usage.

CLI

A simple CLI is provided with this library.

If no username, password, app_email or app_password is supplied as input arguments, and no configuration file is found, you will be prompted for credentials.

Configuration file will be searched for in ./.myenergi.cfg and ~/.myenergi.cfg.

Example configuration file

[hub]
serial=12345678
password=your-password
app_email=myemail@email.com
app_password=your-app-password

CLI usage

usage: myenergi [-h] [-u USERNAME] [-p PASSWORD] [-e APP_EMAIL] [-a APP_PASSWORD] [-d] [-j] [--skip-oauth]
                {list,overview,zappi,eddi,harvi,libbi} ...

myenergi CLI.

positional arguments:
  {list,overview,zappi,eddi,harvi,libbi}
                        sub-command help
    list                list devices
    overview            show overview
    zappi               use zappi --help for available commands
    eddi                use eddi --help for available commands
    harvi               use harvi --help for available commands
    libbi               use libbi --help for available commands

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
  -p PASSWORD, --password PASSWORD
  -e APP_EMAIL, --app_email APP_EMAIL
  -a APP_PASSWORD, --app_password APP_PASSWORD
  -d, --debug
  -j, --json

Library usage

Install pymyenergi using pip (requires Python > 3.6)

Example library usage

import asyncio
from pymyenergi.connection import Connection
from pymyenergi.client import MyenergiClient
from sys import argv
import logging

logging.basicConfig()
logging.root.setLevel(logging.INFO)

user, password = argv

async def zappis() -> None:
    conn = Connection(user, password)
    client = MyenergiClient(conn)

    zappis = await client.getDevices('zappi')
    for zappi in zappis:
        print(f"Zappi {zappi.serial_number} charge mode {zappi.charge_mode}")

loop = asyncio.get_event_loop()
loop.run_until_complete(zappis())

Example library usage - Zappi

import asyncio
from pymyenergi.connection import Connection
from pymyenergi.zappi import Zappi
from sys import argv
import logging

logging.basicConfig()
logging.root.setLevel(logging.INFO)

user, password, zappi_serial = argv


async def get_data() -> None:
    conn = Connection(user, password)
    zappi = Zappi(conn, zappi_serial)
    await zappi.refresh()
    print(f"Zappi S/N {zappi.serial_number} version {zappi.firmware_version}")
    print(f"Status: {zappi.status} Plug status: {zappi.plug_status} Locked: {zappi.locked}")
    print(f"Priority: {zappi.priority}")
    print(f"Charge mode: {zappi.charge_mode} {zappi.num_phases} phase")
    print()
    print(f"Lock when plugged in   : {zappi.lock_when_pluggedin}")
    print(f"Lock when unplugged    : {zappi.lock_when_unplugged}")
    print(f"Charge when locked     : {zappi.charge_when_locked}")
    print(f"Charge session allowed : {zappi.charge_session_allowed}")
    print(f"Charge added: {zappi.charge_added}")
    print()
    print(f"CT 1 {zappi.ct1.name} {zappi.ct1.power}W")
    print(f"CT 2 {zappi.ct2.name} {zappi.ct2.power}W")
    print(f"CT 3 {zappi.ct3.name} {zappi.ct3.power}W")
    print(f"CT 4 {zappi.ct4.name} {zappi.ct4.power}W")
    print(f"CT 5 {zappi.ct5.name} {zappi.ct5.power}W")
    print(f"CT 6 {zappi.ct6.name} {zappi.ct6.power}W")
    print()
    print(f"Supply voltage: {zappi.supply_voltage}V frequency: {zappi.supply_frequency}Hz")
    print("Power:")
    print(f"  Grid      : {zappi.power_grid}W")
    print(f"  Generated : {zappi.power_generated}W")
    print()
    # print(f"      Boost start at {zappi.boost_start_hour}:{zappi.boost_start_minute} add {zappi.boost_amount}kWh")
    print(f"Smart Boost start at {zappi.smart_boost_start_hour}:{zappi.smart_boost_start_minute} add {zappi.smart_boost_amount}kWh")

loop = asyncio.get_event_loop()
loop.run_until_complete(get_data())

Libbi support

Currently supported features:

  • Reads a few values such as State of Charge, DCPV CT
  • Battery in and out energy
  • Gets and sets the current operating mode (normal/stopped/export)
  • Change priority of Libbi
  • Enable/Disable charging from the grid
  • Set charge target (in Wh)

CLI examples:

myenergi libbi show
myenergi libbi mode normal
myenergi libbi priority 1
myenergi libbi energy
myenergi libbi chargefromgrid false
myenergi libbi chargetarget 10200

Credits

twonk for documenting the unofficial API

Metadata

Release files for pymyenergi 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymyenergi 0.2.3
File Size Uploaded
pymyenergi-0.2.3.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymyenergi 0.2.3
File Interpreter ABI Platform
pymyenergi-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 45.7 kB

Release files / pymyenergi-0.2.3.tar.gz

Download URL pymyenergi-0.2.3.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8ae951595f75efdfbb0b0030bc35875d91934240c5fcffb4a5a0420ec5016d41
BLAKE2b-256 checksum
How to use checksums
fd24d80375c8318c51ea0d9b8f6be640a2cf3075b9c9ebc51c9561f85d82d419
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / pymyenergi-0.2.3-py3-none-any.whl

Download URL pymyenergi-0.2.3-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4514b51bfb520ecb8615702dc43a813819f99598f02c660bbffd145b702dd81
BLAKE2b-256 checksum
How to use checksums
27de1cf7ef970cea2399c604ef068f39df8343876e16ed9ee1e881fcd586d231
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page