Skip to content

Commit 5415cd1

Browse files
Merge pull request #21 from Poshy163/main
2 parents 7a4078e + 038c2ac commit 5415cd1

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

alphaess/alphaess.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def __init__(
2020
appSecret,
2121
session: aiohttp.ClientSession | None = None,
2222
timeout: int = 30,
23-
ipaddress=None
23+
ipaddress=None,
24+
verify_ssl=True
2425
) -> None:
2526
"""Initialize."""
2627
self.appID = appID
@@ -33,6 +34,7 @@ def __init__(
3334
self._created_session = not session
3435
self.timeout = timeout
3536
self.ipaddress = ipaddress
37+
self.verify_ssl = verify_ssl
3638

3739
async def close(self) -> None:
3840
"""Close the AlphaESS API client."""
@@ -344,7 +346,8 @@ async def api_get(self, path, json=None) -> Optional(list):
344346
path,
345347
headers=headers,
346348
json=json,
347-
raise_for_status=True
349+
raise_for_status=True,
350+
ssl=self.verify_ssl
348351
) as response:
349352

350353
if response.status == 200:
@@ -375,7 +378,8 @@ async def api_post(self, path, json) -> Optional(dict):
375378
response = await self.session.post(
376379
path,
377380
headers=headers,
378-
json=json
381+
json=json,
382+
ssl=self.verify_ssl
379383
)
380384

381385
response.raise_for_status()

apitest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import asyncio
22
import logging
33
import sys
4+
from enum import verify
5+
46
from alphaess.alphaess import alphaess
57
from datetime import date, timedelta
68

79
if len(sys.argv) != 3:
810
appID = input("AppID: ")
911
appSecret = input("AppSecret: ")
1012
IPAddress = input("IP Address (blank if not using): ") or None
13+
verify_ssl = input("Verify SSL? (Y/N, default Y): ").strip().upper() != "N"
1114
else:
1215
appID = sys.argv[1]
1316
appSecret = sys.argv[2]
1417
IPAddress = sys.argv[3]
18+
verify_ssl = True
1519

1620
logger = logging.getLogger('')
1721
logger.setLevel(logging.DEBUG)
@@ -28,7 +32,7 @@
2832
async def main():
2933
logger.debug("instantiating Alpha ESS Client")
3034
try:
31-
client: alphaess = alphaess(appID, appSecret, ipaddress=IPAddress)
35+
client: alphaess = alphaess(appID, appSecret, ipaddress=IPAddress, verify_ssl=verify_ssl)
3236
ESSList = await client.getESSList()
3337
for unit in ESSList:
3438
if "sysSn" in unit:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
aiohttp~=3.12.13
1+
aiohttp~=3.13.1
22
voluptuous~=0.15.2
33
setuptools~=80.9.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="alphaessopenapi",
8-
version="0.0.16",
8+
version="0.0.17",
99
author="Charles Gillanders",
1010
author_email="[email protected]",
1111
description="A python library to retrieve energy statistics from your Alpha ESS inverter by polling the Official Alpha ESS Open API.",

0 commit comments

Comments
 (0)