Hi I can't for the life of me understand why i can't send non-boolean values to mqtt (which is connected to node-red). It seems to get stuck on message
//relevant code
void callback(char* topic, byte* message, unsigned int length) {
Serial.print("Message arrived on topic: ");
Serial.print(topic);
Serial.print(". Message: ");
String messageLading;
for (int i = 0; i < length; i++) {
Serial.print((char)message[i]);
messageLading += (char)message[i];
}
Serial.println();
// Feel free to add more if statements to control more GPIOs with MQTT
// If a message is received on the topic esp32/output, you check if the message is either "on" or "off".
// Changes the output state according to the message
if (String(topic) == "ladestasjon/output") {
Serial.print("Changing output to ");
if (messageLading == "charge") {
Serial.println("on");
ladBil=true;
}
else if (messageLading == "stop") {
Serial.println("off");
ladBil=false;
}
if (String(topic) == "ladestasjon/BatteriProsent"){
Serial.print(message);
}
}
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("ESP8266Client")) {
Serial.println("connected");
// Subscribe
client.subscribe("ladestasjon/output");
client.subscribe("ladestasjon/BatteriProsent")
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}