Skip to content

Commit

Permalink
Merge pull request #17 from faanskit/dev
Browse files Browse the repository at this point in the history
Updated to a more comprehensice Readme.md and bumped the version
  • Loading branch information
faanskit authored Dec 27, 2023
2 parents cbb7b15 + 9c30abc commit 34da3ae
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 25 deletions.
103 changes: 81 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,103 @@
# pyCheckwatt

Python package for communicating with [CheckWatt](https://checkwatt.se/) [EnergyInBalance](https://energyinbalance.se/) targeted for [Home Assistant](https://home-assistant.io) integration.
Python package for communicating with [CheckWatt](https://checkwatt.se/) [EnergyInBalance](https://energyinbalance.se/) targeted for [Home Assistant](https://home-assistant.io) integrations and other use-cases.

## Warning
This library is provided as-is, is not supported or sanctioned by CheckWatt.
This library is provided **as-is** and is not supported or approved by CheckWatt. CheckWatt can implement breaking changes at any time that renders this module useless. The module may not be updated promptly, or not at all if the changes are not possible to reverse engineer.

## Status
The library is **expermental** and does nothing but to pull some basic info from [EnergyInBalance](https://energyinbalance.se/).
The library is **experimental** and pulls basic info from [EnergyInBalance](https://energyinbalance.se/).
Use with care as it loads the servers of CheckWatt

## Example
In the examples folder exist en example file that make use of this library.
The following example will login to [EnergyInBalance](https://energyinbalance.se/) and reteive basic information.

### Using the example
Create a `.env` file that looks like this and contain your credentials to [EnergyInBalance](https://energyinbalance.se/).
```
CHECKWATT_USERNAME=<username>
CHECKWATT_PASSWORD=<password>
Create a file called `example.py` that looks like this:
```python
"""Example file to test pyCheckwatt"""
from pycheckwatt import CheckwattManager
EIB_USERNAME="eib_username"
EIB_PASSWORD="eib_password"

async def main():
"""Test function for pyCheckwatt."""
async with CheckwattManager(EIB_USERNAME, EIB_PASSWORD) as cw_instance:
try:
# Login to EnergyInBalance
if await cw_instance.login():
# Fetch customer detail
await cw_instance.get_customer_details()
print("System\n======")
print(cw_instance.registred_owner)
print(cw_instance.battery_make_and_model)
print("\nFCR-D\n=====")
print(f"FCR-D State: {cw_instance.fcrd_state}")
print(f"FCR-D Percentage: {cw_instance.fcrd_percentage}")
print(f"FCR-D Date: {cw_instance.fcrd_timestamp}")

except Exception as e:
print(f"An error occurred: {e}")

if __name__ == "__main__":

import asyncio

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())
```

Create a virtual environment and install pyCheckwatt:
```bash
$ python -m venv venv
$ ./venv/Scripts/activate
$ pip install pycheckwatt
```
Run a simple test:
```
> python main.py
$ python example.py
```

Watch the output:
```
Customer Details
================
Firstname Lastname (Adress Zip City)
System
======
Inverter Brand Model
Battery Brand Model (12.3kW, 12.0kWh)
Energy supplier via Dso (BLE City)
Firstname Lastname (Adress Zip City)
Solax power T30 12.0 (12.3kW, 12.0kWh)
Logbook Entries
===============
#9999 Hugo 2023-01-01
20230101-1100-CET - Hugo - test:pass, timestamp:pass, lan-router:pass, 4G:pass, simnumber:pass
20230101-1120-CET - Silas - unpacked
FCR-D
=====
FCR-D State: ACTIVATED
FCR-D Percentage: 99,0/2,9/97,7 %
FCR-D Date: 2023-12-20 00:11:45
```

## Comprehensive Example
A comprehensive example can can found in the [examples](https://github.com/faanskit/pyCheckwatt/tree/master/examples) folder. This example use additional modules, such as `dotenv` and `argparse`.
These modules needs to be installed before the `main.py` is executed.

```bash
$ python -m venv venv
$ ./venv/Scripts/activate
$ pip install pycheckwatt python-dotenv argparse
```

Run the comprehensice test:
```
$ python main.py
```
# Acknowledgements
This module was developed as a team effort by the following contributors.

- [@faanskit](https://github.com/faanskit) : Developer
- [@flopp999](https://github.com/flopp999) : Developer
- [@angoyd](https://github.com/angoyd) : CI/CD

This integration could not have been made without the excellent work done by the Home Assistant team.

If you like what have been done here and want to help I would recommend that you firstly look into supporting Home Assistant.

You can do this by purchasing some swag from their [store](https://home-assistant-store.creator-spring.com/) or paying for a Nabu Casa subscription. None of this could happen without them.

# Licenses
The integration is provided as-is without any warranties and published under [The MIT License](https://opensource.org/license/mit/).
1 change: 1 addition & 0 deletions examples/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os

from dotenv import load_dotenv

from pycheckwatt import CheckwattManager

load_dotenv()
Expand Down
2 changes: 1 addition & 1 deletion pycheckwatt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from __future__ import annotations

import base64
from datetime import datetime, timedelta
import json
import logging
import re
from datetime import datetime, timedelta

from aiohttp import ClientError, ClientResponseError, ClientSession
from dateutil.relativedelta import relativedelta
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pycheckwatt"
version = "0.1.2"
version = "0.1.3"
description = "Read data from CheckWatts EnergyInBalance WEB API"
authors = ["Marcus Karlsson <[email protected]>", "Anders Yderborg <[email protected]>", "Daniel Nilsson <[email protected]>"]
license = "MIT License"
Expand All @@ -19,7 +19,7 @@ include = [

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
aiohttp = "^3.8.1"
aiohttp = "^3.9.1"
python-dateutil = "^2.8.2"

[build-system]
Expand Down

0 comments on commit 34da3ae

Please sign in to comment.