我正在执行此脚本来检查我的 OctoPrint(3d 打印机)是否正在冷却。
通过使用
#octocmd status
temps:
bed: actual=26.0, target=0.0, offset=0
tool0: actual=54.9, target=55.0, offset=0
i will get a data like this.
我可以检查它是否正在打印,因为我在 bash 脚本中已经这样做了
/usr/local/bin/octocmd status | grep 'target=200.0, offset=0'
if [ $? == 0 ]; # if target 200; enter if
then
echo "Printing in progress, Script will check back in 5 minutes"
/usr/local/bin/octocmd status
sleep 5m
在冷却期间我应该看到
tool0: actual=189.3(decreasing), target=0.0, offset=0
但是我一直在尝试使用我的ELSE功能来检查它是否正在冷却。让我们说
actual= (**range from 40.0 to 180**), target=0.0, offset=0
所以我想谦虚地寻求有关如何从实际=XXX中检测任何数据范围的帮助
这是我目前的代码:
while [ 1 ]
do
/usr/local/bin/octocmd status | grep 'target=200.0, offset=0' &> /dev/null # grab string $ remove error
if [ $? == 0 ]; # if target 200; enter if
then
echo "Printing in progress, Script will check back in 5 minutes"
/usr/local/bin/octocmd status
sleep 5m # check every 5 minutes
elif [ -z "/usr/local/bin/octocmd status | /*CHECK IF PRINTER IS COOLING DOWN OR NOT, CHECK ACTUAL=30 ~ 180 */"' 2>&1 /dev/null ];
then
if [ $? == 0 ];
then
#enter here if target is cooled with no print job
/usr/local/bin/octocmd status
fi
done