pycheckwatt


Namepycheckwatt JSON
Version 0.2.6 PyPI version JSON
download
home_page
SummaryRead data from CheckWatts EnergyInBalance WEB API
upload_time2024-03-11 18:14:33
maintainer
docs_urlNone
authorMarcus Karlsson
requires_python>=3.10,<3.13
licenseMIT
keywords checkwatt eib battery
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyCheckwatt

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** 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 **experimental** and pulls basic info from [EnergyInBalance](https://energyinbalance.se/).
Use with care as it loads the servers of CheckWatt

## Example
The following example will login to [EnergyInBalance](https://energyinbalance.se/) and retrieve information. 

Create a file called `example.py` that looks like this:
```python
"""Example-module for pyCheckwatt."""

import argparse
import json

from pycheckwatt import CheckwattManager


async def main(show_details=False):
    """Fetch username and password from environment variables."""
    username = "EIB username"
    password = "EiB password"

    # Create the async class
    async with CheckwattManager(username, password) as check_watt_instance:
        try:
            # Login to EnergyInBalance and check kill switch
            if await check_watt_instance.login():
                # Fetch customer detail
                await check_watt_instance.get_customer_details()

                # Do a sample
                print("Customer Details\n================")
                print(check_watt_instance.registered_owner)

                print("\nSystem\n======")
                print("Charge peak AC", check_watt_instance.battery_peak_data[0])
                print("Charge peak DC", check_watt_instance.battery_peak_data[1])
                print("Discharge peak AC", check_watt_instance.battery_peak_data[2])
                print("Discharge peak DC", check_watt_instance.battery_peak_data[3])
                print(check_watt_instance.battery_make_and_model)
                print(check_watt_instance.electricity_provider)

                print("\nLogbook Entries\n===============")
                for entry in check_watt_instance.logbook_entries:
                    print(entry)

                print("\nComments\n========")
                print(check_watt_instance.comments)

                await check_watt_instance.get_fcrd_today_net_revenue()
                await check_watt_instance.get_fcrd_year_net_revenue()
                await check_watt_instance.get_fcrd_month_net_revenue()
                print("\nFCR-D\n=====")
                print(f"FCR-D State: {check_watt_instance.fcrd_state}")
                print(f"FCR-D Discharge: {check_watt_instance.fcrd_percentage_up}% of {check_watt_instance.fcrd_power}kW")
                print(f"FCR-D Charge: {check_watt_instance.fcrd_percentage_down}% of {check_watt_instance.fcrd_power}kW")
                print(f"FCR-D Response: {check_watt_instance.fcrd_percentage_response} seconds")
                print(f"FCR-D Date: {check_watt_instance.fcrd_timestamp}")

                print("\nRevenue\n=======")
                print(
                    "{:<24}  {:>6}  {:>0}".format(
                        "Daily average:",
                        int(check_watt_instance.fcrd_daily_net_average),
                        "kr",
                    )
                )
                print(
                    "{:<24}  {:>6}  {:>0}".format(
                        "Month estimate:",
                        int(check_watt_instance.fcrd_month_net_estimate),
                        "kr",
                    )
                )
                print(
                    "{:<24}  {:>6}  {:>0}".format(
                        "Month revenue:",
                        int(check_watt_instance.fcrd_month_net_revenue),
                        "kr",
                    )
                )
                print(
                    "{:<24}  {:>6}  {:>0}".format(
                        "Year revenue:",
                        int(check_watt_instance.fcrd_year_net_revenue),
                        "kr",
                    )
                )
                print(
                    "{:<24}  {:>6}  {:>0}".format(
                        "Today revenue:",
                        int(check_watt_instance.fcrd_today_net_revenue),
                        "kr",
                    )
                )


                await check_watt_instance.get_ems_settings()
                print("\nEMS Setting\n===========")
                print(check_watt_instance.ems_settings)

                await check_watt_instance.get_power_data()
                print("\nEnergy\n======")
                print(f"Solar: {check_watt_instance.total_solar_energy/1000} kWh")
                print(f"Charging: {check_watt_instance.total_charging_energy/1000} kWh")
                print(
                    f"Discharging: {check_watt_instance.total_discharging_energy/1000} kWh"  # noqa: E501
                )
                print(f"Import: {check_watt_instance.total_import_energy/1000} kWh")
                print(f"Export: {check_watt_instance.total_export_energy/1000} kWh")

                if show_details:
                    print("\nCustomer Details\n===============")
                    print(json.dumps(check_watt_instance.customer_details, indent=2))

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


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Checkwatt Information")
    parser.add_argument(
        "-d", "--details", action="store_true", help="Show system details"
    )
    args = parser.parse_args()

    import asyncio

    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    loop.run_until_complete(main(args.details))

```

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

Watch the output:
```
Customer Details
================
First name Surname(Street number postal code city)

System
======
Charge peak AC 15.0
Charge peak DC 15.0
Discharge peak AC 15.0
Discharge peak DC 15.0
Growatt APX 30 kWh/Could not get any information about your battery
Bixia AB via E.ON Energidistribution AB

Logbook Entries
===============
[ FCR-D ACTIVATED ] email@email.com --11111-- 97,5/0,6/96,0 % (15 kW) 2022-01-28 00:03:42 API-BACKEND
[ FCR-D DEACTIVATE ]  DOWN 50,19 Hz 46,0 %  (15 kW) 2022-01-22 12:00:25 API-BACKEND
[ FCR-D ACTIVATED ] email@email.com --11111-- 98,2/0,8/97,0 % (15 kW) 2022-01-18 00:02:28 API-BACKEND
[ FCR-D DEACTIVATE ]  UP 49,84 Hz 0,0 %  (15 kW) 2022-01-09 23:09:03 API-BACKEND

Comments
========
Kund har utökat till 20 kWh / 20 kW.

System
======
Charge peak AC 15.0
Charge peak DC 15.0
Discharge peak AC 15.0
Discharge peak DC 15.0
Could not get any information about your battery
Bixia AB via E.ON Energidistribution AB

Revenue
=======
Daily average:                48  kr
Month estimate:             1504  kr
Month revenue:               145  kr
Year revenue:               4008  kr
Today revenue:                39  kr

EMS Setting
===========
Currently optimized (CO)

Energy
======
Solar: 779.365 kWh
Charging: 719.286 kWh
Discharging: 185.699 kWh
Import: 1684.686 kWh
Export: 668.539 kWh

```

# 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/).


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pycheckwatt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<3.13",
    "maintainer_email": "",
    "keywords": "checkwatt,eib,battery",
    "author": "Marcus Karlsson",
    "author_email": "macke.karlsson@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bf/9c/ebcc9e5a0ea17490dfeb152a8d34a97a0c8913ee238955637ed964fc8dc0/pycheckwatt-0.2.6.tar.gz",
    "platform": null,
    "description": "# pyCheckwatt\n\nPython 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.\n\n## Warning\nThis 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.\n\n## Status\nThe library is **experimental** and pulls basic info from [EnergyInBalance](https://energyinbalance.se/).\nUse with care as it loads the servers of CheckWatt\n\n## Example\nThe following example will login to [EnergyInBalance](https://energyinbalance.se/) and retrieve information. \n\nCreate a file called `example.py` that looks like this:\n```python\n\"\"\"Example-module for pyCheckwatt.\"\"\"\n\nimport argparse\nimport json\n\nfrom pycheckwatt import CheckwattManager\n\n\nasync def main(show_details=False):\n    \"\"\"Fetch username and password from environment variables.\"\"\"\n    username = \"EIB username\"\n    password = \"EiB password\"\n\n    # Create the async class\n    async with CheckwattManager(username, password) as check_watt_instance:\n        try:\n            # Login to EnergyInBalance and check kill switch\n            if await check_watt_instance.login():\n                # Fetch customer detail\n                await check_watt_instance.get_customer_details()\n\n                # Do a sample\n                print(\"Customer Details\\n================\")\n                print(check_watt_instance.registered_owner)\n\n                print(\"\\nSystem\\n======\")\n                print(\"Charge peak AC\", check_watt_instance.battery_peak_data[0])\n                print(\"Charge peak DC\", check_watt_instance.battery_peak_data[1])\n                print(\"Discharge peak AC\", check_watt_instance.battery_peak_data[2])\n                print(\"Discharge peak DC\", check_watt_instance.battery_peak_data[3])\n                print(check_watt_instance.battery_make_and_model)\n                print(check_watt_instance.electricity_provider)\n\n                print(\"\\nLogbook Entries\\n===============\")\n                for entry in check_watt_instance.logbook_entries:\n                    print(entry)\n\n                print(\"\\nComments\\n========\")\n                print(check_watt_instance.comments)\n\n                await check_watt_instance.get_fcrd_today_net_revenue()\n                await check_watt_instance.get_fcrd_year_net_revenue()\n                await check_watt_instance.get_fcrd_month_net_revenue()\n                print(\"\\nFCR-D\\n=====\")\n                print(f\"FCR-D State: {check_watt_instance.fcrd_state}\")\n                print(f\"FCR-D Discharge: {check_watt_instance.fcrd_percentage_up}% of {check_watt_instance.fcrd_power}kW\")\n                print(f\"FCR-D Charge: {check_watt_instance.fcrd_percentage_down}% of {check_watt_instance.fcrd_power}kW\")\n                print(f\"FCR-D Response: {check_watt_instance.fcrd_percentage_response} seconds\")\n                print(f\"FCR-D Date: {check_watt_instance.fcrd_timestamp}\")\n\n                print(\"\\nRevenue\\n=======\")\n                print(\n                    \"{:<24}  {:>6}  {:>0}\".format(\n                        \"Daily average:\",\n                        int(check_watt_instance.fcrd_daily_net_average),\n                        \"kr\",\n                    )\n                )\n                print(\n                    \"{:<24}  {:>6}  {:>0}\".format(\n                        \"Month estimate:\",\n                        int(check_watt_instance.fcrd_month_net_estimate),\n                        \"kr\",\n                    )\n                )\n                print(\n                    \"{:<24}  {:>6}  {:>0}\".format(\n                        \"Month revenue:\",\n                        int(check_watt_instance.fcrd_month_net_revenue),\n                        \"kr\",\n                    )\n                )\n                print(\n                    \"{:<24}  {:>6}  {:>0}\".format(\n                        \"Year revenue:\",\n                        int(check_watt_instance.fcrd_year_net_revenue),\n                        \"kr\",\n                    )\n                )\n                print(\n                    \"{:<24}  {:>6}  {:>0}\".format(\n                        \"Today revenue:\",\n                        int(check_watt_instance.fcrd_today_net_revenue),\n                        \"kr\",\n                    )\n                )\n\n\n                await check_watt_instance.get_ems_settings()\n                print(\"\\nEMS Setting\\n===========\")\n                print(check_watt_instance.ems_settings)\n\n                await check_watt_instance.get_power_data()\n                print(\"\\nEnergy\\n======\")\n                print(f\"Solar: {check_watt_instance.total_solar_energy/1000} kWh\")\n                print(f\"Charging: {check_watt_instance.total_charging_energy/1000} kWh\")\n                print(\n                    f\"Discharging: {check_watt_instance.total_discharging_energy/1000} kWh\"  # noqa: E501\n                )\n                print(f\"Import: {check_watt_instance.total_import_energy/1000} kWh\")\n                print(f\"Export: {check_watt_instance.total_export_energy/1000} kWh\")\n\n                if show_details:\n                    print(\"\\nCustomer Details\\n===============\")\n                    print(json.dumps(check_watt_instance.customer_details, indent=2))\n\n        except Exception as e:\n            print(f\"An error occurred: {e}\")\n\n\nif __name__ == \"__main__\":\n    parser = argparse.ArgumentParser(description=\"Checkwatt Information\")\n    parser.add_argument(\n        \"-d\", \"--details\", action=\"store_true\", help=\"Show system details\"\n    )\n    args = parser.parse_args()\n\n    import asyncio\n\n    loop = asyncio.new_event_loop()\n    asyncio.set_event_loop(loop)\n    loop.run_until_complete(main(args.details))\n\n```\n\nCreate a virtual environment and install pyCheckwatt:\n```bash\n$ python -m venv venv\n$ ./venv/Scripts/activate\n$ pip install pycheckwatt\n```\nRun the example code:\n```\n$ python example.py\n```\n\nWatch the output:\n```\nCustomer Details\n================\nFirst name Surname(Street number postal code city)\n\nSystem\n======\nCharge peak AC 15.0\nCharge peak DC 15.0\nDischarge peak AC 15.0\nDischarge peak DC 15.0\nGrowatt APX 30 kWh/Could not get any information about your battery\nBixia AB via E.ON Energidistribution AB\n\nLogbook Entries\n===============\n[ FCR-D ACTIVATED ] email@email.com --11111-- 97,5/0,6/96,0 % (15 kW) 2022-01-28 00:03:42 API-BACKEND\n[ FCR-D DEACTIVATE ]  DOWN 50,19 Hz 46,0 %  (15 kW) 2022-01-22 12:00:25 API-BACKEND\n[ FCR-D ACTIVATED ] email@email.com --11111-- 98,2/0,8/97,0 % (15 kW) 2022-01-18 00:02:28 API-BACKEND\n[ FCR-D DEACTIVATE ]  UP 49,84 Hz 0,0 %  (15 kW) 2022-01-09 23:09:03 API-BACKEND\n\nComments\n========\nKund har ut\u00f6kat till 20 kWh / 20 kW.\n\nSystem\n======\nCharge peak AC 15.0\nCharge peak DC 15.0\nDischarge peak AC 15.0\nDischarge peak DC 15.0\nCould not get any information about your battery\nBixia AB via E.ON Energidistribution AB\n\nRevenue\n=======\nDaily average:                48  kr\nMonth estimate:             1504  kr\nMonth revenue:               145  kr\nYear revenue:               4008  kr\nToday revenue:                39  kr\n\nEMS Setting\n===========\nCurrently optimized (CO)\n\nEnergy\n======\nSolar: 779.365 kWh\nCharging: 719.286 kWh\nDischarging: 185.699 kWh\nImport: 1684.686 kWh\nExport: 668.539 kWh\n\n```\n\n# Acknowledgements\nThis module was developed as a team effort by the following contributors.\n\n- [@faanskit](https://github.com/faanskit) : Developer\n- [@flopp999](https://github.com/flopp999) : Developer\n- [@angoyd](https://github.com/angoyd) : CI/CD\n\nThis integration could not have been made without the excellent work done by the Home Assistant team.\n\nIf you like what have been done here and want to help I would recommend that you firstly look into supporting Home Assistant.\n\nYou 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.\n\n# Licenses\nThe integration is provided as-is without any warranties and published under [The MIT License](https://opensource.org/license/mit/).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Read data from CheckWatts EnergyInBalance WEB API",
    "version": "0.2.6",
    "project_urls": null,
    "split_keywords": [
        "checkwatt",
        "eib",
        "battery"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e02de21b5e1956c3082760dbd7b5af9da6ba711affa153f0b22cf16b34d35f6",
                "md5": "ff9deda7954d704a7c7f68e1b6f81630",
                "sha256": "7669216e41dd4a2fde837f410a58fe175b63ca4c28cf137830efdf4e2d06d69e"
            },
            "downloads": -1,
            "filename": "pycheckwatt-0.2.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ff9deda7954d704a7c7f68e1b6f81630",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<3.13",
            "size": 15222,
            "upload_time": "2024-03-11T18:14:31",
            "upload_time_iso_8601": "2024-03-11T18:14:31.729619Z",
            "url": "https://files.pythonhosted.org/packages/1e/02/de21b5e1956c3082760dbd7b5af9da6ba711affa153f0b22cf16b34d35f6/pycheckwatt-0.2.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf9cebcc9e5a0ea17490dfeb152a8d34a97a0c8913ee238955637ed964fc8dc0",
                "md5": "f8fa6caea96936ac20a0622707d0c3e0",
                "sha256": "8138ccacb922ba0948882c0349e268d80ad5713cea6c24381650e60eaebacf22"
            },
            "downloads": -1,
            "filename": "pycheckwatt-0.2.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f8fa6caea96936ac20a0622707d0c3e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<3.13",
            "size": 13979,
            "upload_time": "2024-03-11T18:14:33",
            "upload_time_iso_8601": "2024-03-11T18:14:33.363625Z",
            "url": "https://files.pythonhosted.org/packages/bf/9c/ebcc9e5a0ea17490dfeb152a8d34a97a0c8913ee238955637ed964fc8dc0/pycheckwatt-0.2.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-11 18:14:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pycheckwatt"
}
        
Elapsed time: 0.20028s