davglass / bambu-cli Goto Github PK
View Code? Open in Web Editor NEWCLI tool for Bambu Labs printers
CLI tool for Bambu Labs printers
Brand new install using npm -g i bambu-cli
C:\Users\larry\AppData\Roaming\npm\node_modules\bambu-cli\bin\cli.js:114
if (!args.id && machines.length === 1) {
^
TypeError: Cannot read properties of undefined (reading 'length')
at Object.<anonymous> (C:\Users\larry\AppData\Roaming\npm\node_modules\bambu-cli\bin\cli.js:114:26)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49
Node.js v20.13.1
Hi!
When I try to log in it never asks me for the 2FA code I have set up in my account.
I had to edit the "getTokens" function in the "login.js" file to make it ask me for the code so I can use the CLI. I would like to be able to open a PR with the modified changes, but given the structure of the project I don't know how to approach it in the best way.
I leave you the piece of code I made:
// (in line 10)
const TFA = 'https://bambulab.com/api/sign-in/tfa';
// (in line 138)
if (code === 200) {
res.on('data', d => {
const json = JSON.parse(d);
logger.debug(`JSON`, JSON.stringify(json, null, 4));
if (json.tfaKey) {
const tfa = rl.question(`[bambulab.com] 2FA code: `);
const tfaPayload = JSON.stringify({ tfaKey: json.tfaKey, tfaCode: tfa });
const tfaEndpoint = parse(TFA);
tfaEndpoint.method = 'POST';
tfaEndpoint.headers = {
'content-type': 'application/json',
'content-length': tfaPayload.length
};
const tfaReq = https.request(tfaEndpoint, (tfaRes) => {
...
});
tfaReq.write(tfaPayload);
tfaReq.end();
}
});
}
Logging in as: [email protected]
Fetching devices from their API.
Found 2 devices.
Device One
Device Two
Attempting to find device IP addresses, please wait, this may take a few seconds..
Found IP for Device-One: null
Response from /v1/iot-service/api/user/bind
"devices": [
{
"dev_id": "",
"name": "A1 Mini",
"online": true,
"print_status": "SUCCESS",
"dev_model_name": "N1",
"dev_product_name": "A1 mini",
"dev_access_code": "",
"nozzle_diameter": 0.4
},
{
"dev_id": "",
"name": "X1C",
"online": true,
"print_status": "FAIL",
"dev_model_name": "BL-P001",
"dev_product_name": "X1 Carbon",
"dev_access_code": "",
"nozzle_diameter": 0.4
}
]
Nice work! I love it!
i have a A1 Mini with AMS Lite - but at the status overview, the script stop working at this point:
`root@BambuClient:~/.config/bambu-cli# bambu-cli status speedy
Showing only, xxxx
Checking connectivity for 1 machine(s)
ID Name IP Address FTP MQTT AMS Nozzle Printing Task Percent Remaining Speed
xxxx Speedy 192.168.178.140 โ โ A RUNNING Brio Schiene Duplo k ... 30% 58m Normal
Model Machine firm
A1 mini 01.07.21.46
/usr/lib/node_modules/bambu-cli/lib/status.js:146
if (tray.cols.length > 1) { //Mulicolor
^
TypeError: Cannot read properties of undefined (reading 'length')
at /usr/lib/node_modules/bambu-cli/lib/status.js:146:31
at Array.forEach ()
at /usr/lib/node_modules/bambu-cli/lib/status.js:127:19
at Array.forEach ()
at showDetails (/usr/lib/node_modules/bambu-cli/lib/status.js:122:13)
at /usr/lib/node_modules/bambu-cli/lib/status.js:75:17
at statusMQTT (/usr/lib/node_modules/bambu-cli/lib/status.js:276:9)
at MqttClient. (/usr/lib/node_modules/bambu-cli/lib/status.js:271:17)
at MqttClient.emit (node:events:514:28)
at handlePublish (/usr/lib/node_modules/bambu-cli/node_modules/mqtt/build/lib/handlers/publish.js:97:20)
at handle (/usr/lib/node_modules/bambu-cli/node_modules/mqtt/build/lib/handlers/index.js:28:35)
at work (/usr/lib/node_modules/bambu-cli/node_modules/mqtt/build/lib/client.js:216:40)
at writable._write (/usr/lib/node_modules/bambu-cli/node_modules/mqtt/build/lib/client.js:241:13)
at writeOrBuffer (/usr/lib/node_modules/bambu-cli/node_modules/readable-stream/lib/internal/streams/writable.js:334:12)
at _write (/usr/lib/node_modules/bambu-cli/node_modules/readable-stream/lib/internal/streams/writable.js:283:10)
at Writable.write (/usr/lib/node_modules/bambu-cli/node_modules/readable-stream/lib/internal/streams/writable.js:286:10)
Node.js v20.10.0
root@BambuClient:~/.config/bambu-cli#`
Hello,
I built a fresh VM on AlmaLinux 9.3, installed Docker in preparation for bambu-farm, installed NodeJS 20. When I attempt to log in, I get the following:
[dge@farmstand ~]$ bambu-cli login
/usr/local/lib/node_modules/bambu-cli/bin/cli.js:114
if (!args.id && machines.length === 1) {
^
TypeError: Cannot read properties of undefined (reading 'length')
at Object. (/usr/local/lib/node_modules/bambu-cli/bin/cli.js:114:26)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.9.0
[dge@farmstand ~]$
The same error occurs with bambu-cli status and bambu-cli ls
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.