DIY Smart Home Automation with ESP32Cam and Moonraker API

Hey everyone, I’m super excited to share a project I’ve been working on to automate my 3D printer with Home Assistant. I’ve always been fascinated by the idea of creating timelapse videos of my prints, and now I’ve finally figured out how to make it happen!

Here’s the deal: I’ve set up an automation that triggers whenever my 3D printer completes a print or goes into an error or paused state. Every 30 seconds, it snaps a photo of the ongoing print and stores it in the Media folder of my ESP32-Cam. Once the print job is finished or has failed, it triggers a shell script to create a timelapse video using all the photos of the print. Talk about showing off to the world!

To make this happen, I became best friends with two key players: the ESP32Cam (using ESPHome) and a Moonraker API (for Klipper firmware). Think of it like a dynamic duo saving the day, but instead of capes, they wear circuit boards and wires. And if you’re a proud owner of a Creality K1, then you’ll definitely need to cozy up to the Moonraker API.

Here’s a quick breakdown of what I did:

Automation Setup

  • Trigger: Monitors the state of my 3D printer sensor.
  • Action: Every 30 seconds, takes a photo and stores it.
  • Condition: Checks if the print has completed or failed.
  • Final Step: Runs a shell script to compile the photos into a timelapse video.

Shell Script Magic
I wrote a shell script that uses ffmpeg to create the timelapse video. It goes through each subdirectory in the Media folder, creates the video, and then deletes the source JPEG files and the directory to keep things tidy.

This project has been a blast to work on, and I’m so proud of how it turned out. It’s not just about the cool timelapse videos—it’s about the satisfaction of bringing all these components together to create something truly awesome. If you’re into DIY projects or 3D printing, I’d love to hear your thoughts or any tips you might have!

Cheers to the amazing Home Assistant community for making this possible! :rocket::sparkles: