klipper
klipper copied to clipboard
Add unixtime pseudo-variable to jinja2 context
Improved version of #5881 (Extend system stats with unixtime), originally proposed by @denis-efimov:
For the moment, it is not possible to make macros based on the host's system time, such as bed leveling once a day or turning things on and off based on real time. Extending system stats with unixtime, we bring the possibilities of macros to a whole new level.
As described this funcionality would be very useful, especially in combination with [save_variables]
to for example track how long you've been using your air filters, without a delayed_gcode
script that's continuously running. Here's a more complex example for a set of nevermore/air filter timer macros I've thrown together and used for the past couple of days.
This PR directly adds unixtime
to the jinja2 context, instead of adding it to the printer
status pseudo-variable, as recommended by @pedrolamas and @Arksine.
Patch has been tested on v0.11.0-86-g6026a99a
. I've also added documentation, including an example for using the variable.