Skip to content

Commit

Permalink
Merge pull request #34 from KyeRussell/docs-updates
Browse files Browse the repository at this point in the history
README improvements
  • Loading branch information
CJNE authored Jun 3, 2024
2 parents 9edfa62 + dedf709 commit 3711d67
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,52 @@
# pymyenergi

An async python library for myenergi API
An async Python library for myenergi API

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

_NOTE:_ This work is not officially supported by myenergi and functionality can stop working at any time without warning
> [!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 pip3/pip (venv is also a good idea)
The easiest method is to install using pip (`pip`/`pip3`):

```
```bash
pip install pymyenergi
```

to update to the latest version
Installing within a [Python virtual environment](https://docs.python.org/3/library/venv.html) is often a good idea:

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

To update to the latest version:

```bash
pip install pymyenergi -U
```

Setup will add a cli under the name myenergicli, see below for usage
Setup will add a CLI under the name `myenergicli`. See below for usage.

## CLI

A simple cli is provided with this library.
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.
Configuration file will be searched for in ./.myenergi.cfg and ~/.myenergi.cfg
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

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

### CLI usage
Expand Down Expand Up @@ -69,11 +79,11 @@ optional arguments:

## Library usage

Install pymyenergi using pip (requires python > 3.6)
Install pymyenergi using pip (requires Python > 3.6)

### Example client usage
### Example library usage

```
```python
import asyncio
from pymyenergi.connection import Connection
from pymyenergi.client import MyenergiClient
Expand All @@ -83,8 +93,7 @@ import logging
logging.basicConfig()
logging.root.setLevel(logging.INFO)

user = argv[1]
password = argv[2]
user, password = argv

async def zappis() -> None:
conn = Connection(user, password)
Expand All @@ -98,9 +107,9 @@ loop = asyncio.get_event_loop()
loop.run_until_complete(zappis())
```

### Example client usage - Zappi
### Example library usage - Zappi

```
```python
import asyncio
from pymyenergi.connection import Connection
from pymyenergi.zappi import Zappi
Expand All @@ -110,9 +119,7 @@ import logging
logging.basicConfig()
logging.root.setLevel(logging.INFO)

user = argv[1]
password = argv[2]
zappi_serial = argv[3]
user, password, zappi_serial = argv


async def get_data() -> None:
Expand All @@ -123,25 +130,25 @@ async def get_data() -> None:
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()
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()
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()
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()
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")

Expand All @@ -150,6 +157,7 @@ loop.run_until_complete(get_data())
```

## Libbi support

Currently supported features:

- Reads a few values such as State of Charge, DCPV CT
Expand All @@ -159,8 +167,9 @@ Currently supported features:
- Enable/Disable charging from the grid
- Set charge target (in Wh)

cli examples:
```
CLI examples:

```bash
myenergi libbi show
myenergi libbi mode normal
myenergi libbi priority 1
Expand All @@ -169,8 +178,6 @@ myenergi libbi chargefromgrid false
myenergi libbi chargetarget 10200
```



## Credits

[twonk](https://github.com/twonk/MyEnergi-App-Api) for documenting the unofficial API

0 comments on commit 3711d67

Please sign in to comment.