def upload(pv, inverters, scheduler, timestamp, boundary):
"""Retrieves and uploads inverter data, and schedules the next upload."""
values = [inverter.request_values() for inverter in inverters]
# Filter systems with normal operating mode
values = [val for val in values if val['operating_mode'] == 'normal']
if values:
data = {
'd': time.strftime('%Y%m%d'),
't': time.strftime('%H:%M'),
'v1': round(sum(value['energy_today'] for value in values) * 1000),
'v2': sum(value['output_power'] for value in values),
'v5': sum(value['internal_temp'] for value in values) / len(values),
'v6': sum(value['grid_voltage'] for value in values) / len(values)
}
logger.info('Uploading: %s', data)
pv.add_status(data)
else:
logger.info('Not uploading, no inverter has operating mode normal')
sched_args = (pv, inverters, scheduler, timestamp + boundary, boundary)
scheduler.enterabs(timestamp + boundary, 1, upload, sched_args)
评论列表
文章目录