Skip to content

Commit e3c6772

Browse files
Merge pull request #17 from Poshy163/local-api-support
2 parents 0a52608 + 2082347 commit e3c6772

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

alphaess/alphaess.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,29 +406,39 @@ async def getdata(self, get_power=False, get_ev=False, self_delay=0) -> Optional
406406
"""Get All Data For All serial numbers from Alpha ESS"""
407407
try:
408408
alldata = []
409+
410+
# Prepare local IP data if available
411+
local_ip_data = {}
409412
if self.ipaddress:
410413
ip_data = await self.getIPData()
411414
if ip_data:
412-
# Wrap it like a unit and add to alldata
413-
alldata.append({
414-
"type": "local_ip_data",
415-
"ip": self.ipaddress,
416-
**ip_data # merge status and device_info keys
417-
})
415+
local_ip_data = {
416+
"LocalIPData": {
417+
"type": "local_ip_data",
418+
"ip": self.ipaddress,
419+
**ip_data # merges 'status' and 'device_info' keys
420+
}
421+
}
422+
418423
units = await self.getESSList()
419-
for unit in units:
424+
for idx, unit in enumerate(units):
420425
if "sysSn" in unit:
421426
serial = unit["sysSn"]
422427
unit['SumData'] = await self.getSumDataForCustomer(serial)
423428
await asyncio.sleep(self_delay)
429+
424430
unit['OneDateEnergy'] = await self.getOneDateEnergyBySn(serial, time.strftime("%Y-%m-%d"))
425431
await asyncio.sleep(self_delay)
432+
426433
unit['LastPower'] = await self.getLastPowerData(serial)
427434
await asyncio.sleep(self_delay)
435+
428436
unit['ChargeConfig'] = await self.getChargeConfigInfo(serial)
429437
await asyncio.sleep(self_delay)
438+
430439
unit['DisChargeConfig'] = await self.getDisChargeConfigInfo(serial)
431440
await asyncio.sleep(self_delay)
441+
432442
if get_power:
433443
await asyncio.sleep(self_delay)
434444
unit['OneDayPower'] = await self.getOneDayPowerBySn(serial, time.strftime("%Y-%m-%d"))
@@ -443,8 +453,14 @@ async def getdata(self, get_power=False, get_ev=False, self_delay=0) -> Optional
443453
unit['EVCurrent'] = await self.getEvChargerCurrentsBySn(serial)
444454
except Exception:
445455
pass
456+
457+
# Only add the local IP data to the first inverter unit
458+
if idx == 0 and local_ip_data:
459+
unit.update(local_ip_data)
460+
446461
alldata.append(unit)
447462
logger.debug(alldata)
463+
448464
return alldata
449465

450466
except Exception as e:

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.14",
8+
version="0.0.15",
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)