def run(emparts, config):
    global pv_debug
    global pv_last_update
    global pv_data

    # Only update every X seconds
    if time.time() < pv_last_update + int(config.get('min_update', 20)):
        if (pv_debug > 1):
            print("pv: data skipping")
        return

    pv_last_update = time.time()
    registers = eval(config.get('registers'))

    pv_data = []
    for inv in eval(config.get('inverters')):
        host, port, modbusid, manufacturer = inv

        device_class = get_device_class(host, int(port), int(modbusid))
        if device_class == "Solar Inverter":
            relevant_registers = eval(config.get('registers'))
            mdata = get_pv_data(host, int(port), int(modbusid), relevant_registers)
            pv_data.append(mdata)
        elif device_class == "Battery Inverter":
            relevant_registers = eval(config.get('registers_batt'))
            mdata = get_pv_data(host, int(port), int(modbusid), relevant_registers)
            pv_data.append(mdata)
        else:
            if (pv_debug > 1):
                print("pv: unknown device class; skipping")
            pass

    # query
    if pv_data is None:
        if pv_debug > 0:
            print("PV: no data")
        return

    timestamp = time.time()
    for i in pv_data:
        i['timestamp'] = timestamp
        if pv_debug > 0:
            print("PV:" + format(i))