tesla-powerwall


Nametesla-powerwall JSON
Version 0.5.2 PyPI version JSON
download
home_page
SummaryA simple API for accessing the Tesla Powerwall over your local network
upload_time2024-02-24 13:59:29
maintainer
docs_urlNone
author
requires_python
licenseMIT License Copyright (c) 2024 Jrester Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords api tesla powerwall tesla_powerwall
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Licence](https://img.shields.io/github/license/jrester/tesla_powerwall?style=for-the-badge)
![PyPI - Downloads](https://img.shields.io/pypi/dm/tesla_powerwall?color=blue&style=for-the-badge)
![PyPI](https://img.shields.io/pypi/v/tesla_powerwall?style=for-the-badge)

Python Tesla Powerwall API for consuming a local endpoint.
> Note: This is not an official API provided by Tesla and this project is not affilated with Tesla in any way.

Powerwall Software versions from 1.47.0 to 1.50.1 as well as 20.40 to 22.9.2 are tested, but others will probably work too.

# Table of Contents <!-- omit in TOC -->

- [Installation](#installation)
- [Limitations](#limitations)
    - [Adjusting Backup Reserve Percentage](#adjusting-backup-reserve-percentage)
- [Usage](#usage)
    - [Setup](#setup)
    - [Authentication](#authentication)
    - [General](#general)
        - [Errors](#errors)
        - [Response](#response)
    - [Battery level](#battery-level)
    - [Capacity](#capacity)
    - [Battery Packs](#battery-packs)
    - [Powerwall Status](#powerwall-status)
    - [Sitemaster](#sitemaster)
    - [Siteinfo](#siteinfo)
    - [Meters](#meters)
        - [Aggregates](#aggregates)
        - [Current power supply/draw](#current-power-supplydraw)
        - [Energy exported/imported](#energy-exportedimported)
        - [Details](#details)
    - [Device Type](#device-type)
    - [Grid Status](#grid-status)
    - [Operation mode](#operation-mode)
    - [Powerwalls Serial Numbers](#powerwalls-serial-numbers)
    - [Gateway DIN](#gateway-din)
    - [VIN](#vin)
    - [Off-grid status](#off-grid-status-set-island-mode)
- [Development](#development)

## Installation

Install the library via pip:

```bash
$ pip install tesla_powerwall
```

## Limitations

### Adjusting Backup Reserve Percentage

Currently it is not possible to control the Backup Percentage, because you need to be logged in as installer, which requires physical switch toggle. There is an ongoing discussion about a possible solution [here](https://github.com/vloschiavo/powerwall2/issues/55).
However, if you believe there exists a solution, feel free to open an issue detailing the solution.

## Usage

For a basic Overview of the functionality of this library you can take a look at `examples/example.py`. You can run the example, by cloning the repo and executing in your shell:

```bash
$ export POWERWALL_IP=<ip of your Powerwall>
$ export POWERWALL_PASSWORD=<your password>
$ tox -e example
```

### Setup

```python
from tesla_powerwall import Powerwall

# Create a simple powerwall object by providing the IP
powerwall = Powerwall("<ip of your Powerwall>")
#=> <Powerwall ...>

# Create a powerwall object with more options
powerwall = Powerwall(
    endpoint="<ip of your powerwall>",
    # Configure timeout; default is 10
    timeout=10,
    # Provide a requests.Session or None. If None is provided, a Session will be created.
    http_session=None,
    # Whether to verify the SSL certificate or not
    verify_ssl=False
)
#=> <Powerwall ...>
```

> Note: By default the API client does not verify the SSL certificate of the Powerwall. If you want to verify the SSL certificate you can set `verify_ssl` to `True`.

### Authentication

Since version 20.49.0 authentication is required for all methods. For that reason you must call `login` before making a request to the API.
When you perform a request without being authenticated, an `AccessDeniedError` will be thrown.

To login you can either use `login` or `login_as`. `login` logs you in as `User.CUSTOMER` whereas with `login_as` you can choose a different user:

```python
from tesla_powerwall import User

# Login as customer without email
# The default value for the email is ""
await powerwall.login("<password>")
#=> <LoginResponse ...>

# Login as customer with email
await powerwall.login("<password>", "<email>")
#=> <LoginResponse ...>

# Login with different user
await powerwall.login_as(User.INSTALLER, "<password>", "<email>")
#=> <LoginResponse ...>

# Check if we are logged in
# This method only checks wether a cookie with a Bearer token exists
# It does not verify whether this token is valid
powerwall.is_authenticated()
#=> True

# Logout
await powerwall.logout()
powerwall.is_authenticated()
#=> False
```

### General

The API object directly maps the REST endpoints with a python method in the form of `<verb>_<path>`. So if you need the raw json responses you can use the API object. It can be either created manually or retrived from an existing `Powerwall`:

```python
from tesla_powerwall import API

# Manually create API object
api = API('https://<ip>/')
# Perform get on 'system_status/soe'
await api.get_system_status_soe()
#=> {'percentage': 97.59281925744594}

# From existing powerwall
api = powerwall.get_api()
await api.get_system_status_soe()
```

The `Powerwall` objet provides a wrapper around the API and exposes common methods.

### Battery level

Get charge in percent:

```python
await powerwall.get_charge()
#=> 97.59281925744594 (%)
```

Get charge in watt:

```python
await powerwall.get_energy()
#=> 14807 (Wh)
```

### Capacity

Get the capacity of your powerwall in watt:

```python
await powerwall.get_capacity()
#=> 28078 (Wh)
```

### Battery Packs

Get information about the battery packs that are installed:

Assuming that the battery is operational, you can retrive a number of values about each battery:
```python
batteries = await powerwall.get_batteries()
#=> [<Battery ...>, <Battery ...>]
batteries[0].part_number
#=> "XXX-G"
batteries[0].serial_number
#=> "TGXXX"
batteries[0].energy_remaining
#=> 7378 (Wh)
batteries[0].capacity
#=> 14031 (Wh)
batteries[0].energy_charged
#=> 5525740 (Wh)
batteries[0].energy_discharged
#=> 4659550 (Wh)
batteries[0].wobble_detected
#=> False
batteries[0].p_out
#=> 260
batteries[0].q_out
#=> -1080
batteries[0].v_out
#=> 245.70
batteries[0].f_out
#=> 49.953
batteries[0].i_out
#=> -7.4
batteries[0].grid_state
#=> GridState.COMPLIANT
batteries[0].disabled_reasons
#=> []

```

If a battery is disabled it's `grid_state` will be `GridState.DISABLED` and some values will be `None`. The variable `disabled_reasons` might contain more information why the battery is disabled:
```python
...
batteries[1].grid_state
#=> GridState.DISABLED
batteries[1].disabled_reasons
#=> ["DisabledExcessiveVoltageDrop"]
batteries[1].p_out
#=> None
batteries[1].energy_charged
#=> None
```

### Powerwall Status

```python
status = await powerwall.get_status()
#=> <PowerwallStatus ...>
status.version
#=> '1.49.0'
status.up_time_seconds
#=> datetime.timedelta(days=13, seconds=63287, microseconds=146455)
status.start_time
#=> datetime.datetime(2020, 9, 23, 23, 31, 16, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800)))
status.device_type
#=> DeviceType.GW2
```

### Sitemaster

```python
sm = await powerwall.get_sitemaster()
#=> <SiteMaster ...>
sm.status
#=> StatusUp
sm.running
#=> true
sm.connected_to_tesla
#=> true
```

The sitemaster can be started and stopped using `run()` and `stop()`

### Siteinfo

```python
info = await powerwall.get_site_info()
#=> <SiteInfo ...>
info.site_name
#=> 'Tesla Home'
info.country
#=> 'Germany'
info.nominal_system_energy
#=> 13.5 (kWh)
info.timezone
#=> 'Europe/Berlin'
```

### Meters

#### Aggregates

```python
from tesla_powerwall import MeterType

meters = await powerwall.get_meters()
#=> <MetersAggregates ...>

# access meter, but may return None when meter is not available
meters.get_meter(MeterType.SOLAR)
#=> <Meter ...>

# access meter, but may raise MeterNotAvailableError when the meter is not available at your powerwall (e.g. no solar panels installed)
meters.solar
#=> <MeterResponse ...>

# get all available meters at the current powerwall
meters.meters.keys()
#=> [<MeterType.SITE: 'site'>, <MeterType.BATTERY: 'battery'>, <MeterType.LOAD: 'load'>, <MeterType.SOLAR: 'solar'>]
```

Available meters are: `solar`, `site`, `load`, `battery`, `generator`, and `busway`. Some of those meters might not be available based on the installation and raise MeterNotAvailableError when accessed.

#### Current power supply/draw

`Meter` provides different methods for checking current power supply/draw:

```python
meters = await powerwall.get_meters()
meters.solar.get_power()
#=> 0.4 (kW)
meters.solar.instant_power
#=> 409.941801071167 (W)
meters.solar.is_drawing_from()
#=> True
meters.load.is_sending_to()
#=> True
meters.battery.is_active()
#=> False

# Different precision settings might return different results
meters.battery.is_active(precision=5)
#=> True
```

> Note: For MeterType.LOAD `is_drawing_from` **always** returns `False` because it cannot be drawn from `load`.

#### Energy exported/imported

Get energy exported/imported in watt-hours (Wh) with `energy_exported` and `energy_imported`. For the values in kilowatt-hours (kWh) use `get_energy_exported` and `get_energy_imported`:

```python
meters.battery.energy_exported
#=> 6394100 (Wh)
meters.battery.get_energy_exported()
#=> 6394.1 (kWh)
meters.battery.energy_imported
#=> 7576570 (Wh)
meters.battery.get_energy_imported()
#=> 7576.6 (kWh)
```

### Details

You can receive more detailed information about the meters `site` and `solar`:

```python
meter_details = await powerwall.get_meter_site() # or get_meter_solar() for the solar meter
#=> <MeterDetailsResponse ...>
readings = meter_details.readings
#=> <MeterDetailsReadings ...>
readings.real_power_a # same for real_power_b and real_power_c
#=> 619.13532458
readings.i_a_current # same for i_b_current and i_c_current
#=> 3.02
readings.v_l1n # smae for v_l2n and v_l3n
#=> 235.82
readings.instant_power
#=> -18.000023458
readings.is_sending()
```

As `MeterDetailsReadings` inherits from `MeterResponse` (which is used in `MetersAggratesResponse`) it exposes the same data and methods.

> For the meters battery and grid no additional details are provided, therefore no methods exist for those meters

### Device Type

```python
await powerwall.get_device_type()
#=> <DeviceType.GW1: 'hec'>
```

### Grid Status

Get current grid status.

```python
await powerwall.get_grid_status()
#=> <GridStatus.Connected: 'SystemGridConnected'>
await powerwall.is_grid_services_active()
#=> False
```

### Operation mode

```python
await powerwall.get_operation_mode()
#=> <OperationMode.SELF_CONSUMPTION: ...>
await powerwall.get_backup_reserve_percentage()
#=> 5.000019999999999 (%)
```

### Powerwalls Serial Numbers

```python
await serials = powerwall.get_serial_numbers()
#=> ["...", "...", ...]
```

### Gateway DIN

```python
await din = powerwall.get_gateway_din()
#=> 4159645-02-A--TGXXX
```

### VIN

```python
await vin = powerwall.get_vin()
```

### Off-grid status (Set Island mode)

Take your powerwall on- and off-grid similar to the "Take off-grid" button in the Tesla app.

#### Set powerwall to off-grid (Islanded)

```python
await powerwall.set_island_mode(IslandMode.OFFGRID)
```

#### Set powerwall to off-grid (Connected)

```python
await powerwall.set_island_mode(IslandMode.ONGRID)
```

# Development

## pre-commit

This project uses pre-commit to run linters, formatters and type checking. You can easily run those checks locally:

```sh
# Install the pre-commit hooks
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
```

Now those checks will be execute on every `git commit`. You can also execute all checks manually with `pre-commit run --all-files`.

## Building

```sh
$ python -m build
```

## Testing

The tests are split in unit and integration tests.
The unit tests are self-contained and can simply be run locally by executing `tox -e unit`, whereas the integration test, run against a real powerwall.

### Unit-Tests

To run unit tests use tox:

```sh
$ tox -e unit
```

### Integration-Tests

To execute the integration tests you need to first provide some information about your powerwall:

```sh
$ export POWERWALL_IP=<ip of your powerwall>
$ export POWERWALL_PASSWORD=<password for your powerwall>
$ tox -e integration
```

> The integration tests might take your powerwall off grid and bring it back online. Before running the tests, make sure that you know what you are doing!

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "tesla-powerwall",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "api,tesla,powerwall,tesla_powerwall",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/5e/ab/6039491270ce1533a3d6d631bd76e47857e28f424171dfdcc753e0a43207/tesla_powerwall-0.5.2.tar.gz",
    "platform": null,
    "description": "![Licence](https://img.shields.io/github/license/jrester/tesla_powerwall?style=for-the-badge)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/tesla_powerwall?color=blue&style=for-the-badge)\n![PyPI](https://img.shields.io/pypi/v/tesla_powerwall?style=for-the-badge)\n\nPython Tesla Powerwall API for consuming a local endpoint.\n> Note: This is not an official API provided by Tesla and this project is not affilated with Tesla in any way.\n\nPowerwall Software versions from 1.47.0 to 1.50.1 as well as 20.40 to 22.9.2 are tested, but others will probably work too.\n\n# Table of Contents <!-- omit in TOC -->\n\n- [Installation](#installation)\n- [Limitations](#limitations)\n    - [Adjusting Backup Reserve Percentage](#adjusting-backup-reserve-percentage)\n- [Usage](#usage)\n    - [Setup](#setup)\n    - [Authentication](#authentication)\n    - [General](#general)\n        - [Errors](#errors)\n        - [Response](#response)\n    - [Battery level](#battery-level)\n    - [Capacity](#capacity)\n    - [Battery Packs](#battery-packs)\n    - [Powerwall Status](#powerwall-status)\n    - [Sitemaster](#sitemaster)\n    - [Siteinfo](#siteinfo)\n    - [Meters](#meters)\n        - [Aggregates](#aggregates)\n        - [Current power supply/draw](#current-power-supplydraw)\n        - [Energy exported/imported](#energy-exportedimported)\n        - [Details](#details)\n    - [Device Type](#device-type)\n    - [Grid Status](#grid-status)\n    - [Operation mode](#operation-mode)\n    - [Powerwalls Serial Numbers](#powerwalls-serial-numbers)\n    - [Gateway DIN](#gateway-din)\n    - [VIN](#vin)\n    - [Off-grid status](#off-grid-status-set-island-mode)\n- [Development](#development)\n\n## Installation\n\nInstall the library via pip:\n\n```bash\n$ pip install tesla_powerwall\n```\n\n## Limitations\n\n### Adjusting Backup Reserve Percentage\n\nCurrently it is not possible to control the Backup Percentage, because you need to be logged in as installer, which requires physical switch toggle. There is an ongoing discussion about a possible solution [here](https://github.com/vloschiavo/powerwall2/issues/55).\nHowever, if you believe there exists a solution, feel free to open an issue detailing the solution.\n\n## Usage\n\nFor a basic Overview of the functionality of this library you can take a look at `examples/example.py`. You can run the example, by cloning the repo and executing in your shell:\n\n```bash\n$ export POWERWALL_IP=<ip of your Powerwall>\n$ export POWERWALL_PASSWORD=<your password>\n$ tox -e example\n```\n\n### Setup\n\n```python\nfrom tesla_powerwall import Powerwall\n\n# Create a simple powerwall object by providing the IP\npowerwall = Powerwall(\"<ip of your Powerwall>\")\n#=> <Powerwall ...>\n\n# Create a powerwall object with more options\npowerwall = Powerwall(\n    endpoint=\"<ip of your powerwall>\",\n    # Configure timeout; default is 10\n    timeout=10,\n    # Provide a requests.Session or None. If None is provided, a Session will be created.\n    http_session=None,\n    # Whether to verify the SSL certificate or not\n    verify_ssl=False\n)\n#=> <Powerwall ...>\n```\n\n> Note: By default the API client does not verify the SSL certificate of the Powerwall. If you want to verify the SSL certificate you can set `verify_ssl` to `True`.\n\n### Authentication\n\nSince version 20.49.0 authentication is required for all methods. For that reason you must call `login` before making a request to the API.\nWhen you perform a request without being authenticated, an `AccessDeniedError` will be thrown.\n\nTo login you can either use `login` or `login_as`. `login` logs you in as `User.CUSTOMER` whereas with `login_as` you can choose a different user:\n\n```python\nfrom tesla_powerwall import User\n\n# Login as customer without email\n# The default value for the email is \"\"\nawait powerwall.login(\"<password>\")\n#=> <LoginResponse ...>\n\n# Login as customer with email\nawait powerwall.login(\"<password>\", \"<email>\")\n#=> <LoginResponse ...>\n\n# Login with different user\nawait powerwall.login_as(User.INSTALLER, \"<password>\", \"<email>\")\n#=> <LoginResponse ...>\n\n# Check if we are logged in\n# This method only checks wether a cookie with a Bearer token exists\n# It does not verify whether this token is valid\npowerwall.is_authenticated()\n#=> True\n\n# Logout\nawait powerwall.logout()\npowerwall.is_authenticated()\n#=> False\n```\n\n### General\n\nThe API object directly maps the REST endpoints with a python method in the form of `<verb>_<path>`. So if you need the raw json responses you can use the API object. It can be either created manually or retrived from an existing `Powerwall`:\n\n```python\nfrom tesla_powerwall import API\n\n# Manually create API object\napi = API('https://<ip>/')\n# Perform get on 'system_status/soe'\nawait api.get_system_status_soe()\n#=> {'percentage': 97.59281925744594}\n\n# From existing powerwall\napi = powerwall.get_api()\nawait api.get_system_status_soe()\n```\n\nThe `Powerwall` objet provides a wrapper around the API and exposes common methods.\n\n### Battery level\n\nGet charge in percent:\n\n```python\nawait powerwall.get_charge()\n#=> 97.59281925744594 (%)\n```\n\nGet charge in watt:\n\n```python\nawait powerwall.get_energy()\n#=> 14807 (Wh)\n```\n\n### Capacity\n\nGet the capacity of your powerwall in watt:\n\n```python\nawait powerwall.get_capacity()\n#=> 28078 (Wh)\n```\n\n### Battery Packs\n\nGet information about the battery packs that are installed:\n\nAssuming that the battery is operational, you can retrive a number of values about each battery:\n```python\nbatteries = await powerwall.get_batteries()\n#=> [<Battery ...>, <Battery ...>]\nbatteries[0].part_number\n#=> \"XXX-G\"\nbatteries[0].serial_number\n#=> \"TGXXX\"\nbatteries[0].energy_remaining\n#=> 7378 (Wh)\nbatteries[0].capacity\n#=> 14031 (Wh)\nbatteries[0].energy_charged\n#=> 5525740 (Wh)\nbatteries[0].energy_discharged\n#=> 4659550 (Wh)\nbatteries[0].wobble_detected\n#=> False\nbatteries[0].p_out\n#=> 260\nbatteries[0].q_out\n#=> -1080\nbatteries[0].v_out\n#=> 245.70\nbatteries[0].f_out\n#=> 49.953\nbatteries[0].i_out\n#=> -7.4\nbatteries[0].grid_state\n#=> GridState.COMPLIANT\nbatteries[0].disabled_reasons\n#=> []\n\n```\n\nIf a battery is disabled it's `grid_state` will be `GridState.DISABLED` and some values will be `None`. The variable `disabled_reasons` might contain more information why the battery is disabled:\n```python\n...\nbatteries[1].grid_state\n#=> GridState.DISABLED\nbatteries[1].disabled_reasons\n#=> [\"DisabledExcessiveVoltageDrop\"]\nbatteries[1].p_out\n#=> None\nbatteries[1].energy_charged\n#=> None\n```\n\n### Powerwall Status\n\n```python\nstatus = await powerwall.get_status()\n#=> <PowerwallStatus ...>\nstatus.version\n#=> '1.49.0'\nstatus.up_time_seconds\n#=> datetime.timedelta(days=13, seconds=63287, microseconds=146455)\nstatus.start_time\n#=> datetime.datetime(2020, 9, 23, 23, 31, 16, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800)))\nstatus.device_type\n#=> DeviceType.GW2\n```\n\n### Sitemaster\n\n```python\nsm = await powerwall.get_sitemaster()\n#=> <SiteMaster ...>\nsm.status\n#=> StatusUp\nsm.running\n#=> true\nsm.connected_to_tesla\n#=> true\n```\n\nThe sitemaster can be started and stopped using `run()` and `stop()`\n\n### Siteinfo\n\n```python\ninfo = await powerwall.get_site_info()\n#=> <SiteInfo ...>\ninfo.site_name\n#=> 'Tesla Home'\ninfo.country\n#=> 'Germany'\ninfo.nominal_system_energy\n#=> 13.5 (kWh)\ninfo.timezone\n#=> 'Europe/Berlin'\n```\n\n### Meters\n\n#### Aggregates\n\n```python\nfrom tesla_powerwall import MeterType\n\nmeters = await powerwall.get_meters()\n#=> <MetersAggregates ...>\n\n# access meter, but may return None when meter is not available\nmeters.get_meter(MeterType.SOLAR)\n#=> <Meter ...>\n\n# access meter, but may raise MeterNotAvailableError when the meter is not available at your powerwall (e.g. no solar panels installed)\nmeters.solar\n#=> <MeterResponse ...>\n\n# get all available meters at the current powerwall\nmeters.meters.keys()\n#=> [<MeterType.SITE: 'site'>, <MeterType.BATTERY: 'battery'>, <MeterType.LOAD: 'load'>, <MeterType.SOLAR: 'solar'>]\n```\n\nAvailable meters are: `solar`, `site`, `load`, `battery`, `generator`, and `busway`. Some of those meters might not be available based on the installation and raise MeterNotAvailableError when accessed.\n\n#### Current power supply/draw\n\n`Meter` provides different methods for checking current power supply/draw:\n\n```python\nmeters = await powerwall.get_meters()\nmeters.solar.get_power()\n#=> 0.4 (kW)\nmeters.solar.instant_power\n#=> 409.941801071167 (W)\nmeters.solar.is_drawing_from()\n#=> True\nmeters.load.is_sending_to()\n#=> True\nmeters.battery.is_active()\n#=> False\n\n# Different precision settings might return different results\nmeters.battery.is_active(precision=5)\n#=> True\n```\n\n> Note: For MeterType.LOAD `is_drawing_from` **always** returns `False` because it cannot be drawn from `load`.\n\n#### Energy exported/imported\n\nGet energy exported/imported in watt-hours (Wh) with `energy_exported` and `energy_imported`. For the values in kilowatt-hours (kWh) use `get_energy_exported` and `get_energy_imported`:\n\n```python\nmeters.battery.energy_exported\n#=> 6394100 (Wh)\nmeters.battery.get_energy_exported()\n#=> 6394.1 (kWh)\nmeters.battery.energy_imported\n#=> 7576570 (Wh)\nmeters.battery.get_energy_imported()\n#=> 7576.6 (kWh)\n```\n\n### Details\n\nYou can receive more detailed information about the meters `site` and `solar`:\n\n```python\nmeter_details = await powerwall.get_meter_site() # or get_meter_solar() for the solar meter\n#=> <MeterDetailsResponse ...>\nreadings = meter_details.readings\n#=> <MeterDetailsReadings ...>\nreadings.real_power_a # same for real_power_b and real_power_c\n#=> 619.13532458\nreadings.i_a_current # same for i_b_current and i_c_current\n#=> 3.02\nreadings.v_l1n # smae for v_l2n and v_l3n\n#=> 235.82\nreadings.instant_power\n#=> -18.000023458\nreadings.is_sending()\n```\n\nAs `MeterDetailsReadings` inherits from `MeterResponse` (which is used in `MetersAggratesResponse`) it exposes the same data and methods.\n\n> For the meters battery and grid no additional details are provided, therefore no methods exist for those meters\n\n### Device Type\n\n```python\nawait powerwall.get_device_type()\n#=> <DeviceType.GW1: 'hec'>\n```\n\n### Grid Status\n\nGet current grid status.\n\n```python\nawait powerwall.get_grid_status()\n#=> <GridStatus.Connected: 'SystemGridConnected'>\nawait powerwall.is_grid_services_active()\n#=> False\n```\n\n### Operation mode\n\n```python\nawait powerwall.get_operation_mode()\n#=> <OperationMode.SELF_CONSUMPTION: ...>\nawait powerwall.get_backup_reserve_percentage()\n#=> 5.000019999999999 (%)\n```\n\n### Powerwalls Serial Numbers\n\n```python\nawait serials = powerwall.get_serial_numbers()\n#=> [\"...\", \"...\", ...]\n```\n\n### Gateway DIN\n\n```python\nawait din = powerwall.get_gateway_din()\n#=> 4159645-02-A--TGXXX\n```\n\n### VIN\n\n```python\nawait vin = powerwall.get_vin()\n```\n\n### Off-grid status (Set Island mode)\n\nTake your powerwall on- and off-grid similar to the \"Take off-grid\" button in the Tesla app.\n\n#### Set powerwall to off-grid (Islanded)\n\n```python\nawait powerwall.set_island_mode(IslandMode.OFFGRID)\n```\n\n#### Set powerwall to off-grid (Connected)\n\n```python\nawait powerwall.set_island_mode(IslandMode.ONGRID)\n```\n\n# Development\n\n## pre-commit\n\nThis project uses pre-commit to run linters, formatters and type checking. You can easily run those checks locally:\n\n```sh\n# Install the pre-commit hooks\n$ pre-commit install\npre-commit installed at .git/hooks/pre-commit\n```\n\nNow those checks will be execute on every `git commit`. You can also execute all checks manually with `pre-commit run --all-files`.\n\n## Building\n\n```sh\n$ python -m build\n```\n\n## Testing\n\nThe tests are split in unit and integration tests.\nThe unit tests are self-contained and can simply be run locally by executing `tox -e unit`, whereas the integration test, run against a real powerwall.\n\n### Unit-Tests\n\nTo run unit tests use tox:\n\n```sh\n$ tox -e unit\n```\n\n### Integration-Tests\n\nTo execute the integration tests you need to first provide some information about your powerwall:\n\n```sh\n$ export POWERWALL_IP=<ip of your powerwall>\n$ export POWERWALL_PASSWORD=<password for your powerwall>\n$ tox -e integration\n```\n\n> The integration tests might take your powerwall off grid and bring it back online. Before running the tests, make sure that you know what you are doing!\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Jrester  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A simple API for accessing the Tesla Powerwall over your local network",
    "version": "0.5.2",
    "project_urls": {
        "Homepage": "https://github.com/jrester/tesla_powerwall"
    },
    "split_keywords": [
        "api",
        "tesla",
        "powerwall",
        "tesla_powerwall"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5eab6039491270ce1533a3d6d631bd76e47857e28f424171dfdcc753e0a43207",
                "md5": "286e83be33342bcdc3ff4d1ef682686a",
                "sha256": "a932d16fe410dcaa98a56e55f42e9ad658c54bb56d1dcc6b5ef50205a3d77695"
            },
            "downloads": -1,
            "filename": "tesla_powerwall-0.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "286e83be33342bcdc3ff4d1ef682686a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19363,
            "upload_time": "2024-02-24T13:59:29",
            "upload_time_iso_8601": "2024-02-24T13:59:29.062201Z",
            "url": "https://files.pythonhosted.org/packages/5e/ab/6039491270ce1533a3d6d631bd76e47857e28f424171dfdcc753e0a43207/tesla_powerwall-0.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-24 13:59:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jrester",
    "github_project": "tesla_powerwall",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "tesla-powerwall"
}
        
Elapsed time: 0.39199s