pax_global_header 0000666 0000000 0000000 00000000064 14677302234 0014522 g ustar 00root root 0000000 0000000 52 comment=c53baccc9e8045326ff55964bc9280857bcc0cba
sunweg-3.1.0/ 0000775 0000000 0000000 00000000000 14677302234 0013033 5 ustar 00root root 0000000 0000000 sunweg-3.1.0/.github/ 0000775 0000000 0000000 00000000000 14677302234 0014373 5 ustar 00root root 0000000 0000000 sunweg-3.1.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14677302234 0016430 5 ustar 00root root 0000000 0000000 sunweg-3.1.0/.github/workflows/python-build.yml 0000664 0000000 0000000 00000002516 14677302234 0021575 0 ustar 00root root 0000000 0000000 name: Python build
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov genbadge[all]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --output-file ./reports/flake8/flake8stats.txt
- name: Test with pytest
run: |
pytest --cov=sunweg --cov-report html --cov-report xml --junitxml=reports/junit/junit.xml
mv htmlcov reports/coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
sunweg-3.1.0/.github/workflows/python-publish.yml 0000664 0000000 0000000 00000005462 14677302234 0022147 0 ustar 00root root 0000000 0000000 # This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov genbadge[all]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --output-file ./reports/flake8/flake8stats.txt
- name: Test with pytest
run: |
pytest --cov=sunweg --cov-report html --cov-report xml --junitxml=reports/junit/junit.xml
mv htmlcov reports/coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Generate badges
if: github.event_name != 'pull_request'
run: |
genbadge tests -o reports/tests.svg
genbadge coverage -i coverage.xml -o reports/coverage.svg
genbadge flake8 -i reports/flake8/flake8stats.txt -o reports/flake8.svg
- name: Publish badges report to badges branch
uses: JamesIves/github-pages-deploy-action@v4
if: github.event_name != 'pull_request'
with:
branch: badges
folder: reports
token: ${{ secrets.SUNWEG_GITHUB_PAT }}
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
sunweg-3.1.0/.gitignore 0000664 0000000 0000000 00000003420 14677302234 0015022 0 ustar 00root root 0000000 0000000 # Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
reports/
sunweg-3.1.0/.vscode/ 0000775 0000000 0000000 00000000000 14677302234 0014374 5 ustar 00root root 0000000 0000000 sunweg-3.1.0/.vscode/extensions.json 0000664 0000000 0000000 00000000227 14677302234 0017467 0 ustar 00root root 0000000 0000000 {
"recommendations": [
"esbenp.prettier-vscode",
"ms-python.python",
"github.vscode-pull-request-github",
"charliermarsh.ruff"
]
}
sunweg-3.1.0/.vscode/launch.json 0000664 0000000 0000000 00000000731 14677302234 0016542 0 ustar 00root root 0000000 0000000 {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
} sunweg-3.1.0/.vscode/settings.json 0000664 0000000 0000000 00000002424 14677302234 0017131 0 ustar 00root root 0000000 0000000 {
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"python.formatting.provider": "black",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"python.linting.mypyEnabled": true,
"cSpell.ignoreWords": [
"Acumulada",
"Acumulado",
"Atualizacao",
"Corrente",
"Gerada",
"Hoje",
"Inversor",
"Potencia",
"SUNWEG",
"Tensao",
"alarme",
"autenticacao",
"carbono",
"descricao",
"economia",
"energia",
"energiaacumuladanumber",
"fatorpotencia",
"franqueado",
"frequencia",
"getpaineloperacao",
"idusina",
"integrador",
"inversores",
"mppt",
"mppts",
"nomemppt",
"planos",
"potenciaativa",
"procurar",
"reduz",
"rtype",
"senha",
"situacao",
"stringmppt",
"temperatura",
"tensaoca",
"usinas",
"usuario",
"rokam"
],
"python.linting.mypyArgs": [
"--follow-imports=silent",
"--ignore-missing-imports",
"--show-column-numbers",
"--no-pretty",
"--install-types"
],
"python.testing.unittestEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--max-complexity=10",
"--max-line-length=127"
],
}
sunweg-3.1.0/.vscode/tasks.json 0000664 0000000 0000000 00000001043 14677302234 0016412 0 ustar 00root root 0000000 0000000 {
"version": "2.0.0",
"tasks": [
{
"label": "Code Coverage",
"detail": "Generate code coverage report.",
"type": "shell",
"command": "pytest ./tests/ --cov=sunweg --cov-report term-missing --durations-min=1 --durations=0",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
} sunweg-3.1.0/LICENSE 0000664 0000000 0000000 00000002073 14677302234 0014042 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2023 Lucas Mindêllo de Andrade
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.
sunweg-3.1.0/README.md 0000664 0000000 0000000 00000002773 14677302234 0014323 0 ustar 00root root 0000000 0000000 # SunWeg
[](https://github.com/rokam/sunweg/actions/workflows/python-build.yml)



Python lib for WEG solar energy platform, [SunWEG.net](https://sunweg.net/)
## Usage
### Retrieve token
You need to use devtools from your browser to retrieve the token. In most of them, you can open devtools by pressing F12.
Inside the network tab, you need to check the preserve logs and then do a login.
You can find the token in the request header of various XHR requests, for example:

It will be available in the X-Auth-Token-Update header.
### Code sample
``` python
from sunweg.api import APIHelper
api = APIHelper(token='your token here')
plants = api.listPlants()
for plant in plants:
print(plant)
for inverter in plant.inverters:
print(inverter)
for phase in inverter.phases:
print(phase)
for mppt in inverter.mppts:
print(mppt)
for string in mppt.strings:
print(string)
```
## Documentation
Check the [DOCs](https://github.com/rokam/sunweg/blob/main/docs/index.md) for API documentation.
## Contribute
Feel free to send issues and pull requests.
sunweg-3.1.0/docs/ 0000775 0000000 0000000 00000000000 14677302234 0013763 5 ustar 00root root 0000000 0000000 sunweg-3.1.0/docs/index.md 0000664 0000000 0000000 00000061174 14677302234 0015425 0 ustar 00root root 0000000 0000000 # Table of Contents
* [sunweg](#sunweg)
* [sunweg.device](#sunweg.device)
* [Phase](#sunweg.device.Phase)
* [\_\_init\_\_](#sunweg.device.Phase.__init__)
* [name](#sunweg.device.Phase.name)
* [voltage](#sunweg.device.Phase.voltage)
* [amperage](#sunweg.device.Phase.amperage)
* [status\_voltage](#sunweg.device.Phase.status_voltage)
* [status\_amperage](#sunweg.device.Phase.status_amperage)
* [\_\_str\_\_](#sunweg.device.Phase.__str__)
* [String](#sunweg.device.String)
* [\_\_init\_\_](#sunweg.device.String.__init__)
* [name](#sunweg.device.String.name)
* [voltage](#sunweg.device.String.voltage)
* [amperage](#sunweg.device.String.amperage)
* [status](#sunweg.device.String.status)
* [\_\_str\_\_](#sunweg.device.String.__str__)
* [MPPT](#sunweg.device.MPPT)
* [\_\_init\_\_](#sunweg.device.MPPT.__init__)
* [name](#sunweg.device.MPPT.name)
* [strings](#sunweg.device.MPPT.strings)
* [\_\_str\_\_](#sunweg.device.MPPT.__str__)
* [Inverter](#sunweg.device.Inverter)
* [\_\_init\_\_](#sunweg.device.Inverter.__init__)
* [id](#sunweg.device.Inverter.id)
* [name](#sunweg.device.Inverter.name)
* [sn](#sunweg.device.Inverter.sn)
* [status](#sunweg.device.Inverter.status)
* [temperature](#sunweg.device.Inverter.temperature)
* [today\_energy](#sunweg.device.Inverter.today_energy)
* [today\_energy](#sunweg.device.Inverter.today_energy)
* [today\_energy\_metric](#sunweg.device.Inverter.today_energy_metric)
* [today\_energy\_metric](#sunweg.device.Inverter.today_energy_metric)
* [total\_energy](#sunweg.device.Inverter.total_energy)
* [total\_energy](#sunweg.device.Inverter.total_energy)
* [total\_energy\_metric](#sunweg.device.Inverter.total_energy_metric)
* [total\_energy\_metric](#sunweg.device.Inverter.total_energy_metric)
* [power\_factor](#sunweg.device.Inverter.power_factor)
* [power\_factor](#sunweg.device.Inverter.power_factor)
* [frequency](#sunweg.device.Inverter.frequency)
* [frequency](#sunweg.device.Inverter.frequency)
* [power](#sunweg.device.Inverter.power)
* [power](#sunweg.device.Inverter.power)
* [power\_metric](#sunweg.device.Inverter.power_metric)
* [power\_metric](#sunweg.device.Inverter.power_metric)
* [is\_complete](#sunweg.device.Inverter.is_complete)
* [phases](#sunweg.device.Inverter.phases)
* [mppts](#sunweg.device.Inverter.mppts)
* [\_\_str\_\_](#sunweg.device.Inverter.__str__)
* [sunweg.const](#sunweg.const)
* [SUNWEG\_URL](#sunweg.const.SUNWEG_URL)
* [SUNWEG\_LOGIN\_PATH](#sunweg.const.SUNWEG_LOGIN_PATH)
* [SUNWEG\_PLANT\_LIST\_PATH](#sunweg.const.SUNWEG_PLANT_LIST_PATH)
* [SUNWEG\_PLANT\_DETAIL\_PATH](#sunweg.const.SUNWEG_PLANT_DETAIL_PATH)
* [SUNWEG\_INVERTER\_DETAIL\_PATH](#sunweg.const.SUNWEG_INVERTER_DETAIL_PATH)
* [SUNWEG\_MONTH\_STATS\_PATH](#sunweg.const.SUNWEG_MONTH_STATS_PATH)
* [sunweg.api](#sunweg.api)
* [SunWegApiError](#sunweg.api.SunWegApiError)
* [LoginError](#sunweg.api.LoginError)
* [convert\_situation\_status](#sunweg.api.convert_situation_status)
* [separate\_value\_metric](#sunweg.api.separate_value_metric)
* [APIHelper](#sunweg.api.APIHelper)
* [\_\_init\_\_](#sunweg.api.APIHelper.__init__)
* [authenticate](#sunweg.api.APIHelper.authenticate)
* [listPlants](#sunweg.api.APIHelper.listPlants)
* [plant](#sunweg.api.APIHelper.plant)
* [inverter](#sunweg.api.APIHelper.inverter)
* [complete\_inverter](#sunweg.api.APIHelper.complete_inverter)
* [month\_stats\_production](#sunweg.api.APIHelper.month_stats_production)
* [month\_stats\_production\_by\_id](#sunweg.api.APIHelper.month_stats_production_by_id)
* [sunweg.plant](#sunweg.plant)
* [Plant](#sunweg.plant.Plant)
* [\_\_init\_\_](#sunweg.plant.Plant.__init__)
* [id](#sunweg.plant.Plant.id)
* [name](#sunweg.plant.Plant.name)
* [total\_power](#sunweg.plant.Plant.total_power)
* [kwh\_per\_kwp](#sunweg.plant.Plant.kwh_per_kwp)
* [performance\_rate](#sunweg.plant.Plant.performance_rate)
* [saving](#sunweg.plant.Plant.saving)
* [today\_energy](#sunweg.plant.Plant.today_energy)
* [today\_energy\_metric](#sunweg.plant.Plant.today_energy_metric)
* [total\_energy](#sunweg.plant.Plant.total_energy)
* [total\_carbon\_saving](#sunweg.plant.Plant.total_carbon_saving)
* [last\_update](#sunweg.plant.Plant.last_update)
* [inverters](#sunweg.plant.Plant.inverters)
* [\_\_str\_\_](#sunweg.plant.Plant.__str__)
* [sunweg.util](#sunweg.util)
* [Status](#sunweg.util.Status)
* [ProductionStats](#sunweg.util.ProductionStats)
* [\_\_init\_\_](#sunweg.util.ProductionStats.__init__)
* [date](#sunweg.util.ProductionStats.date)
* [production](#sunweg.util.ProductionStats.production)
* [prognostic](#sunweg.util.ProductionStats.prognostic)
* [\_\_str\_\_](#sunweg.util.ProductionStats.__str__)
# sunweg
Sunweg API library.
# sunweg.device
Sunweg API devices.
## Phase Objects
```python
class Phase()
```
Phase details.
#### \_\_init\_\_
```python
def __init__(name: str, voltage: float, amperage: float,
status_voltage: Status, status_amperage: Status) -> None
```
Initialize Phase.
**Arguments**:
- `name` (`str`): phase name
- `voltage` (`float`): phase AC voltage in V
- `amperage` (`float`): phase AC amperage in A
- `status_voltage` (`Status`): phase AC voltage status
- `status_amperage` (`Status`): phase AC amperage status
#### name
```python
@property
def name() -> str
```
Get phase name.
**Returns**:
`str`: phase name
#### voltage
```python
@property
def voltage() -> float
```
Get phase AC voltage in V.
**Returns**:
`float`: phase AC voltage in V
#### amperage
```python
@property
def amperage() -> float
```
Get phase AC amperage in A.
**Returns**:
`float`: phase AC amperage in A
#### status\_voltage
```python
@property
def status_voltage() -> Status
```
Get phase AC voltage status.
**Returns**:
`Status`: phase AC voltage status
#### status\_amperage
```python
@property
def status_amperage() -> Status
```
Get phase AC amperage status.
**Returns**:
`Status`: phase AC amperage status
#### \_\_str\_\_
```python
def __str__() -> str
```
Cast Phase to str.
## String Objects
```python
class String()
```
String details.
#### \_\_init\_\_
```python
def __init__(name: str, voltage: float, amperage: float,
status: Status) -> None
```
Initialize String.
**Arguments**:
- `name` (`str`): string name
- `voltage` (`float`): string DC voltage in V
- `amperage` (`float`): string DC amperage in A
- `status` (`Status`): string status
#### name
```python
@property
def name() -> str
```
Get string name.
**Returns**:
`str`: string name
#### voltage
```python
@property
def voltage() -> float
```
Get string DC voltage in V.
**Returns**:
`float`: string DC voltage in V
#### amperage
```python
@property
def amperage() -> float
```
Get string DC amperage in A.
**Returns**:
`float`: string DC amperage in A
#### status
```python
@property
def status() -> Status
```
Get string status.
**Returns**:
`Status`: string status
#### \_\_str\_\_
```python
def __str__() -> str
```
Cast String to str.
## MPPT Objects
```python
class MPPT()
```
MPPT details.
#### \_\_init\_\_
```python
def __init__(name: str) -> None
```
Initialize MPPT.
**Arguments**:
- `name` (`srt`): MPPT name
#### name
```python
@property
def name() -> str
```
Get MPPT name.
**Returns**:
`str`: MPPT name
#### strings
```python
@property
def strings() -> list[String]
```
Get list of MPPT's String.
**Returns**:
`list[String]`: list of Strings
#### \_\_str\_\_
```python
def __str__() -> str
```
Cast MPPT to str.
## Inverter Objects
```python
class Inverter()
```
Inverter device.
#### \_\_init\_\_
```python
def __init__(id: int,
name: str,
sn: str,
status: Status,
temperature: int,
total_energy: float = 0,
total_energy_metric: str = "",
today_energy: float = 0,
today_energy_metric: str = "",
power_factor: float = 0,
frequency: float = 0,
power: float = 0,
power_metric: str = "") -> None
```
Initialize Inverter.
**Arguments**:
- `id` (`int`): inverter id
- `name` (`str`): inverter name
- `sn` (`str`): inverter serial number
- `status` (`Status`): inverter status
- `temperature` (`int`): inverter temperature
- `total_energy` (`float`): total generated energy
- `total_energy_metric` (`str`): total generated energy metric
- `today_energy` (`float`): total generated energy today
- `today_energy_metric` (`str`): total generated energy today metric
- `power_factor` (`float`): inverter power factor
- `frequency` (`float`): inverter output frequency in Hz
- `power` (`str`): inverter output power
- `power` (`str`): inverter output power metric
#### id
```python
@property
def id() -> int
```
Get inverter id.
**Returns**:
`int`: inverter id
#### name
```python
@property
def name() -> str
```
Get inverter name.
**Returns**:
`str`: inverter name
#### sn
```python
@property
def sn() -> str
```
Get inverter serial number.
**Returns**:
`str`: inverter serial number
#### status
```python
@property
def status() -> Status
```
Get inverter status.
**Returns**:
`Status`: inverter status
#### temperature
```python
@property
def temperature() -> int
```
Get inverter temperature.
**Returns**:
`int`: inverter temperature
#### today\_energy
```python
@property
def today_energy() -> float
```
Get inverter today generated energy.
**Returns**:
`float`: inverter today generated energy
#### today\_energy
```python
@today_energy.setter
def today_energy(value: float) -> None
```
Set inverter today generated energy.
**Arguments**:
- `value` (`float`): inverter today generated energy
#### today\_energy\_metric
```python
@property
def today_energy_metric() -> str
```
Get inverter today generated energy metric.
**Returns**:
`str`: inverter today generated energy metric
#### today\_energy\_metric
```python
@today_energy_metric.setter
def today_energy_metric(value: str) -> None
```
Set inverter today generated energy metric.
**Arguments**:
- `value` (`str`): inverter today generated energy metric
#### total\_energy
```python
@property
def total_energy() -> float
```
Get inverter total generated energy.
**Returns**:
`float`: inverter total generated energy
#### total\_energy
```python
@total_energy.setter
def total_energy(value: float) -> None
```
Set inverter total generated energy.
**Arguments**:
- `value` (`float`): inverter total generated energy
#### total\_energy\_metric
```python
@property
def total_energy_metric() -> str
```
Get inverter total generated energy metric.
**Returns**:
`str`: inverter total generated energy metric
#### total\_energy\_metric
```python
@total_energy_metric.setter
def total_energy_metric(value: str) -> None
```
Set inverter total generated energy metric.
**Arguments**:
- `value` (`str`): inverter total generated energy metric
#### power\_factor
```python
@property
def power_factor() -> float
```
Get inverter power factor.
**Returns**:
`float`: inverter power factor
#### power\_factor
```python
@power_factor.setter
def power_factor(value: float) -> None
```
Set inverter power factor.
**Arguments**:
- `value` (`float`): inverter power factor
#### frequency
```python
@property
def frequency() -> float
```
Get inverter frequency in Hz.
**Returns**:
`float`: inverter frequency in HZ
#### frequency
```python
@frequency.setter
def frequency(value: float) -> None
```
Set inverter frequency in Hz.
**Arguments**:
- `value` (`float`): inverter frequency in Hz
#### power
```python
@property
def power() -> float
```
Get inverter output power.
**Returns**:
`float`: inverter output power
#### power
```python
@power.setter
def power(value: float) -> None
```
Set inverter output power.
**Arguments**:
- `value` (`float`): inverter output power
#### power\_metric
```python
@property
def power_metric() -> str
```
Get inverter output power metric.
**Returns**:
`str`: inverter output power metric
#### power\_metric
```python
@power_metric.setter
def power_metric(value: str) -> None
```
Set inverter output power metric.
**Arguments**:
- `value` (`float`): inverter output power metric
#### is\_complete
```python
@property
def is_complete() -> bool
```
Is inverter data complete.
**Returns**:
`bool`: True when inverter data is complete
#### phases
```python
@property
def phases() -> list[Phase]
```
Get list of inverter's phases.
**Returns**:
`list[Phase]`: list of phases
#### mppts
```python
@property
def mppts() -> list[MPPT]
```
Get list of inverter's MPPTs.
**Returns**:
`list[MPPT]`: list of MPPTs
#### \_\_str\_\_
```python
def __str__() -> str
```
Cast Inverter to str.
# sunweg.const
Sunweg API constants.
#### SUNWEG\_URL
SunWEG API URL
#### SUNWEG\_LOGIN\_PATH
SunWEG API login path
#### SUNWEG\_PLANT\_LIST\_PATH
SunWEG API list plants path
#### SUNWEG\_PLANT\_DETAIL\_PATH
SunWEG API plant details path
#### SUNWEG\_INVERTER\_DETAIL\_PATH
SunWEG API inverter details path
#### SUNWEG\_MONTH\_STATS\_PATH
SunWEG API month history path
# sunweg.api
API Helper.
## SunWegApiError Objects
```python
class SunWegApiError(RuntimeError)
```
API Error.
## LoginError Objects
```python
class LoginError(SunWegApiError)
```
Login Error.
#### convert\_situation\_status
```python
def convert_situation_status(situation: int) -> Status
```
Convert situation to status.
**Arguments**:
- `situation` (`int`): situation
**Returns**:
`Status`: equivalent status
#### separate\_value\_metric
```python
def separate_value_metric(value_with_metric: str | None,
default_metric: str = "") -> tuple[float, str]
```
Separate the value from the metric.
**Arguments**:
- `value_with_metric` (`str | None`): value with metric separated by space
- `default_metric` (`str`): metric that should be returned if `value_with_metric` is None
**Returns**:
`tuple[float, str]`: tuple with value and metric
## APIHelper Objects
```python
class APIHelper()
```
Class to call sunweg.net api.
#### \_\_init\_\_
```python
def __init__(username: str, password: str) -> None
```
Initialize APIHelper for SunWEG platform.
**Arguments**:
- `username` (`str`): username for authentication
- `password` (`str`): password for authentication
#### authenticate
```python
def authenticate() -> bool
```
Authenticate with provided username and password.
**Returns**:
`bool`: True on authentication success
#### listPlants
```python
def listPlants(retry=True) -> list[Plant]
```
Retrieve the list of plants with incomplete inverter information.
You may want to call `complete_inverter()` to complete the Inverter information.
**Arguments**:
- `retry` (`bool`): reauthenticate if token expired and retry
**Returns**:
`list[Plant]`: list of Plant
#### plant
```python
def plant(id: int, retry=True) -> Plant | None
```
Retrieve plant detail by plant id.
**Arguments**:
- `id` (`int`): plant id
- `retry` (`bool`): reauthenticate if token expired and retry
**Returns**:
`Plant | None`: Plant or None if `id` not found.
#### inverter
```python
def inverter(id: int, retry=True) -> Inverter | None
```
Retrieve inverter detail by inverter id.
**Arguments**:
- `id` (`int`): inverter id
- `retry` (`bool`): reauthenticate if token expired and retry
**Returns**:
`Inverter | None`: Inverter or None if `id` not found.
#### complete\_inverter
```python
def complete_inverter(inverter: Inverter, retry=True) -> None
```
Complete inverter data.
**Arguments**:
- `inverter` (`Inverter`): inverter object to be completed with information
- `retry` (`bool`): reauthenticate if token expired and retry
#### month\_stats\_production
```python
def month_stats_production(year: int,
month: int,
plant: Plant,
inverter: Inverter | None = None,
retry: bool = True) -> list[ProductionStats]
```
Retrieve month energy production statistics.
**Arguments**:
- `year` (`int`): statistics year
- `month` (`int`): statistics month
- `plant` (`Plant`): statistics plant
- `inverter` (`Inverter | None`): statistics inverter, None for every inverter
- `retry` (`bool`): reauthenticate if token expired and retry
**Returns**:
`list[ProductionStats]`: list of daily energy production statistics
#### month\_stats\_production\_by\_id
```python
def month_stats_production_by_id(year: int,
month: int,
plant_id: int,
inverter_id: int | None = None,
retry: bool = True) -> list[ProductionStats]
```
Retrieve month energy production statistics.
**Arguments**:
- `year` (`int`): statistics year
- `month` (`int`): statistics month
- `plant_id` (`int`): id of statistics plant
- `inverter_id` (`int | None`): id of statistics inverter, None for every inverter
- `retry` (`bool`): reauthenticate if token expired and retry
**Returns**:
`list[ProductionStats]`: list of daily energy production statistics
# sunweg.plant
Sunweg API plant.
## Plant Objects
```python
class Plant()
```
Plant details.
#### \_\_init\_\_
```python
def __init__(id: int, name: str, total_power: float, kwh_per_kwp: float,
performance_rate: float, saving: float, today_energy: float,
today_energy_metric: str, total_energy: float,
total_carbon_saving: float, last_update: datetime | None) -> None
```
Initialize Plant.
**Arguments**:
- `id` (`int`): plant id
- `name` (`str`): plant name
- `total_power` (`float`): plant total power
- `kwh_per_kwp` (`float`): plant kWh/kWp
- `performance_rate` (`float`): plant performance rate
- `saving` (`float`): total saving in R$
- `today_energy` (`float`): today generated energy
- `today_energy_metric` (`str`): today generated energy metric
- `total_energy` (`float`): total generated energy in kWh
- `total_carbon_saving` (`float`): total of CO2 saved
- `last_update` (`datetime | None`): when the data was updated
#### id
```python
@property
def id() -> int
```
Get plant id.
**Returns**:
`int`: plant id
#### name
```python
@property
def name() -> str
```
Get plant name.
**Returns**:
`str`: plant name
#### total\_power
```python
@property
def total_power() -> float
```
Get plant total power.
**Returns**:
`float`: plant total power
#### kwh\_per\_kwp
```python
@property
def kwh_per_kwp() -> float
```
Get plant kWh/kWp.
**Returns**:
`float`: plant kWh/kWp
#### performance\_rate
```python
@property
def performance_rate() -> float
```
Get plant performance rate.
**Returns**:
`float`: plant performance rate
#### saving
```python
@property
def saving() -> float
```
Get plant saving in R$.
**Returns**:
`float`: plant saving in R$
#### today\_energy
```python
@property
def today_energy() -> float
```
Get plant today generated energy.
**Returns**:
`float`: plant today generated energy
#### today\_energy\_metric
```python
@property
def today_energy_metric() -> str
```
Get plant today generated energy metric.
**Returns**:
`str`: plant today generated energy metric
#### total\_energy
```python
@property
def total_energy() -> float
```
Get plant total generated energy in kWh.
**Returns**:
`float`: plant total generated energy in kWh
#### total\_carbon\_saving
```python
@property
def total_carbon_saving() -> float
```
Get plant total of CO2 saved.
**Returns**:
`float`: plant total of CO2 saved
#### last\_update
```python
@property
def last_update() -> datetime | None
```
Get when the plant data was updated.
**Returns**:
`datetime | None`: when the plant data was updated
#### inverters
```python
@property
def inverters() -> list[Inverter]
```
Get list of plant's inverters.
**Returns**:
`list[Inverter]`: list of inverters
#### \_\_str\_\_
```python
def __str__() -> str
```
Cast Plant to str.
# sunweg.util
Sunweg API util.
## Status Objects
```python
class Status(Enum)
```
Status enum.
## ProductionStats Objects
```python
class ProductionStats()
```
Energy production statistics
#### \_\_init\_\_
```python
def __init__(date: date, production: float, prognostic: float) -> None
```
Initialize energy production statistics.
**Arguments**:
- `date` (`date`): statistics date
- `production` (`float`): statistics production in kWh
- `prognostic`: statistics expected production in kWh
#### date
```python
@property
def date() -> date
```
Get date.
#### production
```python
@property
def production() -> float
```
Get energy production in kWh.
#### prognostic
```python
@property
def prognostic() -> float
```
Get expected energy production in kWh.
#### \_\_str\_\_
```python
def __str__() -> str
```
Cast Phase to str.
sunweg-3.1.0/img/ 0000775 0000000 0000000 00000000000 14677302234 0013607 5 ustar 00root root 0000000 0000000 sunweg-3.1.0/img/image.png 0000664 0000000 0000000 00000424412 14677302234 0015406 0 ustar 00root root 0000000 0000000 PNG
IHDR # b < sBIT|d tEXtSoftware gnome-screenshot> &tEXtCreation Time qua 02 out 2024 14:25:34Kz IDATx}\TUAġ&ACK2)ݠ-E\2*ž
l1-MV2`,Vt[M CEJ!$`?ay~|{9{>{|>5"`ҖC8e:Iyԝe]FVp#Gߔ)~ٳ6uпs.@ 3Rnt9~tMgkX.lhs`0欬-bz^^*dm1V CVVX/eco|#d!""3C}cbbHH@ Ucp-owe@6VԝcҖ-w:0ّGst[j""FEVf9Bɑ#
CCg@|B<[uع;@E*/?YYVKV>50e*çޡtj9e=?# #M-'#%h
}^n"""Yຟ@ F;Uc].嗅dlF(7~CxW˼M.
0T&?ؘXEwPŨ":Ěn"""<.rpd:bw`9=Z&6&Zo4Avw{?O[" )@ 3j$