@@ -388,6 +388,29 @@ void COctoPrintMQTT::on_message(const struct mosquitto_message *message)
388
388
int crcID = Crc32 (0 , (const unsigned char *)szSensorName.c_str (), szSensorName.length ());
389
389
SendTempSensor (crcID, 255 , std::stof (root[" actual" ].asString ()), szSensorName);
390
390
}
391
+ else if (szMsgType == " progress" )
392
+ {
393
+ if (strarray.size () < 3 )
394
+ {
395
+ _log.Log (LOG_ERROR, " OCTO_MQTT: Invalid event received!" );
396
+ return ;
397
+ }
398
+ std::string szProgrssName = strarray[2 ];
399
+ if (szProgrssName == " printing" )
400
+ {
401
+ if (root[" progress" ].empty ())
402
+ {
403
+ _log.Log (LOG_ERROR, " OCTO_MQTT: Invalid progress data received! (no progress field in JSON payload ?)" );
404
+ return ;
405
+ }
406
+ SendPercentageSensor (1 , 1 , 255 , std::stof (root[" progress" ].asString ()), " Printing Progress" );
407
+
408
+ // It is possible to enable extended data, this will be in a 'printer_data' object
409
+ // for example:
410
+ // [printer_data][progress][completion] (percetage like 0.008484)
411
+ // [printer_data][progress][printTimeLeft] in seconds
412
+ }
413
+ }
391
414
else if (szMsgType == " event" )
392
415
{
393
416
if (strarray.size () < 3 )
@@ -399,7 +422,18 @@ void COctoPrintMQTT::on_message(const struct mosquitto_message *message)
399
422
400
423
// There are many events, not all of them are handled (or need to be handled)
401
424
// http://docs.octoprint.org/en/devel/events/index.html#available-events
402
-
425
+
426
+ // Ignore the following events
427
+ if (
428
+ (szEventName == " CaptureStart" )
429
+ || (szEventName == " CaptureDone" )
430
+ )
431
+ {
432
+ // we get these every xx seconds
433
+ return ;
434
+ }
435
+
436
+
403
437
UpdateUserVariable (" LastEvent" , szEventName);
404
438
UpdateUserVariable (" LastEventData" , qMessage);
405
439
0 commit comments