You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
result = m_sql.safe_query("SELECT Max(Unit) FROM DeviceStatus WHERE (HardwareID==%d) AND (Type==%d) AND (Unit>=40) AND (Unit<52)", m_HwdID, (int)pTypeEvohomeZone);
591
+
592
+
int nDevCount = 0;
593
+
if (result.size() > 0)
594
+
{
595
+
nDevCount = atoi(result[0][0].c_str());
596
+
}
597
+
elsereturn;
598
+
for (int i = 40; i <= nDevCount; ++i)
599
+
{
600
+
result = m_sql.safe_query("SELECT DeviceID, Name FROM DeviceStatus WHERE (HardwareID==%d) AND (Type==%d) AND (Unit==%d)", m_HwdID, (int)pTypeEvohomeZone, i); // Get Zone Name and DeviceID
601
+
if (result.size() > 0) //Check that sensor number exists - this allows for deletion
602
+
{
603
+
//std::vector<std::string> sd = result[0];
604
+
std::stringstream s_strid;
605
+
std::string SensorName = result[0][1].c_str();
606
+
//s_strid << std::hex << sd[0].c_str();
607
+
s_strid << std::hex << result[0][0].c_str();
608
+
s_strid >> ID;
609
+
result = m_sql.safe_query("SELECT sValue FROM DeviceStatus WHERE (Type !=%d) AND (Name=='%q')", (int)pTypeEvohomeZone, SensorName.c_str()); // Get temperature from external sensor with matching Name
610
+
if (result.size() == 1)
611
+
{
612
+
std::vector<std::string> strarray;
613
+
StringSplit(result[0][0], ";", strarray);
614
+
if (strarray.size() >= 1)
615
+
dbTemp = atof(strarray[0].c_str());
616
+
Log(true, LOG_STATUS, "evohome: Send Temp Zone msg Zone: %d DeviceID: 0x%x Name:%s Temp:%f ", i, ID, SensorName.c_str(), dbTemp);
elseif (nDevType == CEvohomeID::devZone)//Binding the HGI80 to the evohome controller as a zone temperature sensor
904
+
{
905
+
// Check that the max Device ID includes the zone temperature sensors
906
+
std::vector<std::vector<std::string> > result;
907
+
908
+
result = m_sql.safe_query("SELECT MAX(DeviceID) FROM DeviceStatus WHERE (HardwareID==%d) AND (Type==%d) AND (Unit>=40) AND (Unit<52)", m_HwdID, (int)pTypeEvohomeZone);
Log(true,LOG_STATUS,"evohome: %s: WARNING: sensor reading with zone != 0: 0x%x - %d", tag, msg.GetID(0), msg.payload[0]);
1017
1105
}
1018
1106
}
1107
+
if ((msg.GetID(0) > m_MaxDeviceID))
1108
+
m_MaxDeviceID = msg.GetID(0);
1019
1109
1020
1110
returntrue;
1021
1111
}
@@ -1812,6 +1902,27 @@ namespace http {
1812
1902
}
1813
1903
elseif (type == "OutdoorSensor")
1814
1904
nID = pEvoHW->Bind(0, CEvohomeID::devSensor);
1905
+
elseif (type == "ZoneSensor")
1906
+
{
1907
+
//get dev count
1908
+
std::vector<std::vector<std::string> > result;
1909
+
result = m_sql.safe_query("SELECT MAX(Unit) FROM DeviceStatus WHERE (HardwareID==%d) AND (Type==%d) AND (Unit>=40) AND (Unit<52)", HwdID,(int)pTypeEvohomeZone);
1910
+
int nDevCount = 0;
1911
+
if (result.size() > 0)
1912
+
{
1913
+
nDevCount = atoi(result[0][0].c_str());
1914
+
}
1915
+
1916
+
if (nDevCount == 51)// Allow a maximum of 12 sensors
1917
+
{
1918
+
root["status"] = "ERR";
1919
+
root["message"] = "Maximum number of Zone sensors reached";
0 commit comments