aiosolaredge 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aiosolaredge/__init__.py
ADDED
aiosolaredge/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Any, Iterable, Literal, Optional
|
|
3
|
+
|
|
4
|
+
import aiohttp
|
|
5
|
+
import yarl
|
|
6
|
+
|
|
7
|
+
_BASE_URL = yarl.URL("https://monitoringapi.solaredge.com")
|
|
8
|
+
_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SolarEdge:
|
|
12
|
+
"""SolarEdge API client."""
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
api_key: str,
|
|
17
|
+
session: Optional[aiohttp.ClientSession] = None,
|
|
18
|
+
timeout: int = 10,
|
|
19
|
+
) -> None:
|
|
20
|
+
"""Initialize the SolarEdge API client."""
|
|
21
|
+
self.api_key = api_key
|
|
22
|
+
self.session = session or aiohttp.ClientSession()
|
|
23
|
+
self._created_session = not session
|
|
24
|
+
self.timeout = timeout
|
|
25
|
+
|
|
26
|
+
async def close(self) -> None:
|
|
27
|
+
"""Close the SolarEdge API client."""
|
|
28
|
+
if self._created_session:
|
|
29
|
+
await self.session.close()
|
|
30
|
+
|
|
31
|
+
def _get_site_url(self, site_id: int) -> yarl.URL:
|
|
32
|
+
"""Get the site URL."""
|
|
33
|
+
return _BASE_URL.joinpath("site", str(site_id))
|
|
34
|
+
|
|
35
|
+
async def get_details(self, site_id: int) -> dict[str, Any]:
|
|
36
|
+
"""
|
|
37
|
+
Get details of the SolarEdge system.
|
|
38
|
+
|
|
39
|
+
:param site_id: The site ID.
|
|
40
|
+
:return: The details of the SolarEdge system.
|
|
41
|
+
"""
|
|
42
|
+
return await self._get_json(self._get_site_url(site_id).joinpath("details"))
|
|
43
|
+
|
|
44
|
+
async def get_overview(self, site_id: int) -> dict[str, Any]:
|
|
45
|
+
"""
|
|
46
|
+
Get overview of the SolarEdge system.
|
|
47
|
+
|
|
48
|
+
:param site_id: The site ID.
|
|
49
|
+
:return: The overview of the SolarEdge system.
|
|
50
|
+
"""
|
|
51
|
+
return await self._get_json(self._get_site_url(site_id).joinpath("overview"))
|
|
52
|
+
|
|
53
|
+
async def get_inventory(self, site_id: int) -> dict[str, Any]:
|
|
54
|
+
"""
|
|
55
|
+
Get inventory of the SolarEdge system.
|
|
56
|
+
|
|
57
|
+
:param site_id: The site ID.
|
|
58
|
+
:return: The inventory of the SolarEdge system.
|
|
59
|
+
"""
|
|
60
|
+
return await self._get_json(self._get_site_url(site_id).joinpath("inventory"))
|
|
61
|
+
|
|
62
|
+
async def get_energy_details(
|
|
63
|
+
self,
|
|
64
|
+
site_id: int,
|
|
65
|
+
start_time: datetime,
|
|
66
|
+
end_time: datetime,
|
|
67
|
+
meters: Iterable[
|
|
68
|
+
Literal[
|
|
69
|
+
"PRODUCTION", "CONSUMPTION", "SELFCONSUMPTION", "FEEDIN", "PURCHASED"
|
|
70
|
+
]
|
|
71
|
+
] = [],
|
|
72
|
+
time_unit: str = "DAY",
|
|
73
|
+
) -> dict[str, Any]:
|
|
74
|
+
"""
|
|
75
|
+
Get energy details of the SolarEdge system.
|
|
76
|
+
|
|
77
|
+
:param site_id: The site ID.
|
|
78
|
+
:param start_time: The start time.
|
|
79
|
+
:param end_time: The end time.
|
|
80
|
+
:param meters: The meters.
|
|
81
|
+
an iterable of PRODUCTION,CONSUMPTION,SELFCONSUMPTION,FEEDIN,PURCHASED
|
|
82
|
+
:param time_unit: The time unit.
|
|
83
|
+
one of "QUARTER_OF_AN_HOUR", "HOUR", "DAY", "WEEK", "MONTH", "YEAR"
|
|
84
|
+
:return: The energy details of the SolarEdge system.
|
|
85
|
+
"""
|
|
86
|
+
url = self._get_site_url(site_id).joinpath("energyDetails")
|
|
87
|
+
params = {
|
|
88
|
+
"startTime": start_time.strftime(_DATETIME_FORMAT),
|
|
89
|
+
"endTime": end_time.strftime(_DATETIME_FORMAT),
|
|
90
|
+
"timeUnit": time_unit,
|
|
91
|
+
}
|
|
92
|
+
if meters:
|
|
93
|
+
params["meters"] = ",".join(meters)
|
|
94
|
+
return await self._get_json(url, params=params)
|
|
95
|
+
|
|
96
|
+
async def get_current_power_flow(self, site_id: int) -> dict[str, Any]:
|
|
97
|
+
"""
|
|
98
|
+
Get current power flow of the SolarEdge system.
|
|
99
|
+
|
|
100
|
+
:param site_id: The site ID.
|
|
101
|
+
:return: The current power flow of the SolarEdge system.
|
|
102
|
+
"""
|
|
103
|
+
return await self._get_json(
|
|
104
|
+
self._get_site_url(site_id).joinpath("currentPowerFlow")
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
async def _get_json(
|
|
108
|
+
self, url: yarl.URL, params: dict[str, Any] | None = None
|
|
109
|
+
) -> dict[str, Any]:
|
|
110
|
+
"""Get JSON from the SolarEdge API."""
|
|
111
|
+
response = await self.session.get(
|
|
112
|
+
url,
|
|
113
|
+
params={"api_key": self.api_key, **(params or {})},
|
|
114
|
+
timeout=self.timeout,
|
|
115
|
+
)
|
|
116
|
+
response.raise_for_status()
|
|
117
|
+
return await response.json()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 J. Nick Koston
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: aiosolaredge
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Asyncio SolarEdge
|
|
5
|
+
Home-page: https://github.com/bdraco/aiosolaredge
|
|
6
|
+
License: MIT
|
|
7
|
+
Author: J. Nick Koston
|
|
8
|
+
Author-email: nick@koston.org
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Requires-Dist: aiohttp (>=3.9.0)
|
|
21
|
+
Requires-Dist: yarl (>=1.9.0)
|
|
22
|
+
Project-URL: Bug Tracker, https://github.com/bdraco/aiosolaredge/issues
|
|
23
|
+
Project-URL: Changelog, https://github.com/bdraco/aiosolaredge/blob/main/CHANGELOG.md
|
|
24
|
+
Project-URL: Documentation, https://aiosolaredge.readthedocs.io
|
|
25
|
+
Project-URL: Repository, https://github.com/bdraco/aiosolaredge
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# Asyncio SolarEdge
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://github.com/bdraco/aiosolaredge/actions/workflows/ci.yml?query=branch%3Amain">
|
|
32
|
+
<img src="https://img.shields.io/github/actions/workflow/status/bdraco/aiosolaredge/ci.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" >
|
|
33
|
+
</a>
|
|
34
|
+
<a href="https://aiosolaredge.readthedocs.io">
|
|
35
|
+
<img src="https://img.shields.io/readthedocs/aiosolaredge.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
|
|
36
|
+
</a>
|
|
37
|
+
<a href="https://codecov.io/gh/bdraco/aiosolaredge">
|
|
38
|
+
<img src="https://img.shields.io/codecov/c/github/bdraco/aiosolaredge.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
39
|
+
</a>
|
|
40
|
+
</p>
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://python-poetry.org/">
|
|
43
|
+
<img src="https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=" alt="Poetry">
|
|
44
|
+
</a>
|
|
45
|
+
<a href="https://github.com/ambv/black">
|
|
46
|
+
<img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square" alt="black">
|
|
47
|
+
</a>
|
|
48
|
+
<a href="https://github.com/pre-commit/pre-commit">
|
|
49
|
+
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
|
|
50
|
+
</a>
|
|
51
|
+
</p>
|
|
52
|
+
<p align="center">
|
|
53
|
+
<a href="https://pypi.org/project/aiosolaredge/">
|
|
54
|
+
<img src="https://img.shields.io/pypi/v/aiosolaredge.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
|
|
55
|
+
</a>
|
|
56
|
+
<img src="https://img.shields.io/pypi/pyversions/aiosolaredge.svg?style=flat-square&logo=python&logoColor=fff" alt="Supported Python versions">
|
|
57
|
+
<img src="https://img.shields.io/pypi/l/aiosolaredge.svg?style=flat-square" alt="License">
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
**Documentation**: <a href="https://aiosolaredge.readthedocs.io" target="_blank">https://aiosolaredge.readthedocs.io </a>
|
|
63
|
+
|
|
64
|
+
**Source Code**: <a href="https://github.com/bdraco/aiosolaredge" target="_blank">https://github.com/bdraco/aiosolaredge </a>
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
Asyncio SolarEdge
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
Install this via pip (or your favourite package manager):
|
|
73
|
+
|
|
74
|
+
`pip install aiosolaredge`
|
|
75
|
+
|
|
76
|
+
## Contributors ✨
|
|
77
|
+
|
|
78
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
79
|
+
|
|
80
|
+
<!-- prettier-ignore-start -->
|
|
81
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
82
|
+
<!-- markdownlint-disable -->
|
|
83
|
+
<!-- markdownlint-enable -->
|
|
84
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
85
|
+
<!-- prettier-ignore-end -->
|
|
86
|
+
|
|
87
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
88
|
+
|
|
89
|
+
## Credits
|
|
90
|
+
|
|
91
|
+
This package was created with
|
|
92
|
+
[Copier](https://copier.readthedocs.io/) and the
|
|
93
|
+
[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
|
|
94
|
+
project template.
|
|
95
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
aiosolaredge/__init__.py,sha256=tqvw1P3DDONFxixGrb36QmI-XUyyNeY7Zn73S_twfb4,117
|
|
2
|
+
aiosolaredge/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
aiosolaredge/solaredge.py,sha256=yVKekpVycnAbdcQZp7G8WO2O_o2_jsJpnFbhDeFa6ts,3888
|
|
4
|
+
aiosolaredge-0.1.0.dist-info/LICENSE,sha256=rbfcA4IGPLGOT4bAnhAfD-rv0UtcfWXKUrJuikvUaVQ,1072
|
|
5
|
+
aiosolaredge-0.1.0.dist-info/METADATA,sha256=mHgM-2SAw-QZ6bbwN6W8SGJNQgVQLYb8GsKXwgqNqNM,4855
|
|
6
|
+
aiosolaredge-0.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
+
aiosolaredge-0.1.0.dist-info/RECORD,,
|