Skip to content

Commit 78ceba9

Browse files
committed
Added Printing progress sensor (non-extended)
Ignoring Capture Start/Done Changing some diacritics characters
1 parent 65c3ec4 commit 78ceba9

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

hardware/OctoPrintMQTT.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,29 @@ void COctoPrintMQTT::on_message(const struct mosquitto_message *message)
388388
int crcID = Crc32(0, (const unsigned char*)szSensorName.c_str(), szSensorName.length());
389389
SendTempSensor(crcID, 255, std::stof(root["actual"].asString()), szSensorName);
390390
}
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+
}
391414
else if (szMsgType == "event")
392415
{
393416
if (strarray.size() < 3)
@@ -399,7 +422,18 @@ void COctoPrintMQTT::on_message(const struct mosquitto_message *message)
399422

400423
//There are many events, not all of them are handled (or need to be handled)
401424
//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+
403437
UpdateUserVariable("LastEvent", szEventName);
404438
UpdateUserVariable("LastEventData", qMessage);
405439

main/RFXNames.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static const STR_TABLE_SINGLE HardwareTypeTable[] =
278278
{ HTYPE_DenkoviHTTPDevices, "Denkovi Modules with LAN (HTTP) Interface", "Denkovi" },
279279
{ HTYPE_DenkoviUSBDevices, "Denkovi Modules with USB Interface", "Denkovi" },
280280
{ HTYPE_DenkoviTCPDevices, "Denkovi Modules with LAN (TCP) Interface", "Denkovi" },
281-
{ HTYPE_OctoPrint, "OctoPrint (MQTT/Gina Häußge) with LAN interface", "OctoPrint" },
281+
{ HTYPE_OctoPrint, "OctoPrint (MQTT/Gina Haussge) with LAN interface", "OctoPrint" },
282282
{ 0, NULL, NULL }
283283
};
284284

0 commit comments

Comments
 (0)