samil_upload.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:solar 作者: mhvis 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号