@@ -11983,6 +11983,12 @@ void MainWorker::HeartbeatCheck()
11983
11983
bool MainWorker::UpdateDevice (const int HardwareID, const std::string &DeviceID, const int unit, const int devType, const int subType, const int nValue, const std::string &sValue , const int signallevel, const int batterylevel, const bool parseTrigger)
11984
11984
{
11985
11985
CDomoticzHardwareBase *pHardware = GetHardware (HardwareID);
11986
+
11987
+ unsigned long ID = 0 ;
11988
+ std::stringstream s_strid;
11989
+ s_strid << std::hex << DeviceID;
11990
+ s_strid >> ID;
11991
+
11986
11992
if (pHardware)
11987
11993
{
11988
11994
if (devType == pTypeLighting2)
@@ -12011,36 +12017,62 @@ bool MainWorker::UpdateDevice(const int HardwareID, const std::string &DeviceID,
12011
12017
lcmd.LIGHTING2 .level = (unsigned char )atoi (sValue .c_str ());
12012
12018
lcmd.LIGHTING2 .filler = 0 ;
12013
12019
lcmd.LIGHTING2 .rssi = signallevel;
12014
- DecodeRXMessage (pHardware, (const unsigned char *)&lcmd.LIGHTING2 , NULL , - 1 );
12020
+ DecodeRXMessage (pHardware, (const unsigned char *)&lcmd.LIGHTING2 , NULL , batterylevel );
12015
12021
return true ;
12016
12022
}
12017
- else if (( devType == pTypeGeneral) && (subType == sTypePercentage ) )
12023
+ else if (devType == pTypeGeneral)
12018
12024
{
12019
- unsigned long ID;
12020
- std::stringstream s_strid;
12021
- s_strid << std::hex << DeviceID;
12022
- s_strid >> ID;
12023
- _tGeneralDevice gDevice ;
12024
- gDevice .subtype = sTypePercentage ;
12025
- gDevice .id = unit;
12026
- gDevice .floatval1 = (float )atof (sValue .c_str ());
12027
- gDevice .intval1 = static_cast <int >(ID);
12028
- DecodeRXMessage (pHardware, (const unsigned char *)&gDevice , NULL , -1 );
12029
- return true ;
12025
+ if (subType == sTypePercentage )
12026
+ {
12027
+ _tGeneralDevice gDevice ;
12028
+ gDevice .subtype = sTypePercentage ;
12029
+ gDevice .id = unit;
12030
+ gDevice .floatval1 = (float )atof (sValue .c_str ());
12031
+ gDevice .intval1 = static_cast <int >(ID);
12032
+ DecodeRXMessage (pHardware, (const unsigned char *)&gDevice , NULL , batterylevel);
12033
+ return true ;
12034
+ }
12035
+ else if (subType == sTypeWaterflow )
12036
+ {
12037
+ unsigned long ID;
12038
+ std::stringstream s_strid;
12039
+ s_strid << std::hex << DeviceID;
12040
+ s_strid >> ID;
12041
+ _tGeneralDevice gDevice ;
12042
+ gDevice .subtype = sTypeWaterflow ;
12043
+ gDevice .id = unit;
12044
+ gDevice .floatval1 = (float )atof (sValue .c_str ());
12045
+ gDevice .intval1 = static_cast <int >(ID);
12046
+ DecodeRXMessage (pHardware, (const unsigned char *)&gDevice , NULL , batterylevel);
12047
+ return true ;
12048
+ }
12049
+ else if (subType == sTypeSoundLevel )
12050
+ {
12051
+ _tGeneralDevice gDevice ;
12052
+ gDevice .subtype = sTypeSoundLevel ;
12053
+ gDevice .id = unit;
12054
+ gDevice .intval1 = static_cast <int >(ID);
12055
+ gDevice .intval2 = atoi (sValue .c_str ());
12056
+ DecodeRXMessage (pHardware, (const unsigned char *)&gDevice , NULL , batterylevel);
12057
+ return true ;
12058
+ }
12030
12059
}
12031
- else if ((devType == pTypeGeneral ) && (subType == sTypeWaterflow ))
12060
+ else if ((devType == pTypeAirQuality ) && (subType == sTypeVoltcraft ))
12032
12061
{
12033
- unsigned long ID;
12034
- std::stringstream s_strid;
12035
- s_strid << std::hex << DeviceID;
12036
- s_strid >> ID;
12037
- _tGeneralDevice gDevice ;
12038
- gDevice .subtype = sTypeWaterflow ;
12039
- gDevice .id = unit;
12040
- gDevice .floatval1 = (float )atof (sValue .c_str ());
12041
- gDevice .intval1 = static_cast <int >(ID);
12042
- DecodeRXMessage (pHardware, (const unsigned char *)&gDevice , NULL , -1 );
12043
- return true ;
12062
+ std::vector<std::vector<std::string> > result;
12063
+ result = m_sql.safe_query (
12064
+ " SELECT ID,Name FROM DeviceStatus WHERE (HardwareID=%d AND DeviceID='%q' AND Unit=%d AND Type=%d AND SubType=%d)" ,
12065
+ HardwareID, DeviceID.c_str (), unit, devType, subType);
12066
+ if (!result.empty ())
12067
+ {
12068
+ std::vector<std::string> sd = result[0 ];
12069
+ unsigned long long dID = 0 ;
12070
+ std::stringstream s_strid;
12071
+ s_strid << sd[0 ];
12072
+ s_strid >> dID;
12073
+
12074
+ m_notifications.CheckAndHandleNotification (dID, sd[1 ], devType, subType, NTYPE_USAGE, (const float )nValue);
12075
+ }
12044
12076
}
12045
12077
}
12046
12078
0 commit comments