28 lines
728 B
Python
28 lines
728 B
Python
import asyncio
|
|
|
|
from InverterData import InverterData
|
|
|
|
|
|
class Inverter:
|
|
def __init__(self, queue: asyncio.Queue, cloud_connection, inverter_id):
|
|
self._queue = queue
|
|
self.inverter_id = inverter_id
|
|
self.cloud_connection = cloud_connection
|
|
self.gather_data = False
|
|
|
|
async def start(self):
|
|
self.gather_data = True
|
|
await self.gather()
|
|
|
|
async def gather(self):
|
|
while self.gather_data:
|
|
realtime_data: dict = self.cloud_connection.get_realtime_data(self.inverter_id)
|
|
data = InverterData(
|
|
self.inverter_id,
|
|
realtime_data
|
|
)
|
|
await self._queue.put(data)
|
|
await asyncio.sleep(60)
|
|
|
|
|