Skip to content

Commit c65db8e

Browse files
committed
- Implemented: Scene/Group, now possible to add same device multiple times, as long as the ondelay is different
- Implemented: Scene/Group devices now supports both on and off delays (off = ondelay + offdelay)
1 parent dd40830 commit c65db8e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

History.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Version 2.0.xxxx (xxxx 2015)
7272
- Changed: Now using OpenZWave security branch
7373
- Changed: Now possible to disable serial hardware when usb port is not available
7474
- Changed: FibaroLink/Datapush, support for V4 firmware
75+
- Implemented: Scene/Group, now possible to add same device multiple times, as long as the ondelay is different
76+
- Implemented: Scene/Group devices now supports both on and off delays (off = ondelay + offdelay)
7577

7678
Version 2.0.2284 (February 22th 2015)
7779
- Fixed: Firefox, RGBW/Setpoint popup

main/WebServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4157,10 +4157,10 @@ namespace http {
41574157
}
41584158
}
41594159
}
4160-
//first check if it is not already a sub device
4160+
//first check if it is not already a part of this scene/group (with the same OnDelay)
41614161
szQuery.clear();
41624162
szQuery.str("");
4163-
szQuery << "SELECT ID FROM SceneDevices WHERE (DeviceRowID=='" << devidx << "') AND (SceneRowID =='" << idx << "')";
4163+
szQuery << "SELECT ID FROM SceneDevices WHERE (DeviceRowID=='" << devidx << "') AND (SceneRowID =='" << idx << "') AND (OnDelay == " << ondelay << ")";
41644164
result = m_sql.query(szQuery.str());
41654165
if (result.size() == 0)
41664166
{

main/mainworker.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9774,7 +9774,7 @@ bool MainWorker::SwitchLight(const unsigned long long idx, const std::string &sw
97749774
{
97759775
if (ExtraDelay != 0)
97769776
{
9777-
_log.Log(LOG_NORM, "Delaying switch [%s] action for %d seconds", result[0][8].c_str(), ExtraDelay);
9777+
_log.Log(LOG_NORM, "Delaying switch [%s] action (%s) for %d seconds", result[0][8].c_str(), switchcmd.c_str(), ExtraDelay);
97789778
}
97799779
m_sql.AddTaskItem(_tTaskItem::SwitchLightEvent(iOnDelay + ExtraDelay, idx, switchcmd, level, hue, "Switch with Delay"));
97809780
return true;
@@ -10167,8 +10167,7 @@ bool MainWorker::SwitchScene(const unsigned long long idx, const std::string &sw
1016710167
std::string offaction="";
1016810168

1016910169
//Get Scene Name
10170-
sprintf(szTmp, "SELECT Name, SceneType, OnAction, OffAction FROM Scenes WHERE (ID == %llu)",
10171-
idx);
10170+
sprintf(szTmp, "SELECT Name, SceneType, OnAction, OffAction FROM Scenes WHERE (ID == %llu)", idx);
1017210171
result=m_sql.query(szTmp);
1017310172
if (result.size()>0)
1017410173
{
@@ -10219,6 +10218,7 @@ bool MainWorker::SwitchScene(const unsigned long long idx, const std::string &sw
1021910218
}
1022010219
}
1022110220

10221+
_log.Log(LOG_NORM, "Activating Scene/Group: %s", Name.c_str());
1022210222

1022310223
//now switch all attached devices, and only the onces that do not trigger a scene
1022410224
std::stringstream szQuery;
@@ -10248,13 +10248,14 @@ bool MainWorker::SwitchScene(const unsigned long long idx, const std::string &sw
1024810248
unsigned char Unit=atoi(sd2[2].c_str());
1024910249
unsigned char dType=atoi(sd2[3].c_str());
1025010250
unsigned char dSubType=atoi(sd2[4].c_str());
10251+
std::string DeviceName = sd2[8];
1025110252
_eSwitchType switchtype=(_eSwitchType)atoi(sd2[5].c_str());
1025210253

1025310254
//Check if this device will not activate a scene
1025410255
int hwID=atoi(sd2[0].c_str());
1025510256
if (DoesDeviceActiveAScene(hwID,sd2[1],Unit,dType,dSubType))
1025610257
{
10257-
_log.Log(LOG_ERROR,"Skipping sensor '%s' because this triggers another scene!",sd2[8].c_str());
10258+
_log.Log(LOG_ERROR, "Skipping sensor '%s' because this triggers another scene!", DeviceName.c_str());
1025810259
continue;
1025910260
}
1026010261

@@ -10276,7 +10277,7 @@ bool MainWorker::SwitchScene(const unsigned long long idx, const std::string &sw
1027610277
else
1027710278
GetLightStatus(dType, dSubType, switchtype,rnValue, sValue, lstatus, llevel, bHaveDimmer, maxDimLevel, bHaveGroupCmd);
1027810279

10279-
_log.Log(LOG_NORM,"Activating Scene/Group: %s (%s)",Name.c_str(),intswitchcmd.c_str());
10280+
_log.Log(LOG_NORM, "Activating Scene/Group Device: %s (%s)", DeviceName.c_str(), intswitchcmd.c_str());
1028010281

1028110282
int ilevel=maxDimLevel-1;
1028210283

@@ -10301,6 +10302,11 @@ bool MainWorker::SwitchScene(const unsigned long long idx, const std::string &sw
1030110302
{
1030210303
int delay = (intswitchcmd == "Off") ? offdelay : ondelay;
1030310304
SwitchLight(idx, intswitchcmd, ilevel, hue, false, delay);
10305+
if ((intswitchcmd != "Off") && (offdelay > 0))
10306+
{
10307+
//switch with on delay, and off delay
10308+
SwitchLight(idx, "Off", ilevel, hue, false, ondelay+offdelay);
10309+
}
1030410310
//SwitchLightInt(sd2,intswitchcmd,ilevel,hue,false);
1030510311
}
1030610312
else

0 commit comments

Comments
 (0)