blob: e598e7dff097c18254cb5bcbeb05b95eb0f57415 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# printstats
A printer monitoring service that aggregates status from multiple 3D printers (Prusa and Bambu) and exposes them through a unified HTTP API.
## Features
- Monitor Prusa and Bambu 3D printers simultaneously
- Prusa: polls via HTTP REST API every 5 seconds
- Bambu: real-time updates via MQTT subscription
- Unified JSON endpoint for all printer states
- Tracks bed temperature and print status per printer
## Prerequisites
- Rust
- Network connectivity to your printers
## Setup
1. Copy the example config and fill in your printer details:
```sh
cp example_config.toml config.toml
```
2. Edit `config.toml`:
```toml
[[printers]]
type = "prusa"
name = "MyPrusa"
host = "192.168.1.10"
api_key = "your-api-key"
[[printers]]
type = "bambu"
name = "MyBambu"
host = "192.168.1.11"
access_code = "12345678"
serial_number = "ABCDEFGH"
```
## Build & Run
```sh
cargo build --release
./target/release/printstats
```
Or directly:
```sh
cargo run
```
The server listens on `0.0.0.0:3000`.
## API
### `GET /`
Returns the current state of all configured printers.
**Response:**
```json
{
"MyPrusa": {
"bed_temp": 60.0,
"status": "Printing"
},
"MyBambu": {
"bed_temp": 0.0,
"status": "Idle"
}
}
```
**Status values:** `Idle`, `Printing`, `Paused`, `Finished`, `Unknown`
## Logging
Uses the `tracing` crate. Control log level via `RUST_LOG`:
```sh
RUST_LOG=debug cargo run
```
## License
MIT
|