Skip to content

Commit 077b726

Browse files
committed
Fixed on-delay caused by #540
1 parent 3130869 commit 077b726

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

main/mainworker.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10992,13 +10992,13 @@ bool MainWorker::SwitchLight(const unsigned long long idx, const std::string &sw
1099210992
{
1099310993
//Get Device details
1099410994
std::vector<std::vector<std::string> > result;
10995-
result=m_sql.safe_query(
10996-
"SELECT HardwareID,DeviceID,Unit,Type,SubType,SwitchType,AddjValue,nValue,sValue,Name,Options FROM DeviceStatus WHERE (ID == %llu)",
10995+
result = m_sql.safe_query(
10996+
"SELECT HardwareID,DeviceID,Unit,Type,SubType,SwitchType,AddjValue2,nValue,sValue,Name,Options FROM DeviceStatus WHERE (ID == %llu)",
1099710997
idx);
10998-
if (result.size()<1)
10998+
if (result.size() < 1)
1099910999
return false;
1100011000

11001-
std::vector<std::string> sd=result[0];
11001+
std::vector<std::string> sd = result[0];
1100211002

1100311003
//unsigned char dType = atoi(sd[3].c_str());
1100411004
//unsigned char dSubType = atoi(sd[4].c_str());
@@ -11015,27 +11015,23 @@ bool MainWorker::SwitchLight(const unsigned long long idx, const std::string &sw
1101511015
int nNewVal = bIsOn ? 1 : 0;//Is that everything we need here
1101611016
if ((switchtype == STYPE_Selector) && (nValue == nNewVal) && (level == atoi(sValue.c_str()))) {
1101711017
return true;
11018-
} else if (nValue == nNewVal) {
11018+
}
11019+
else if (nValue == nNewVal) {
1101911020
return true;//FIXME no return code for already set
1102011021
}
1102111022
}
11022-
if (switchtype == STYPE_Selector) {
11023-
bIsOn = (level > 0) ? true : false;
11024-
}
11025-
int iDelay = bIsOn ? iOnDelay : 0;
11026-
11027-
//Check if we have an OnDelay, if yes, add it to the tasker
11028-
if ((iDelay != 0) || ExtraDelay)
11023+
//Check if we have an On-Delay, if yes, add it to the tasker
11024+
if (((bIsOn) && (iOnDelay != 0)) || ExtraDelay)
1102911025
{
1103011026
if (ExtraDelay != 0)
1103111027
{
1103211028
_log.Log(LOG_NORM, "Delaying switch [%s] action (%s) for %d seconds", devName.c_str(), switchcmd.c_str(), ExtraDelay);
1103311029
}
11034-
m_sql.AddTaskItem(_tTaskItem::SwitchLightEvent(iDelay + ExtraDelay, idx, switchcmd, level, hue, "Switch with Delay"));
11030+
m_sql.AddTaskItem(_tTaskItem::SwitchLightEvent(iOnDelay + ExtraDelay, idx, switchcmd, level, hue, "Switch with Delay"));
1103511031
return true;
1103611032
}
1103711033
else
11038-
return SwitchLightInt(sd,switchcmd,level,hue,false);
11034+
return SwitchLightInt(sd, switchcmd, level, hue, false);
1103911035
}
1104011036

1104111037
bool MainWorker::SetSetPoint(const std::string &idx, const float TempValue, const int newMode, const std::string &until)

0 commit comments

Comments
 (0)