@@ -2030,6 +2030,7 @@ void CSQLHelper::Do_Work()
2030
2030
case pTypeLighting6:
2031
2031
case pTypeLimitlessLights:
2032
2032
case pTypeGeneralSwitch:
2033
+ case pTypeHomeConfort:
2033
2034
SwitchLightFromTasker (itt->_idx , " Off" , 0 , -1 );
2034
2035
break ;
2035
2036
case pTypeSecurity1:
@@ -2471,6 +2472,9 @@ unsigned long long CSQLHelper::UpdateValue(const int HardwareID, const char* ID,
2471
2472
case pTypeGeneralSwitch:
2472
2473
newnValue = gswitch_sOff;
2473
2474
break ;
2475
+ case pTypeHomeConfort:
2476
+ newnValue = HomeConfort_sOff;
2477
+ break ;
2474
2478
default :
2475
2479
continue ;
2476
2480
}
@@ -2550,6 +2554,9 @@ unsigned long long CSQLHelper::UpdateValue(const int HardwareID, const char* ID,
2550
2554
case pTypeGeneralSwitch:
2551
2555
newnValue = gswitch_sOff;
2552
2556
break ;
2557
+ case pTypeHomeConfort:
2558
+ newnValue = HomeConfort_sOff;
2559
+ break ;
2553
2560
default :
2554
2561
continue ;
2555
2562
}
@@ -2671,6 +2678,7 @@ unsigned long long CSQLHelper::UpdateValueInt(const int HardwareID, const char*
2671
2678
case pTypeThermostat3:
2672
2679
case pTypeRemote:
2673
2680
case pTypeGeneralSwitch:
2681
+ case pTypeHomeConfort:
2674
2682
case pTypeRadiator1:
2675
2683
if ((devType == pTypeRadiator1) && (subType != sTypeSmartwaresSwitchRadiator ))
2676
2684
break ;
@@ -2849,6 +2857,10 @@ unsigned long long CSQLHelper::UpdateValueInt(const int HardwareID, const char*
2849
2857
cmd = gswitch_sOff;
2850
2858
bAdd2DelayQueue = true ;
2851
2859
break ;
2860
+ case pTypeHomeConfort:
2861
+ cmd = HomeConfort_sOff;
2862
+ bAdd2DelayQueue = true ;
2863
+ break ;
2852
2864
}
2853
2865
}
2854
2866
/* Smoke detectors are manually reset!
@@ -5658,6 +5670,49 @@ void CSQLHelper::Lighting2GroupCmd(const std::string &ID, const unsigned char su
5658
5670
GroupCmd);
5659
5671
}
5660
5672
5673
+ unsigned long long CSQLHelper::UpdateValueHomeConfortGroupCmd (const int HardwareID, const char * ID, const unsigned char unit,
5674
+ const unsigned char devType, const unsigned char subType,
5675
+ const unsigned char signallevel, const unsigned char batterylevel,
5676
+ const int nValue, const char * sValue ,
5677
+ std::string &devname,
5678
+ const bool bUseOnOffAction)
5679
+ {
5680
+ // We only have to update all others units within the ID group. If the current unit does not have the same value,
5681
+ // it will be updated too. The reason we choose the UpdateValue is the propagation of the change to all units involved, including LogUpdate.
5682
+
5683
+ unsigned long long devRowIndex = -1 ;
5684
+ typedef std::vector<std::vector<std::string> > VectorVectorString;
5685
+
5686
+ VectorVectorString result = safe_query (" SELECT Unit FROM DeviceStatus WHERE ((DeviceID=='%q') AND (Type==%d) AND (SubType==%d) AND (nValue!=%d))" ,
5687
+ ID,
5688
+ pTypeHomeConfort,
5689
+ subType,
5690
+ nValue);
5691
+
5692
+ for (VectorVectorString::const_iterator itt = result.begin (); itt != result.end (); ++itt)
5693
+ {
5694
+ unsigned char theUnit = atoi ((*itt)[0 ].c_str ()); // get the unit value
5695
+ devRowIndex = UpdateValue (HardwareID, ID, theUnit, devType, subType, signallevel, batterylevel, nValue, sValue , devname, bUseOnOffAction);
5696
+ }
5697
+ return devRowIndex;
5698
+ }
5699
+
5700
+ void CSQLHelper::HomeConfortGroupCmd (const std::string &ID, const unsigned char subType, const unsigned char GroupCmd)
5701
+ {
5702
+ time_t now = mytime (NULL );
5703
+ struct tm ltime;
5704
+ localtime_r (&now, <ime);
5705
+
5706
+ safe_query (" UPDATE DeviceStatus SET nValue='%d', sValue='%s', LastUpdate='%04d-%02d-%02d %02d:%02d:%02d' WHERE (DeviceID=='%q') And (Type==%d) And (SubType==%d) And (nValue!=%d)" ,
5707
+ GroupCmd,
5708
+ " OFF" ,
5709
+ ltime.tm_year + 1900 , ltime.tm_mon + 1 , ltime.tm_mday , ltime.tm_hour , ltime.tm_min , ltime.tm_sec ,
5710
+ ID.c_str (),
5711
+ pTypeHomeConfort,
5712
+ subType,
5713
+ GroupCmd);
5714
+ }
5715
+
5661
5716
void CSQLHelper::GeneralSwitchGroupCmd (const std::string &ID, const unsigned char subType, const unsigned char GroupCmd)
5662
5717
{
5663
5718
safe_query (" UPDATE DeviceStatus SET nValue = %d WHERE (DeviceID=='%q') And (Type==%d) And (SubType==%d)" , GroupCmd, ID.c_str (), pTypeGeneralSwitch, subType);
@@ -5839,7 +5894,7 @@ void CSQLHelper::CheckDeviceTimeout()
5839
5894
5840
5895
std::vector<std::vector<std::string> > result;
5841
5896
result = safe_query (
5842
- " SELECT ID,Name,LastUpdate FROM DeviceStatus WHERE (Used!=0 AND LastUpdate<='%04d-%02d-%02d %02d:%02d:%02d' AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d) ORDER BY Name" ,
5897
+ " SELECT ID,Name,LastUpdate FROM DeviceStatus WHERE (Used!=0 AND LastUpdate<='%04d-%02d-%02d %02d:%02d:%02d' AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d AND Type!=%d ) ORDER BY Name" ,
5843
5898
ltime.tm_year +1900 ,ltime.tm_mon +1 , ltime.tm_mday , ltime.tm_hour , ltime.tm_min , ltime.tm_sec ,
5844
5899
pTypeLighting1,
5845
5900
pTypeLighting2,
@@ -5857,7 +5912,8 @@ void CSQLHelper::CheckDeviceTimeout()
5857
5912
pTypeThermostat2,
5858
5913
pTypeThermostat3,
5859
5914
pTypeRemote,
5860
- pTypeGeneralSwitch
5915
+ pTypeGeneralSwitch,
5916
+ pTypeHomeConfort
5861
5917
);
5862
5918
if (result.size ()<1 )
5863
5919
return ;
0 commit comments