Handle cooldown time for watering; add start and end time when pumping is allowed

This commit is contained in:
Ollo
2021-04-07 21:26:11 +02:00
parent 3932e82593
commit 47aba5387b
3 changed files with 52 additions and 33 deletions
+18 -15
View File
@@ -98,23 +98,26 @@ public:
void init(void);
/** @fn bool isInCooldown(long sinceLastActivation)
* @brief determine, if the plant was recently casted
* @param sinceLastActivation timestamp of last time
*/
bool isInCooldown(long sinceLastActivation)
{
/* if the time difference is greater than one month, we know these are initial values */
if (sinceLastActivation > (60 * 60 * 24 * 30))
{
return false;
}
return (getCooldownInSeconds() > sinceLastActivation);
long getCooldownInSeconds() {
return this->mSetting->pPumpCooldownInHours->get()*60*60;
}
long getCooldownInSeconds(){
return this->mSetting->pPumpCooldownInHours->get()*60*60;
/**
* @brief Get the Hours when pumping should start
*
* @return hour
*/
int getHoursStart() {
return this->mSetting->pPumpAllowedHourRangeStart->get();
}
/**
* @brief Get the Hours when pumping should end
*
* @return hour
*/
int getHoursEnd() {
return this->mSetting->pPumpAllowedHourRangeEnd->get();
}
bool isAllowedOnlyAtLowLight(void)