Setting works with default values
This commit is contained in:
parent
4bdb82cecc
commit
e95590ffd6
@ -23,10 +23,10 @@ private:
|
|||||||
int mValue = 0; /**< Value of the moist sensor */
|
int mValue = 0; /**< Value of the moist sensor */
|
||||||
|
|
||||||
int mAnalogValue=0; /**< moist sensor values, used for a calculation */
|
int mAnalogValue=0; /**< moist sensor values, used for a calculation */
|
||||||
HomieNode *mPlant = NULL;
|
HomieNode* mPlant = NULL;
|
||||||
PlantSettings_t mSetting;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
PlantSettings_t* mSetting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new Plant object
|
* @brief Construct a new Plant object
|
||||||
@ -77,12 +77,14 @@ public:
|
|||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool isPumpRequired() {
|
bool isPumpRequired() {
|
||||||
return (this->mSetting.pSensorWet != NULL) && (this->mValue < this->mSetting.pSensorWet->get());
|
return (this->mSetting->pSensorWet != NULL) && (this->mValue < this->mSetting->pSensorWet->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
HomieInternals::SendingPromise& setProperty(const String& property) const {
|
HomieInternals::SendingPromise& setProperty(const String& property) const {
|
||||||
return mPlant->setProperty(property);
|
return mPlant->setProperty(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,34 +12,36 @@
|
|||||||
|
|
||||||
#include "PlantCtrl.h"
|
#include "PlantCtrl.h"
|
||||||
|
|
||||||
Plant::Plant(int pinSensor, int pinPump,int plantId, HomieNode *plant, PlantSettings_t* setting) {
|
Plant::Plant(int pinSensor, int pinPump,int plantId, HomieNode* plant, PlantSettings_t* setting) {
|
||||||
this->mPinSensor = pinSensor;
|
this->mPinSensor = pinSensor;
|
||||||
this->mPinPump = pinPump;
|
this->mPinPump = pinPump;
|
||||||
this->mPlant = plant;
|
this->mPlant = plant;
|
||||||
/*
|
this->mSetting = setting;
|
||||||
this->mSetting = mSetting;
|
}
|
||||||
this->mSetting.pSensorDry->setDefaultValue(4095);
|
|
||||||
this->mSetting.pSensorDry->setValidator([] (long candidate) {
|
void Plant::init(void) {
|
||||||
|
this->mSetting->pSensorDry->setDefaultValue(4095);
|
||||||
|
this->mSetting->pSensorDry->setValidator([] (long candidate) {
|
||||||
return ((candidate >= 0) && (candidate <= 4095) );
|
return ((candidate >= 0) && (candidate <= 4095) );
|
||||||
});
|
});
|
||||||
this->mSetting.pSensorWet->setDefaultValue(0);
|
this->mSetting->pSensorWet->setDefaultValue(0);
|
||||||
this->mSetting.pSensorWet->setValidator([] (long candidate) {
|
this->mSetting->pSensorWet->setValidator([] (long candidate) {
|
||||||
return ((candidate >= 0) && (candidate <= 4095) );
|
return ((candidate >= 0) && (candidate <= 4095) );
|
||||||
});
|
});
|
||||||
this->mSetting.pPumpAllowedHourRangeStart->setDefaultValue(8);
|
this->mSetting->pPumpAllowedHourRangeStart->setDefaultValue(8);
|
||||||
this->mSetting.pPumpAllowedHourRangeStart->setValidator([] (long candidate) {
|
this->mSetting->pPumpAllowedHourRangeStart->setValidator([] (long candidate) {
|
||||||
return ((candidate >= 0) && (candidate <= 23) );
|
return ((candidate >= 0) && (candidate <= 23) );
|
||||||
});
|
});
|
||||||
this->mSetting.pPumpAllowedHourRangeEnd->setDefaultValue(20);
|
this->mSetting->pPumpAllowedHourRangeEnd->setDefaultValue(20);
|
||||||
this->mSetting.pPumpAllowedHourRangeEnd->setValidator([] (long candidate) {
|
this->mSetting->pPumpAllowedHourRangeEnd->setValidator([] (long candidate) {
|
||||||
return ((candidate >= 0) && (candidate <= 23) );
|
return ((candidate >= 0) && (candidate <= 23) );
|
||||||
});
|
});
|
||||||
this->mSetting.pPumpOnlyWhenLowLight->setDefaultValue(true);
|
this->mSetting->pPumpOnlyWhenLowLight->setDefaultValue(true);
|
||||||
this->mSetting.pPumpCooldownInHours->setDefaultValue(20);
|
this->mSetting->pPumpCooldownInHours->setDefaultValue(20);
|
||||||
this->mSetting.pPumpCooldownInHours->setValidator([] (long candidate) {
|
this->mSetting->pPumpCooldownInHours->setValidator([] (long candidate) {
|
||||||
return ((candidate >= 0) && (candidate <= 1024) );
|
return ((candidate >= 0) && (candidate <= 1024) );
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plant::addSenseValue(int analog) {
|
void Plant::addSenseValue(int analog) {
|
||||||
|
@ -309,6 +309,11 @@ void readSensors() {
|
|||||||
* Is called once, the controller is started
|
* Is called once, the controller is started
|
||||||
*/
|
*/
|
||||||
void setup() {
|
void setup() {
|
||||||
|
/* Intialize Plant */
|
||||||
|
for(int i=0; i < MAX_PLANTS; i++) {
|
||||||
|
mPlants[i].init();
|
||||||
|
}
|
||||||
|
|
||||||
/* Required to read the temperature once */
|
/* Required to read the temperature once */
|
||||||
float temp[2] = {0, 0};
|
float temp[2] = {0, 0};
|
||||||
float* pFloat = temp;
|
float* pFloat = temp;
|
||||||
|
Loading…
Reference in New Issue
Block a user