代码拉取完成,页面将自动刷新
import logging
import asyncio
from GivTCP.findInvertor import findInvertor
from GivTCP.givenergy_modbus_async.client.client import Client
logger = logging.getLogger(__name__)
subnet="172.16.10.185"
invList={}
inverterStats={}
async def getInvDeets2(HOST):
try:
Stats={}
client=Client(HOST,8899,3)
await client.connect()
await client.detect_plant(additional=False)
await client.close()
SN= client.plant.inverter.serial_number
#logger.debug("Deets retrieved from found Inverter are: "+str(stats))
#SN=stats[2]
gen=client.plant.inverter.generation
model=client.plant.inverter.model
fw=client.plant.inverter.arm_firmware_version
numbats=client.plant.number_batteries
Stats['Serial_Number']=SN
Stats['Firmware']=fw
Stats['Model']=model
Stats['Generation']=gen
Stats['Number_of_Batteries']=numbats
Stats['IP_Address']=HOST
logger.info(f'Inverter {str(SN)} which is a {str(gen.name.capitalize())} - {str(model.name.capitalize())} with {str(numbats)} batteries has been found at: {str(HOST)}')
return Stats
except:
logger.debug("Gathering inverter details for " + str(HOST) + " failed.")
return None
list={}
count=0
while len(list)<=0:
if count<2:
logger.info("INV- Scanning network ("+str(count+1)+"):"+str(subnet))
list=findInvertor(subnet)
if len(list)>0: break
count=count+1
else:
break
if list:
logger.info(str(len(list))+" Inverters found on "+str(subnet)+" - "+str(list))
invList.update(list)
for inv in invList:
deets={}
logger.info("Getting inverter stats for: "+str(invList[inv]))
count=0
while not deets:
if count<2:
deets=asyncio.run(getInvDeets2(invList[inv]))
#deets=getInvDeets2(invList[inv])
if deets:
inverterStats[inv]=deets
logger.info(deets)
#else:
# logger.error("Unable to interrogate inverter to get base details")
count=count+1
else:
break
if len(invList)==0:
logger.info("No inverters found...")
else:
logger.info("inverters found...")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。