status_on_delay=((int)(res.value))&&(found->second.on_counter>=1)&&((ts.tv_sec-found->second.on_delay)>found->second.ts_on_delay.tv_sec);//formula gives true and on delay has passed
status_on_delay=((bool)(res.value!=0))&&(found->second.on_counter>=1)&&((ts.tv_sec-found->second.on_delay)>found->second.ts_on_delay.tv_sec);//formula gives true and on delay has passed
else
else
status_on_delay=(int)(res.value);
status_on_delay=(bool)(res.value!=0);
boolstatus_off_delay;
boolstatus_off_delay;
if(found->second.off_delay>0)//if enabled off delay
if(found->second.off_delay>0)//if enabled off delay
status_off_delay=(!(int)(res.value))&&(found->second.off_counter>=1)&&((ts.tv_sec-found->second.off_delay)>found->second.ts_off_delay.tv_sec);//formula gives false and off delay has passed
status_off_delay=(!(bool)(res.value!=0))&&(found->second.off_counter>=1)&&((ts.tv_sec-found->second.off_delay)>found->second.ts_off_delay.tv_sec);//formula gives false and off delay has passed
else
else
status_off_delay=!(int)(res.value);
status_off_delay=!(bool)(res.value!=0);
//if status changed:
//if status changed:
// - from S_NORMAL to S_ALARM considering also on delay
// - from S_NORMAL to S_ALARM considering also on delay