32 lines
706 B
Python
32 lines
706 B
Python
import asyncio
|
|
import os
|
|
import toml
|
|
|
|
from CloudConnection import CloudConnection
|
|
from Inverter import Inverter
|
|
|
|
|
|
async def main():
|
|
os.path.dirname(__file__)
|
|
with open("config.toml", "r") as f:
|
|
config = toml.load(f)
|
|
|
|
connection = CloudConnection(config["username"], config["password"])
|
|
connection.generate_user_token()
|
|
inverter = connection.get_inverter()
|
|
devices = []
|
|
|
|
queue = asyncio.Queue()
|
|
for inv in inverter:
|
|
devices.append(Inverter(queue, connection, inv))
|
|
for device in devices:
|
|
asyncio.create_task(device.start())
|
|
|
|
while True:
|
|
item = await queue.get()
|
|
print(item)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|