-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
The issue im grappling with is the function block receiving the string input from the slider (Temperature setpoint block and deadband block) These are being converted from a number into a string and then passed in to the particle function block.
The function that is being called on the SOM tracker device is as follows:
` int setTempAlarm(String value) {
// Log the received value
Log.info("Received value: ---%s---", value.c_str());
if (value.trim().length() == 0) {
Particle.publish("debug", "Received empty value for Temp Setpoint", PRIVATE);
return -1;
}
// Validate if input is numeric
if (!isValidNumber(value)) {
Particle.publish("debug", "Invalid numeric value for Temp Setpoint", PRIVATE);
return -1;
}
tempAlarmSetpoint = value.toFloat();
Particle.publish("debug", String::format("Temp Setpoint Updated: %.2f", tempAlarmSetpoint), PRIVATE);
return 1;
}
// Helper function to validate numeric strings
bool isValidNumber(const String &str) {
for (int i = 0; i < str.length(); i++) {
if (!isdigit(str[i]) && str[i] != '.' && str[i] != '-') {
return false;
}
}
return true;
}
`
The fault is:
- the value is shown to be "an invalid numeric value for temp setpoint" in the particle console, im unsure if this is a device issue or a node red library issue
- The value passed into the particle function block resets to 0 continuously.
- the function on the device when called from the console works fine, when attempting to write the same value from node red, it sets it to 0.
Metadata
Metadata
Assignees
Labels
No labels