MQTT: fix text object format
This commit is contained in:
parent
c8ab79839d
commit
0263908e67
23
src/main.cpp
23
src/main.cpp
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user