@@ -10992,13 +10992,13 @@ bool MainWorker::SwitchLight(const unsigned long long idx, const std::string &sw
10992
10992
{
10993
10993
// Get Device details
10994
10994
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)" ,
10997
10997
idx);
10998
- if (result.size ()< 1 )
10998
+ if (result.size () < 1 )
10999
10999
return false ;
11000
11000
11001
- std::vector<std::string> sd= result[0 ];
11001
+ std::vector<std::string> sd = result[0 ];
11002
11002
11003
11003
// unsigned char dType = atoi(sd[3].c_str());
11004
11004
// unsigned char dSubType = atoi(sd[4].c_str());
@@ -11015,27 +11015,23 @@ bool MainWorker::SwitchLight(const unsigned long long idx, const std::string &sw
11015
11015
int nNewVal = bIsOn ? 1 : 0 ;// Is that everything we need here
11016
11016
if ((switchtype == STYPE_Selector) && (nValue == nNewVal) && (level == atoi (sValue .c_str ()))) {
11017
11017
return true ;
11018
- } else if (nValue == nNewVal) {
11018
+ }
11019
+ else if (nValue == nNewVal) {
11019
11020
return true ;// FIXME no return code for already set
11020
11021
}
11021
11022
}
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)
11029
11025
{
11030
11026
if (ExtraDelay != 0 )
11031
11027
{
11032
11028
_log.Log (LOG_NORM, " Delaying switch [%s] action (%s) for %d seconds" , devName.c_str (), switchcmd.c_str (), ExtraDelay);
11033
11029
}
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" ));
11035
11031
return true ;
11036
11032
}
11037
11033
else
11038
- return SwitchLightInt (sd,switchcmd,level,hue,false );
11034
+ return SwitchLightInt (sd, switchcmd, level, hue, false );
11039
11035
}
11040
11036
11041
11037
bool MainWorker::SetSetPoint (const std::string &idx, const float TempValue, const int newMode, const std::string &until)
0 commit comments