fixed wrong percent calculation, emit trigger value to mqtt

This commit is contained in:
Your Name 2021-08-17 16:55:52 +02:00
parent 2e052710e2
commit 61098724b6
2 changed files with 4 additions and 2 deletions

View File

@ -92,8 +92,9 @@ public:
{
if (this->mSetting->pSensorDry != NULL)
{
float percent = (this->mSetting->pSensorDry->get());
return (((MOIST_SENSOR_MAX_FRQ - MOIST_SENSOR_MIN_FRQ) * percent) + MOIST_SENSOR_MIN_FRQ);
//1 is totally wet, 0 is try, 0 is MOIST_SENSOR_MAX_FRQ, 1 is MOIST_SENSOR_MIN_FRQ
float factor = (this->mSetting->pSensorDry->get());
return map(factor,0,100,MOIST_SENSOR_MAX_FRQ,MOIST_SENSOR_MIN_FRQ);
}
else
{

View File

@ -120,6 +120,7 @@ void Plant::postMQTTconnection(void)
this->mPlant->setProperty("moist").send(String(round(pct*10)/10));
this->mPlant->setProperty("moistraw").send(String(raw));
this->mPlant->setProperty("moisttrigger").send(String(getSetting2Moisture()));
}