Thought I’d share my dashboard and usecases for what I’ve done with extending the NR flow.
Node Red Flow Extensions
In addition to the published one in my gist, I extended it to FTP to the printer and get the 3mf file of the current print job. From this, it extracts both the print preview image, and the total net weight of filament used for the whole file.
I also have a DB schema setup that stores data for my printers and each print. Hooked up with a metering smart plug, I track the total kwh of the printer, and for each print the initial and later final kwh to calculate the amount used. This is multiplied by the electric rate at print time for the electric cost. It also takes in the amount of filament used, and if the print “FAILED”, it will multiply it by the final print progress %. This isn’t an exact measure but it’s better than nothing. It updates the print record on when running, paused, finished or failed.
Both of these keep using the HA integration palette nodes in NR, as it was the easiest way to get current states and detect state changes. I also have to rely on it 100% for some other printers, such as my MonoX resin printer, since I’m using a semi-broken component in HA for it, and nodered doesn’t have a palette for UART-WiFi.
Grafana Dashboard
The data entered into the DB is then used for my Grafana dashboard. First I have a list of all prints and some useful/calculated metrics. Printer name (selectable above, I also have other printers in here such as a resin printer), print start time, file/print name, duration (if in progress, then duration between start time and now), status (FINISH=Success, FAILED=Failed, RUNNING=In Progress, PAUSED=Paused), Kwh of the print (calculated column of final - initial kwh, but if in progress then current kwh - initial kwh), Electric cost is a generated column of electric rate * kwh of print, and if in progress it uses same calc as kwh, and finally Material used which as I mentioned, is the grams of filament for the print, and if failed, multiplied by progress - which is not always perfect but good enough. Previous prints have 0 grams because I didn’t add that until later.
Additionally, I have a column for print type (filament, resin). This also acts as a config column, which sets the unit of the material used column. Grams if filament, ML if resin.
I hope to expand this further by finding a way to match filament/resin types and costs which I’d need to store and likely manually enter for each, as it would span multiple printers and printer types.
Middle row are just electric costs of the selected printer. First is the total cost of idle time + prints, then there’s the cost of all prints combined in the time period, and finally the idle time costs. Idle time seems high because it’s since I installed the metering smart plug, and had run several prints before storing them in this db.
I have a table with one row each per printer for their lifetime kwh, and just update that for the total/idle costs calculations, which means it doesn’t work well with the timerange in grafana. I find it fine since I don’t care too much for finding my “idle costs” in a given timespan, moreso the “print costs” per timespan which does still work. Saves me from a bunch of db writes.
Final barchart is just the table, displayed as a barchart. I have another below it setup horizontally. That’s just for fun but I prefer the table myself, especially when the amount of records increases.
DB Table for prints for those interested. I have some columns I’m not using yet, but are placeholders for if I use them. Additionally, some columns I have in grafana are calculated in their queries (such as material units) or are from other tables related to my printers, but this is the most important one. It isn’t perfect but works for me!
CREATE TABLE IF NOT EXISTS prints (
id SERIAL,
start_epoch numeric PRIMARY KEY,
printer varchar(25) NOT NULL,
printer_serial varchar(20) NOT NULL,
name varchar(75) NOT NULL,
start_time timestamp DEFAULT (now() at time zone 'utc'),
end_time timestamp,
initial_kwh numeric DEFAULT 0.0,
final_kwh numeric DEFAULT 0.0,
kwh numeric GENERATED ALWAYS AS
(
case WHEN final_kwh = 0.0 THEN 0.0
ELSE final_kwh - initial_kwh
end
) STORED,
status varchar(10),
electric_rate numeric NOT NULL,
electric_cost numeric GENERATED ALWAYS AS (
case WHEN final_kwh = 0.0 THEN 0.0
ELSE ((electric_rate / 100) * (final_kwh - initial_kwh))
end
) STORED,
material_used numeric default 0.0,
material_type varchar(10) default 'filament',
material_price numeric default 0.0,
material_cost numeric GENERATED ALWAYS AS (
material_used * (material_price / 1000)
) STORED,
material_description varchar(50)
);
HomeAssistant Dashboard
And finally, the HA dashboard. It’s pretty much the same as it was last time I shared it. Power, Speed and Light control. AMS preview (still need to put on temp/humidity icon badges on it just realized ), print preview image inside the printer image, dynamic image and icon colour changing based on states, etc.
That’s 80% of everything I wanted out of it, but I can comfortably say that all my needs for monitoring and tracking my usage of the X1C are handled in HomeAssistant. Just need to make it easier to have a camera stream in here, better way to detect filaments (including if not via AMS), and some way to reverse engineer the bambu RFID system (or make my own replacement) then I’ll be (mostly) done