MQTT: fix text object format

This commit is contained in:
Marcel Walter 2026-01-20 01:11:47 +01:00
parent c8ab79839d
commit 0263908e67

View File

@ -264,6 +264,8 @@ void loop()
mqtt.publish(FLIPDOT_AVAILABILITY_TOPIC, "available");
publishHomeAssistantDiscovery();
publishClose();
}
}
}
@ -450,25 +452,6 @@ void mqttCallback(char *topic, unsigned char *message, unsigned int length)
if (ToppicString == FLIPDOT_TEXT_TOPIC)
{
Serial.println("Text topic received: " + MessageString);
JsonDocument doc;
if (deserializeJson(doc, (const char *)message, length) == DeserializationError::Ok)
{
MessageString = doc["value"] | String("none"); // the pipe operand tells the default value, if "value" is not existing
if ((MessageString != "none"))
{
printText(MessageString);
}
else
{
Serial.print(FLIPDOT_TEXT_TOPIC);
Serial.println(" has no [\"value\"]!");
}
}
else
{
Serial.print(FLIPDOT_TEXT_TOPIC);
Serial.println(" is no json!");
}
printText(MessageString);
}
}