sunsynk-api-client 1.2.0__tar.gz → 1.2.1__tar.gz

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.
Files changed (35) hide show
  1. sunsynk_api_client-1.2.1/PKG-INFO +99 -0
  2. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/README.md +4 -0
  3. sunsynk_api_client-1.2.1/pyproject.toml +33 -0
  4. sunsynk_api_client-1.2.1/sunsynk/__init__.py +3 -0
  5. sunsynk_api_client-1.2.1/sunsynk_api_client.egg-info/PKG-INFO +99 -0
  6. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk_api_client.egg-info/SOURCES.txt +1 -3
  7. sunsynk_api_client-1.2.0/PKG-INFO +0 -27
  8. sunsynk_api_client-1.2.0/setup.py +0 -31
  9. sunsynk_api_client-1.2.0/sunsynk/__init__.py +0 -0
  10. sunsynk_api_client-1.2.0/sunsynk/version.py +0 -1
  11. sunsynk_api_client-1.2.0/sunsynk/version_info.py +0 -41
  12. sunsynk_api_client-1.2.0/sunsynk_api_client.egg-info/PKG-INFO +0 -27
  13. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/LICENSE +0 -0
  14. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/setup.cfg +0 -0
  15. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/battery.py +0 -0
  16. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/client.py +0 -0
  17. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/exceptions.py +0 -0
  18. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/grid.py +0 -0
  19. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/input.py +0 -0
  20. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/inverter.py +0 -0
  21. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/load.py +0 -0
  22. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/output.py +0 -0
  23. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/plant.py +0 -0
  24. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/pviv.py +0 -0
  25. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/py.typed +0 -0
  26. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/resource.py +0 -0
  27. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/vip.py +0 -0
  28. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/vip_resource.py +0 -0
  29. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk/weather.py +0 -0
  30. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk_api_client.egg-info/dependency_links.txt +0 -0
  31. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk_api_client.egg-info/requires.txt +0 -0
  32. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/sunsynk_api_client.egg-info/top_level.txt +0 -0
  33. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/tests/test_client.py +0 -0
  34. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/tests/test_client_errors.py +0 -0
  35. {sunsynk_api_client-1.2.0 → sunsynk_api_client-1.2.1}/tests/test_resource.py +0 -0
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: sunsynk-api-client
3
+ Version: 1.2.1
4
+ Summary: API client for interacting with SunSynk APIs.
5
+ Author: James Ridgway
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/jamesridgway/sunsynk-api-client
8
+ Project-URL: Changelog, https://github.com/jamesridgway/sunsynk-api-client/releases
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Framework :: AsyncIO
13
+ Requires-Python: >=3.13
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: aiohttp>=3.9
17
+ Requires-Dist: cryptography>=41
18
+ Dynamic: license-file
19
+
20
+ # Sunsynk API Client
21
+ [![CI](https://github.com/jamesridgway/sunsynk-api-client/actions/workflows/ci.yml/badge.svg)](https://github.com/jamesridgway/sunsynk-api-client/actions/workflows/ci.yml)
22
+
23
+ An API client library for reading data from the Sunsynk API that is used by the Sunsynk Connect apps and
24
+ [PowerView](https://pv.inteless.com/) portal.
25
+
26
+
27
+ ## Install
28
+
29
+ pip install sunsynk-api-client
30
+
31
+ ## Example Usage
32
+
33
+ import asyncio
34
+ import os
35
+
36
+ from sunsynk.client import SunsynkClient
37
+
38
+
39
+ async def main():
40
+ sunsynk_username = os.getenv('SUNSYNK_USERNAME')
41
+ sunsynk_password = os.getenv('SUNSYNK_PASSWORD')
42
+
43
+ async with SunsynkClient(sunsynk_username, sunsynk_password) as client:
44
+ inverters = await client.get_inverters()
45
+ for inverter in inverters:
46
+ grid = await client.get_inverter_realtime_grid(inverter.sn)
47
+ battery = await client.get_inverter_realtime_battery(inverter.sn)
48
+ solar_pv = await client.get_inverter_realtime_input(inverter.sn)
49
+
50
+ await client.get_inverter_realtime_output(inverter.sn)
51
+
52
+ print(f"Inverter (sn: {inverter.sn}) is drawing {grid.get_power()}W from the grid, {battery.power}W from battery and {solar_pv.get_power()}W.")
53
+
54
+ print('Done!')
55
+
56
+ asyncio.run(main())
57
+
58
+
59
+ ## Use With an Existing aiohttp Session
60
+
61
+ Pass a `session` to share an existing `aiohttp.ClientSession`. The client does
62
+ not close a shared session:
63
+
64
+ async with aiohttp.ClientSession() as session:
65
+ client = SunsynkClient(sunsynk_username, sunsynk_password, session=session)
66
+ await client.login()
67
+ inverters = await client.get_inverters()
68
+
69
+ ## Errors
70
+
71
+ All errors raised by the client subclass `sunsynk.exceptions.SunsynkError`:
72
+
73
+ * `SunsynkAuthenticationError` - the username or password is not correct.
74
+ * `SunsynkConnectionError` - the API could not be reached, timed out, or
75
+ returned an unexpected response.
76
+
77
+ Numeric values in the API responses are converted to `float` or `int`. Values
78
+ that are missing are `None`.
79
+
80
+ ## Load, Plant Details and Weather
81
+
82
+ In addition to the inverter realtime data shown above, the client can also read
83
+ the realtime load/UPS metrics, full plant details (including coordinates), and
84
+ the weather for a plant's location:
85
+
86
+ async with SunsynkClient(sunsynk_username, sunsynk_password) as client:
87
+ inverters = await client.get_inverters()
88
+ load = await client.get_inverter_realtime_load(inverters[0].sn)
89
+ print(f"Load is drawing {load.get_power()}W ({load.daily_used} kWh used today)")
90
+
91
+ # get_plant returns the full plant detail, including lon/lat coordinates
92
+ plant = await client.get_plant(inverters[0].plant.id)
93
+
94
+ # The Sunsynk weather endpoint expects the coordinates as "lat,lon"
95
+ weather = await client.get_weather(f"{plant.lat},{plant.lon}")
96
+ print(f"It is currently {weather.get_current_temp()}C and {weather.description}")
97
+
98
+ `get_weather` defaults to today's date; pass `date="YYYY-MM-DD"` to request a
99
+ specific day.
@@ -5,6 +5,10 @@ An API client library for reading data from the Sunsynk API that is used by the
5
5
  [PowerView](https://pv.inteless.com/) portal.
6
6
 
7
7
 
8
+ ## Install
9
+
10
+ pip install sunsynk-api-client
11
+
8
12
  ## Example Usage
9
13
 
10
14
  import asyncio
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sunsynk-api-client"
7
+ version = "1.2.1"
8
+ description = "API client for interacting with SunSynk APIs."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "James Ridgway" }]
13
+ requires-python = ">=3.13"
14
+ dependencies = [
15
+ "aiohttp>=3.9",
16
+ "cryptography>=41",
17
+ ]
18
+ classifiers = [
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Framework :: AsyncIO",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/jamesridgway/sunsynk-api-client"
27
+ Changelog = "https://github.com/jamesridgway/sunsynk-api-client/releases"
28
+
29
+ [tool.setuptools.packages.find]
30
+ include = ["sunsynk*"]
31
+
32
+ [tool.setuptools.package-data]
33
+ sunsynk = ["py.typed"]
@@ -0,0 +1,3 @@
1
+ """Async client for the Sunsynk API."""
2
+
3
+ __version__ = "1.2.1"
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: sunsynk-api-client
3
+ Version: 1.2.1
4
+ Summary: API client for interacting with SunSynk APIs.
5
+ Author: James Ridgway
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/jamesridgway/sunsynk-api-client
8
+ Project-URL: Changelog, https://github.com/jamesridgway/sunsynk-api-client/releases
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Framework :: AsyncIO
13
+ Requires-Python: >=3.13
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: aiohttp>=3.9
17
+ Requires-Dist: cryptography>=41
18
+ Dynamic: license-file
19
+
20
+ # Sunsynk API Client
21
+ [![CI](https://github.com/jamesridgway/sunsynk-api-client/actions/workflows/ci.yml/badge.svg)](https://github.com/jamesridgway/sunsynk-api-client/actions/workflows/ci.yml)
22
+
23
+ An API client library for reading data from the Sunsynk API that is used by the Sunsynk Connect apps and
24
+ [PowerView](https://pv.inteless.com/) portal.
25
+
26
+
27
+ ## Install
28
+
29
+ pip install sunsynk-api-client
30
+
31
+ ## Example Usage
32
+
33
+ import asyncio
34
+ import os
35
+
36
+ from sunsynk.client import SunsynkClient
37
+
38
+
39
+ async def main():
40
+ sunsynk_username = os.getenv('SUNSYNK_USERNAME')
41
+ sunsynk_password = os.getenv('SUNSYNK_PASSWORD')
42
+
43
+ async with SunsynkClient(sunsynk_username, sunsynk_password) as client:
44
+ inverters = await client.get_inverters()
45
+ for inverter in inverters:
46
+ grid = await client.get_inverter_realtime_grid(inverter.sn)
47
+ battery = await client.get_inverter_realtime_battery(inverter.sn)
48
+ solar_pv = await client.get_inverter_realtime_input(inverter.sn)
49
+
50
+ await client.get_inverter_realtime_output(inverter.sn)
51
+
52
+ print(f"Inverter (sn: {inverter.sn}) is drawing {grid.get_power()}W from the grid, {battery.power}W from battery and {solar_pv.get_power()}W.")
53
+
54
+ print('Done!')
55
+
56
+ asyncio.run(main())
57
+
58
+
59
+ ## Use With an Existing aiohttp Session
60
+
61
+ Pass a `session` to share an existing `aiohttp.ClientSession`. The client does
62
+ not close a shared session:
63
+
64
+ async with aiohttp.ClientSession() as session:
65
+ client = SunsynkClient(sunsynk_username, sunsynk_password, session=session)
66
+ await client.login()
67
+ inverters = await client.get_inverters()
68
+
69
+ ## Errors
70
+
71
+ All errors raised by the client subclass `sunsynk.exceptions.SunsynkError`:
72
+
73
+ * `SunsynkAuthenticationError` - the username or password is not correct.
74
+ * `SunsynkConnectionError` - the API could not be reached, timed out, or
75
+ returned an unexpected response.
76
+
77
+ Numeric values in the API responses are converted to `float` or `int`. Values
78
+ that are missing are `None`.
79
+
80
+ ## Load, Plant Details and Weather
81
+
82
+ In addition to the inverter realtime data shown above, the client can also read
83
+ the realtime load/UPS metrics, full plant details (including coordinates), and
84
+ the weather for a plant's location:
85
+
86
+ async with SunsynkClient(sunsynk_username, sunsynk_password) as client:
87
+ inverters = await client.get_inverters()
88
+ load = await client.get_inverter_realtime_load(inverters[0].sn)
89
+ print(f"Load is drawing {load.get_power()}W ({load.daily_used} kWh used today)")
90
+
91
+ # get_plant returns the full plant detail, including lon/lat coordinates
92
+ plant = await client.get_plant(inverters[0].plant.id)
93
+
94
+ # The Sunsynk weather endpoint expects the coordinates as "lat,lon"
95
+ weather = await client.get_weather(f"{plant.lat},{plant.lon}")
96
+ print(f"It is currently {weather.get_current_temp()}C and {weather.description}")
97
+
98
+ `get_weather` defaults to today's date; pass `date="YYYY-MM-DD"` to request a
99
+ specific day.
@@ -1,6 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
- setup.py
3
+ pyproject.toml
4
4
  sunsynk/__init__.py
5
5
  sunsynk/battery.py
6
6
  sunsynk/client.py
@@ -14,8 +14,6 @@ sunsynk/plant.py
14
14
  sunsynk/pviv.py
15
15
  sunsynk/py.typed
16
16
  sunsynk/resource.py
17
- sunsynk/version.py
18
- sunsynk/version_info.py
19
17
  sunsynk/vip.py
20
18
  sunsynk/vip_resource.py
21
19
  sunsynk/weather.py
@@ -1,27 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: sunsynk-api-client
3
- Version: 1.2.0
4
- Summary: API client for interacting with SunSynk APIs.
5
- Home-page: https://github.com/jamesridgway/sunsynk-api-client
6
- Author: James Ridgway
7
- License: MIT
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.13
11
- Classifier: Programming Language :: Python :: 3.14
12
- Classifier: Framework :: AsyncIO
13
- Requires-Python: >=3.13
14
- License-File: LICENSE
15
- Requires-Dist: aiohttp>=3.9
16
- Requires-Dist: cryptography>=41
17
- Dynamic: author
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: home-page
21
- Dynamic: license
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
- API client for interacting with SunSynk APIs.
@@ -1,31 +0,0 @@
1
- import os
2
-
3
- from setuptools import setup, find_packages
4
-
5
- from sunsynk.version_info import Version
6
-
7
- Version.generate()
8
-
9
- with open(os.path.abspath(os.path.join(os.path.dirname(__file__), 'requirements.txt'))) as f:
10
- install_reqs = f.read().splitlines()
11
-
12
- setup(
13
- name='sunsynk-api-client',
14
- version=Version.get(),
15
- description='API client for interacting with SunSynk APIs.',
16
- long_description='API client for interacting with SunSynk APIs.',
17
- author='James Ridgway',
18
- url='https://github.com/jamesridgway/sunsynk-api-client',
19
- license='MIT',
20
- packages=find_packages(exclude=['tests', 'tests.*']),
21
- package_data={'sunsynk': ['py.typed']},
22
- python_requires='>=3.13',
23
- install_requires=install_reqs,
24
- classifiers=[
25
- 'License :: OSI Approved :: MIT License',
26
- 'Programming Language :: Python :: 3',
27
- 'Programming Language :: Python :: 3.13',
28
- 'Programming Language :: Python :: 3.14',
29
- 'Framework :: AsyncIO',
30
- ],
31
- )
File without changes
@@ -1 +0,0 @@
1
- SUNSYNK_API_CLIENT_VERSION = "1.2.0"
@@ -1,41 +0,0 @@
1
- import os
2
- import platform
3
- import subprocess
4
- import sys
5
-
6
- VERSION_FILENAME = os.path.abspath(os.path.join(os.path.dirname(__file__), 'version.py'))
7
-
8
-
9
- class Version:
10
- @staticmethod
11
- def generate() -> str:
12
- with subprocess.Popen(["git", "describe", "--always", "--tags"],
13
- stdout=subprocess.PIPE,
14
- stderr=None) as process:
15
- last_tag = process.communicate()[0].decode('ascii').strip()
16
- version = last_tag.split('-g', maxsplit=1)[0].replace('-', '.') if '-g' in last_tag else last_tag
17
- with open(VERSION_FILENAME, 'w',encoding='utf-8') as file:
18
- file.write(f'SUNSYNK_API_CLIENT_VERSION = "{version}"\n')
19
- return version
20
-
21
- @staticmethod
22
- def get(retry=True) -> str:
23
- try:
24
- # pylint: disable=C0415
25
- from sunsynk.version import SUNSYNK_API_CLIENT_VERSION
26
- return SUNSYNK_API_CLIENT_VERSION
27
- except ModuleNotFoundError:
28
- if retry:
29
- Version.generate()
30
- return Version.get(False)
31
- return 'unknown'
32
- except ImportError:
33
- if retry:
34
- Version.generate()
35
- return Version.get(False)
36
- return 'unknown'
37
-
38
- @staticmethod
39
- def get_env_info() -> str:
40
- os_info = f"Release: {platform.release()}, Platform: {platform.platform()}"
41
- return f"(Python: {platform.python_version()}), OS: ({os_info}). Default Encoding: {sys.getdefaultencoding()}"
@@ -1,27 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: sunsynk-api-client
3
- Version: 1.2.0
4
- Summary: API client for interacting with SunSynk APIs.
5
- Home-page: https://github.com/jamesridgway/sunsynk-api-client
6
- Author: James Ridgway
7
- License: MIT
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.13
11
- Classifier: Programming Language :: Python :: 3.14
12
- Classifier: Framework :: AsyncIO
13
- Requires-Python: >=3.13
14
- License-File: LICENSE
15
- Requires-Dist: aiohttp>=3.9
16
- Requires-Dist: cryptography>=41
17
- Dynamic: author
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: home-page
21
- Dynamic: license
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
- API client for interacting with SunSynk APIs.