Fix remaining mqtt calculation
This commit is contained in:
parent
6cb446735d
commit
85bcbd166c
@ -1094,10 +1094,14 @@ void plantcontrol()
|
|||||||
if (waterRawSensor.getCount() > 0)
|
if (waterRawSensor.getCount() > 0)
|
||||||
{
|
{
|
||||||
float remaining = (waterLevelMax.get() - waterRawSensor.getAverage());
|
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))
|
if (!isnan(remaining))
|
||||||
{
|
{
|
||||||
/* measuring the distance from top -> smaller value means more water: */
|
/* 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()))
|
if (!isnan(waterRawSensor.getAverage()))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user