Bugfix for Mqtt enable / disable (was float, uses int now)
This commit is contained in:
parent
3c5082287e
commit
a306bc1351
@ -65,19 +65,23 @@ void MqttHandlePowerLimiterClass::onMqttMessage(const espMqttClientTypes::Messag
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* strlimit = new char[len + 1];
|
char* str = new char[len + 1];
|
||||||
memcpy(strlimit, payload, len);
|
memcpy(str, payload, len);
|
||||||
strlimit[len] = '\0';
|
str[len] = '\0';
|
||||||
float payload_val = strtof(strlimit, NULL);
|
uint8_t payload_val = atoi(str);
|
||||||
delete[] strlimit;
|
delete[] str;
|
||||||
|
|
||||||
if (!strcmp(setting, TOPIC_SUB_POWER_LIMITER)) {
|
if (!strcmp(setting, TOPIC_SUB_POWER_LIMITER)) {
|
||||||
MessageOutput.printf("Disable power limter: %f A\r\n", payload_val);
|
|
||||||
if(payload_val == 1) {
|
if(payload_val == 1) {
|
||||||
|
MessageOutput.println("Power limiter disabled");
|
||||||
PowerLimiter.setDisable(true);
|
PowerLimiter.setDisable(true);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if(payload_val == 0) {
|
if(payload_val == 0) {
|
||||||
|
MessageOutput.println("Power limiter enabled");
|
||||||
PowerLimiter.setDisable(false);
|
PowerLimiter.setDisable(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
MessageOutput.println("Power limiter enable / disable - unknown command received. Please use 0 or 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user