Fix remaining mqtt calculation

This commit is contained in:
Empire 2023-06-04 19:21:53 +02:00
parent 6cb446735d
commit 85bcbd166c

View File

@ -1094,10 +1094,14 @@ void plantcontrol()
if (waterRawSensor.getCount() > 0)
{
float remaining = (waterLevelMax.get() - waterRawSensor.getAverage());
float actualDifference = waterLevelMax.get() - waterLevelMin.get();
float ratio = remaining/actualDifference;
sensorWater.setProperty("useable").send(String(actualDifference));
if (!isnan(remaining))
{
/* measuring the distance from top -> smaller value means more water: */
sensorWater.setProperty("remaining").send(String(100.0 - (remaining/100)));
sensorWater.setProperty("remaining").send(String(ratio*100));
}
if (!isnan(waterRawSensor.getAverage()))
{