I am working on setting up octoprint. It is working well, but I have set up octoprint with the prusa slicer thumbnails, so I thought I would try pointing a picture card at the thumbnail and it actually works, kind of:
That shows the image, but the currently printing object isn’t always printed_file it is sensor.octoprint_print_file. And that file has .gcode at the end, instead of .png.
So here is the question, How do I make the image: parameter a template? I don’t see anything about it, and the little thing I tried did not work. (I tried just wrapping it with {{}}).
So, I figured this out a moment after I posted this. Here’s what I’m doing.
I configured a camera with a snapshot url, which can point to a template:
# Testing a camera of the current prusa thumbnail
camera:
- platform: generic
name: "Wanhao Print Thumbnail"
still_image_url: '{{ "http://192.168.1.112/plugin/prusaslicerthumbnails/thumbnail/" + states("sensor.octoprint_print_file").split(".")[0] + ".png" }}'
limit_refetch_to_url_change: true
I configured a picture entity card with the printing status and the camera feed (I might put this into a conditional, but I kind of like seeing it all the time):
Thanks for the guidance. I got MQTT setup and working with my octoprint.
I did have trouble getting the camera to show anything. So I was messing around with the templet editor in the Developer tools and realized that my Prusa Slicer was outputting names with “0.2” or “0.15” based on the layer height. so the .split(".")[0] in the template was cutting off the rest of the filename after the first period.
For example:
File name cube_0.15mm_PETG_1h18m.gcode would become cube_0
However if I changed it to .split(".")[1] it would remove the first period but still remove the “.gcode” rusulting in cube_015mm_PETG_1h18m except it would not match up to the file on my octoprint.
After doing some searching I figured out that I could use the replace function instead of split. That way I could just replace the “gcode” with “png”.
Looks like octoprint plugin changed behaviour, it no longer serves the .png file directly, but instead serves the .bgcode file, which is actually a .png if you download it. Anyway the camera plugin can’t deal with the image format mismatch, so here’s my workaround.
install the MQTT and HA discovery plugins to octoprint
register to MQTT on your HA (you have to copy user + password from HA MQTT config) - this will provide filename info
add shell command to pull the image to your confiuration.yaml. The command will save file with proper .png file type.