see if the relative_humidity and temperature enviroment_metric properties are already being used or 'set'. if not use them for the soil monitor.

This commit is contained in:
Justin E. Mann 2024-12-15 11:14:01 -07:00
parent 544528af93
commit c179d3c36f

View File

@ -87,6 +87,21 @@ bool RAK12035VBSensor::getMetrics(meshtastic_Telemetry *measurement)
LOG_INFO("Successful read from sensor Temperature: %.2f, Moisture: %ld%", (double)(temp/10), moisture);
measurement->variant.environment_metrics.soil_temperature = (float)(temp/10);
measurement->variant.environment_metrics.soil_moisture = moisture;
LOG_INFO("Check if the original temperature and moisture (relative_humidity) are being used.. if not just use them for the soil monitoring.");
if( !measurement->variant.environment_metrics.has_temperature ){
LOG_INFO("Overwrite the temp metrics (not being set right now and this will allow the soil temp value to be used in the client interface).");
measurement->variant.environment_metrics.has_temperature = true;
measurement->variant.environment_metrics.temperature = (float)(temp/10);
}
if( !measurement->variant.environment_metrics.has_relative_humidity ){
LOG_INFO("Overwrite the moisture metrics (not being used for air humidity and this will allow the soil humidity to appear in the client interfaces without adjustments).");
measurement->variant.environment_metrics.has_relative_humidity = true;
measurement->variant.environment_metrics.relative_humidity = (float)moisture;
}
return true;
}
#endif