Skip to content

Commit a6ed214

Browse files
committed
Merge pull request #14 from domoticz/master
Update from original
2 parents e4ff8f6 + bb2f15a commit a6ed214

27 files changed

+50
-48
lines changed

History.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Version 2.xxx (xxxx 2015)
102102
- Implemented: Option to hide scenes/groups (placing a $ in front of the name)
103103
- Implemented: Scene codes now handles again seperate status (on/off)
104104
- Implemented: RFXtrx ASA protocol implemented
105+
- Implemented: Scene, option for 'stop'
105106

106107
Version 2.2563 (June 14th 2015)
107108
- Implemented: WebServer, native SSL and keep-alive, big thanks to chimit!!!!

main/SQLHelper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,8 +4922,8 @@ void CSQLHelper::DeleteHardware(const std::string &idx)
49224922
{
49234923
std::vector<std::vector<std::string> > result;
49244924
result=safe_query("DELETE FROM Hardware WHERE (ID == '%q')",idx.c_str());
4925-
//also delete all records in other tables
49264925

4926+
//and now delete all records in the DeviceStatus table itself
49274927
result=safe_query("SELECT ID FROM DeviceStatus WHERE (HardwareID == '%q')",idx.c_str());
49284928
if (result.size()>0)
49294929
{
@@ -4934,11 +4934,11 @@ void CSQLHelper::DeleteHardware(const std::string &idx)
49344934
DeleteDevice(sd[0]);
49354935
}
49364936
}
4937-
//and now delete all records in the DeviceStatus table itself
4938-
safe_query("DELETE FROM DeviceStatus WHERE (HardwareID == '%q')",idx.c_str());
4937+
//also delete all records in other tables
49394938
safe_query("DELETE FROM ZWaveNodes WHERE (HardwareID== '%q')",idx.c_str());
49404939
safe_query("DELETE FROM EnoceanSensors WHERE (HardwareID== '%q')", idx.c_str());
49414940
safe_query("DELETE FROM MySensors WHERE (HardwareID== '%q')", idx.c_str());
4941+
safe_query("DELETE FROM WOLNodes WHERE (HardwareID == '%q')",idx.c_str());
49424942
}
49434943

49444944
void CSQLHelper::DeleteCamera(const std::string &idx)

main/WebServer.cpp

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,7 @@ namespace http {
26972697
std::string idx = m_pWebEm->FindValue("idx");
26982698
std::string devidx = m_pWebEm->FindValue("devidx");
26992699
std::string isscene = m_pWebEm->FindValue("isscene");
2700-
int command = atoi(m_pWebEm->FindValue("command").c_str());
2700+
std::string scommand = m_pWebEm->FindValue("command");
27012701
int ondelay = atoi(m_pWebEm->FindValue("ondelay").c_str());
27022702
int offdelay = atoi(m_pWebEm->FindValue("offdelay").c_str());
27032703

@@ -2710,7 +2710,16 @@ namespace http {
27102710
int level = atoi(m_pWebEm->FindValue("level").c_str());
27112711
int hue = atoi(m_pWebEm->FindValue("hue").c_str());
27122712

2713-
std::string rState = (command == 1) ? "On" : "Off";
2713+
unsigned char command=0;
2714+
result = m_sql.safe_query("SELECT HardwareID, DeviceID, Unit, Type, SubType, SwitchType FROM DeviceStatus WHERE (ID=='%q')",
2715+
devidx.c_str());
2716+
if (result.size() > 0)
2717+
{
2718+
int dType = atoi(result[0][3].c_str());
2719+
int sType = atoi(result[0][4].c_str());
2720+
_eSwitchType switchtype = (_eSwitchType)atoi(result[0][5].c_str());
2721+
GetLightCommand(dType, sType, switchtype, scommand, command);
2722+
}
27142723

27152724
//first check if this device is not the scene code!
27162725
result = m_sql.safe_query("SELECT Activators, SceneType FROM Scenes WHERE (ID=='%q')", idx.c_str());
@@ -2742,8 +2751,14 @@ namespace http {
27422751
}
27432752
}
27442753
//first check if it is not already a part of this scene/group (with the same OnDelay)
2745-
result = m_sql.safe_query("SELECT ID FROM SceneDevices WHERE (DeviceRowID=='%q') AND (SceneRowID =='%q') AND (OnDelay == %d)",
2746-
devidx.c_str(), idx.c_str(), ondelay);
2754+
if (isscene == "true") {
2755+
result = m_sql.safe_query("SELECT ID FROM SceneDevices WHERE (DeviceRowID=='%q') AND (SceneRowID =='%q') AND (OnDelay == %d) AND (OffDelay == %d) AND (Cmd == %d)",
2756+
devidx.c_str(), idx.c_str(), ondelay, offdelay, command);
2757+
}
2758+
else {
2759+
result = m_sql.safe_query("SELECT ID FROM SceneDevices WHERE (DeviceRowID=='%q') AND (SceneRowID =='%q') AND (OnDelay == %d)",
2760+
devidx.c_str(), idx.c_str(), ondelay);
2761+
}
27472762
if (result.size() == 0)
27482763
{
27492764
root["status"] = "OK";
@@ -2780,7 +2795,7 @@ namespace http {
27802795
{
27812796
std::string idx = m_pWebEm->FindValue("idx");
27822797
std::string devidx = m_pWebEm->FindValue("devidx");
2783-
int command = atoi(m_pWebEm->FindValue("command").c_str());
2798+
std::string scommand = m_pWebEm->FindValue("command");
27842799
int ondelay = atoi(m_pWebEm->FindValue("ondelay").c_str());
27852800
int offdelay = atoi(m_pWebEm->FindValue("offdelay").c_str());
27862801

@@ -2790,21 +2805,16 @@ namespace http {
27902805
)
27912806
return;
27922807

2793-
std::string rState = (command == 1) ? "On" : "Off";
2808+
unsigned char command = 0;
27942809

2795-
//first check if this device is not the scene code!
27962810
result = m_sql.safe_query("SELECT HardwareID, DeviceID, Unit, Type, SubType, SwitchType FROM DeviceStatus WHERE (ID=='%q')",
27972811
devidx.c_str());
27982812
if (result.size() > 0)
27992813
{
28002814
int dType = atoi(result[0][3].c_str());
28012815
int sType = atoi(result[0][4].c_str());
28022816
_eSwitchType switchtype = (_eSwitchType)atoi(result[0][5].c_str());
2803-
unsigned char scommand;
2804-
if (GetLightCommand(dType, sType, switchtype, rState, scommand))
2805-
{
2806-
command = scommand;
2807-
}
2817+
GetLightCommand(dType, sType, switchtype, scommand, command);
28082818
}
28092819
int level = atoi(m_pWebEm->FindValue("level").c_str());
28102820
int hue = atoi(m_pWebEm->FindValue("hue").c_str());
@@ -2948,7 +2958,7 @@ namespace http {
29482958
root["title"] = "GetSceneDevices";
29492959

29502960
std::vector<std::vector<std::string> > result;
2951-
result = m_sql.safe_query("SELECT a.ID, b.Name, a.DeviceRowID, b.Type, b.SubType, b.nValue, b.sValue, a.Cmd, a.Level, b.ID, a.[Order], a.Hue, a.OnDelay, a.OffDelay FROM SceneDevices a, DeviceStatus b WHERE (a.SceneRowID=='%q') AND (b.ID == a.DeviceRowID) ORDER BY a.[Order]",
2961+
result = m_sql.safe_query("SELECT a.ID, b.Name, a.DeviceRowID, b.Type, b.SubType, b.nValue, b.sValue, a.Cmd, a.Level, b.ID, a.[Order], a.Hue, a.OnDelay, a.OffDelay, b.SwitchType FROM SceneDevices a, DeviceStatus b WHERE (a.SceneRowID=='%q') AND (b.ID == a.DeviceRowID) ORDER BY a.[Order]",
29522962
idx.c_str());
29532963
if (result.size() > 0)
29542964
{
@@ -2966,6 +2976,8 @@ namespace http {
29662976
root["result"][ii]["OnDelay"] = atoi(sd[12].c_str());
29672977
root["result"][ii]["OffDelay"] = atoi(sd[13].c_str());
29682978

2979+
_eSwitchType switchtype=(_eSwitchType)atoi(sd[14].c_str());
2980+
29692981
unsigned char devType = atoi(sd[3].c_str());
29702982
unsigned char subType = atoi(sd[4].c_str());
29712983
unsigned char nValue = (unsigned char)atoi(sd[5].c_str());
@@ -2978,11 +2990,8 @@ namespace http {
29782990
bool bHaveDimmer = false;
29792991
bool bHaveGroupCmd = false;
29802992
int maxDimLevel = 0;
2981-
if (isscene == "true")
2982-
GetLightStatus(devType, subType, STYPE_OnOff, command, sValue, lstatus, llevel, bHaveDimmer, maxDimLevel, bHaveGroupCmd);
2983-
else
2984-
GetLightStatus(devType, subType, STYPE_OnOff, nValue, sValue, lstatus, llevel, bHaveDimmer, maxDimLevel, bHaveGroupCmd);
2985-
root["result"][ii]["IsOn"] = IsLightSwitchOn(lstatus);
2993+
GetLightStatus(devType, subType, STYPE_OnOff, command, sValue, lstatus, llevel, bHaveDimmer, maxDimLevel, bHaveGroupCmd);
2994+
root["result"][ii]["Command"] = lstatus;
29862995
root["result"][ii]["Level"] = level;
29872996
root["result"][ii]["Hue"] = atoi(sd[11].c_str());
29882997
root["result"][ii]["Type"] = RFX_Type_Desc(devType, 1);

main/mainworker.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9317,8 +9317,11 @@ bool MainWorker::SwitchLightInt(const std::vector<std::string> &sd, std::string
93179317
}
93189318

93199319
int hindex=FindDomoticzHardware(HardwareID);
9320-
if (hindex==-1)
9320+
if (hindex == -1)
9321+
{
9322+
_log.Log(LOG_ERROR, "Switch command not send!, Hardware device disabled or not found!");
93219323
return false;
9324+
}
93229325
CDomoticzHardwareBase *pHardware=GetHardware(HardwareID);
93239326
if (pHardware==NULL)
93249327
return false;

www/app/ScenesController.js

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ define(['app'], function (app) {
164164
return ;
165165
}
166166

167-
var Command=$("#scenecontent #combocommand option:selected").val();
167+
var Command=$("#scenecontent #combocommand option:selected").text();
168168

169169
var level=100;
170170
var hue=0;
@@ -359,22 +359,9 @@ define(['app'], function (app) {
359359
var totalItems=data.result.length;
360360
$.each(data.result, function(i,item){
361361
var bIsLED=(item.SubType.indexOf("RGB") >= 0);
362-
var commandbtns;
363-
if ($.isScene==false) {
364-
if (item.IsOn==true) {
365-
commandbtns='<button class="btn btn-mini btn-info" type="button" onclick="SwitchLight(' + item.DevID + ',\'On\',RefreshDeviceTableEx);">' + $.t('ON') + '</button> <button class="btn btn-mini" type="button" onclick="SwitchLight(' + item.DevID + ',\'Off\',RefreshDeviceTableEx);">' + $.t('OFF') + '</button>';
366-
}
367-
else {
368-
commandbtns='<button class="btn btn-mini" type="button" onclick="SwitchLight(' + item.DevID + ',\'On\',RefreshDeviceTableEx);">' + $.t('ON') + '</button> <button class="btn btn-mini btn-info" type="button" onclick="SwitchLight(' + item.DevID + ',\'Off\',RefreshDeviceTableEx);">' + $.t('OFF') + '</button>';
369-
}
370-
}
371-
else {
372-
if (item.IsOn==true) {
373-
commandbtns='<button class="btn btn-mini btn-info" type="button">' + $.t('ON') + '</button> <button class="btn btn-mini" type="button">' + $.t('OFF') + '</button>';
374-
}
375-
else {
376-
commandbtns='<button class="btn btn-mini" type="button">' + $.t('ON') + '</button> <button class="btn btn-mini btn-info" type="button">' + $.t('OFF') + '</button>';
377-
}
362+
var command="-";
363+
if ($.isScene==true) {
364+
command=item.Command;
378365
}
379366
var updownImg="";
380367
if (i!=totalItems-1) {
@@ -413,15 +400,16 @@ define(['app'], function (app) {
413400

414401
var addId = oTable.fnAddData( {
415402
"DT_RowId": item.ID,
416-
"IsOn": item.IsOn,
403+
"Command": item.Command,
417404
"RealIdx": item.DevRealIdx,
418405
"Level": item.Level,
419406
"Hue": item.Hue,
420407
"OnDelay": item.OnDelay,
421408
"OffDelay": item.OffDelay,
422409
"Order": item.Order,
410+
"IsScene": item.Order,
423411
"0": item.Name,
424-
"1": commandbtns,
412+
"1": command,
425413
"2": levelstr,
426414
"3": item.OnDelay,
427415
"4": item.OffDelay,
@@ -458,11 +446,11 @@ define(['app'], function (app) {
458446
$("#scenecontent #delclr #updatedelete").attr("href", "javascript:UpdateDevice(" + idx + "," + devidx + ")");
459447
$.lampIdx = devidx;
460448
$("#scenecontent #combodevice").val(devidx);
461-
if (data["IsOn"]==true) {
462-
$("#scenecontent #combocommand").val(1);
449+
if ($.isScene==true) {
450+
$("#scenecontent #combocommand").val(data["Command"]);
463451
}
464452
else {
465-
$("#scenecontent #combocommand").val(0);
453+
$("#scenecontent #combocommand").val("On");
466454
}
467455
OnSelChangeDevice();
468456

@@ -508,7 +496,7 @@ define(['app'], function (app) {
508496
return ;
509497
}
510498

511-
var Command=$("#scenecontent #combocommand option:selected").val();
499+
var Command=$("#scenecontent #combocommand option:selected").text();
512500

513501
var level=100;
514502
var hue=0;

www/html5.appcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# ref 1041
2+
# ref 1042
33

44
CACHE:
55
# CSS

www/i18n/domoticz-bg.json.gz

6 Bytes
Binary file not shown.

www/i18n/domoticz-cs.json.gz

6 Bytes
Binary file not shown.

www/i18n/domoticz-da.json.gz

20 Bytes
Binary file not shown.

www/i18n/domoticz-de.json.gz

19 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)