Skip to content

Commit ace010a

Browse files
committed
Added Evohome 'All Sensors' button to add devices for all individual temperature sensors.
1 parent 97581d8 commit ace010a

File tree

4 files changed

+80
-6
lines changed

4 files changed

+80
-6
lines changed

hardware/evohome.cpp

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ CEvohome::CEvohome(const int ID, const std::string &szSerialPort) :
8989
m_nZoneCount=0;
9090
m_nControllerMode=0;
9191
m_MaxDeviceID = 0;
92+
93+
AllSensors = false;
9294

9395
m_iBaudRate=115200;
9496
if(!szSerialPort.empty())
@@ -314,6 +316,16 @@ void CEvohome::Do_Work()
314316
for (uint8_t i = 0; i < nZoneCount; i++)
315317
RequestZoneTemp(i);
316318
}
319+
if (AllSensors == false) // Check whether individual zone sensors has been activated
320+
{
321+
result = m_sql.safe_query("SELECT HardwareID, DeviceID FROM DeviceStatus WHERE (HardwareID==%d) AND (Type==%d) AND (Unit >= 13) AND (Unit <= 24)", m_HwdID, (int)pTypeEvohomeZone);
322+
if (result.size() != 0)
323+
AllSensors = true;
324+
// Check if the dummy sensor exists and delete
325+
result = m_sql.safe_query("SELECT HardwareID, DeviceID FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID == 'FFFFFF') AND (Type==%d) AND (Unit == 13)", m_HwdID, (int)pTypeEvohomeZone);
326+
if (result.size() != 0)
327+
m_sql.safe_query("DELETE FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID=='FFFFFF' AND (Type==%d) AND (Unit == 13))", m_HwdID, (int)pTypeEvohomeZone);
328+
}
317329
nStartup = 0;
318330
}
319331
}
@@ -991,8 +1003,17 @@ bool CEvohome::DecodeSetpoint(CEvohomeMsg &msg)//0x2309
9911003
//presumably this will ordinarily update to correspond to the transmitted value from the controller
9921004
//The exception appears to be for local overrides which may be possible to track by seeing if a change
9931005
//occurs that does not correspond to the controller setpoint for a given zone
994-
if (msg.GetID(0) == GetControllerID())
1006+
if (msg.GetID(0) == GetControllerID())
9951007
sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, "Setpoint", 255);
1008+
else if (AllSensors)
1009+
{
1010+
char zstrname[40];
1011+
1012+
sprintf(zstrname, "Zone %d", tsen.EVOHOME2.zone);
1013+
tsen.EVOHOME2.zone += 12; //zone number offset by 12
1014+
Log(true, LOG_STATUS, "evohome: %s: Setting: %d (0x%x): %d", tag, tsen.EVOHOME2.zone, msg.GetID(0), tsen.EVOHOME2.temperature);
1015+
sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, zstrname, 255);
1016+
}
9961017
}
9971018

9981019
return true;
@@ -1048,11 +1069,11 @@ bool CEvohome::DecodeSetpointOverride(CEvohomeMsg &msg)//0x2349
10481069
if(msg.payloadsize == 13)
10491070
{
10501071
CEvohomeDateTime::DecodeDateTime(tsen.EVOHOME2,msg.payload,7);
1051-
Log(true,LOG_STATUS,"evohome: %s: Setting: %d: %d (%d=%s) %s", tag, tsen.EVOHOME2.zone, tsen.EVOHOME2.temperature, tsen.EVOHOME2.mode, GetZoneModeName(tsen.EVOHOME2.mode),CEvohomeDateTime::GetStrDate(tsen.EVOHOME2).c_str());
1072+
Log(true,LOG_STATUS,"evohome: %s: Setting: %d (0x%x): %d (%d=%s) %s", tag, tsen.EVOHOME2.zone, msg.GetID(0), tsen.EVOHOME2.temperature, tsen.EVOHOME2.mode, GetZoneModeName(tsen.EVOHOME2.mode),CEvohomeDateTime::GetStrDate(tsen.EVOHOME2).c_str());
10521073
}
10531074
else
10541075
{
1055-
Log(true,LOG_STATUS,"evohome: %s: Setting: %d: %d (%d=%s)", tag, tsen.EVOHOME2.zone, tsen.EVOHOME2.temperature, tsen.EVOHOME2.mode, GetZoneModeName(tsen.EVOHOME2.mode));
1076+
Log(true,LOG_STATUS,"evohome: %s: Setting: %d (0x%x): %d (%d=%s)", tag, tsen.EVOHOME2.zone, msg.GetID(0), tsen.EVOHOME2.temperature, tsen.EVOHOME2.mode, GetZoneModeName(tsen.EVOHOME2.mode));
10561077
}
10571078

10581079
sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, "Setpoint", 255);
@@ -1093,7 +1114,7 @@ bool CEvohome::DecodeZoneTemp(CEvohomeMsg &msg)//0x30C9
10931114
tsen.EVOHOME2.zone = 0;
10941115
tsen.EVOHOME2.temperature = msg.payload[i + 1] << 8 | msg.payload[i + 2];
10951116
//this is sent for zones that use a zone temperature instead of the internal sensor.
1096-
Log(true,LOG_STATUS,"evohome: %s: Zone sensor msg: 0x%x: %d: %d", tag, msg.GetID(0), tsen.EVOHOME2.zone, tsen.EVOHOME2.temperature);
1117+
Log(true, LOG_STATUS, "evohome: %s: Zone sensor msg: 0x%x: %d: %d", tag, msg.GetID(0), tsen.EVOHOME2.zone, tsen.EVOHOME2.temperature);
10971118
if(tsen.EVOHOME2.temperature!=0x7FFF)//afaik this is the error value just ignore it right now as we have no way to report errors...also perhaps could be returned if DHW is not installed?
10981119
{
10991120
sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, "Zone Temp", 255);
@@ -1114,6 +1135,31 @@ bool CEvohome::DecodeZoneTemp(CEvohomeMsg &msg)//0x30C9
11141135
}
11151136
else {//no zone number here so we'd need to do a lookup based on the ID to use this
11161137
//msg from sensor itself
1138+
if (AllSensors)
1139+
{
1140+
std::vector<std::vector<std::string> > result;
1141+
char zstrname[40];
1142+
std::string zstrid(CEvohomeID::GetHexID(msg.GetID(0)));
1143+
1144+
result = m_sql.safe_query("SELECT Unit FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID == '%q') AND (Type == %d)", m_HwdID, zstrid.c_str(), (int)pTypeEvohomeZone);
1145+
if (result.size() != 0) // Update existing temp sensor with value directly from sensor
1146+
{
1147+
tsen.EVOHOME2.zone = atoi(result[0][0].c_str());
1148+
Log(true, LOG_STATUS, "evohome: %s: Zone sensor msg: 0x%x: %d: %d", tag, msg.GetID(0), tsen.EVOHOME2.zone, tsen.EVOHOME2.temperature);
1149+
sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, "Zone Temp", 255);
1150+
}
1151+
else // If matching relay with same deviceID then create a new Zone Temp sensor with zone number offset by 12
1152+
{
1153+
result = m_sql.safe_query("SELECT Unit FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID == '%q') AND (Type == %d)", m_HwdID, zstrid.c_str(), (int)pTypeEvohomeRelay);
1154+
if (result.size() != 0)
1155+
{
1156+
tsen.EVOHOME2.zone = atoi(result[0][0].c_str()) + 12;
1157+
sprintf(zstrname, "Zone %d", atoi(result[0][0].c_str()));
1158+
Log(true, LOG_STATUS, "evohome: %s: Zone sensor msg: 0x%x: %d: %d", tag, msg.GetID(0), tsen.EVOHOME2.zone, tsen.EVOHOME2.temperature);
1159+
sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, zstrname, 255);
1160+
}
1161+
}
1162+
}
11171163
if (msg.payloadsize != 3) {
11181164
Log(true,LOG_STATUS,"evohome: %s: WARNING: got a sensor temperature msg with an unexpected payload size: %d", tag, msg.payloadsize);
11191165
}
@@ -1917,6 +1963,21 @@ namespace http {
19171963
}
19181964
else if (type == "OutdoorSensor")
19191965
nID = pEvoHW->Bind(0, CEvohomeID::devSensor);
1966+
else if (type == "AllSensors")
1967+
{
1968+
// Check if All Sensors has already been activated, if not create a temporary dummy sensor
1969+
std::vector<std::vector<std::string> > result;
1970+
result = m_sql.safe_query("SELECT HardwareID, DeviceID FROM DeviceStatus WHERE (HardwareID==%d) AND (Type==%d) AND (Unit > 12) AND (Unit <= 24)", HwdID, (int)pTypeEvohomeZone);
1971+
if (result.size() == 0)
1972+
{
1973+
std::string devname = "Zone Temp";
1974+
m_sql.UpdateValue(HwdID, "FFFFFF", 13, pTypeEvohomeZone, sTypeEvohomeZone, 10, 255, 0, "0.0;0.0;Auto", devname);
1975+
}
1976+
root["status"] = "OK";
1977+
root["title"] = "CreateEvohomeSensor";
1978+
root["Used"] = false;
1979+
return;
1980+
}
19201981
else if (type == "ZoneSensor")
19211982
{
19221983
//get dev count

hardware/evohome.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ class CEvohome : public AsyncSerial, public CDomoticzHardwareBase
606606
boost::condition_variable m_cndBindNotify;
607607

608608
unsigned int m_MaxDeviceID;
609+
610+
bool AllSensors;
609611

610612
struct _tRelayCheck
611613
{

main/mainworker.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5906,6 +5906,7 @@ void MainWorker::decode_evohome2(const int HwdID, const _eHardwareTypes HwdType,
59065906

59075907
bool bNewDev=false;
59085908
std::string name,szDevID;
5909+
std::stringstream szID;
59095910
unsigned char Unit;
59105911
unsigned char dType;
59115912
unsigned char dSubType;
@@ -5927,11 +5928,16 @@ void MainWorker::decode_evohome2(const int HwdID, const _eHardwareTypes HwdType,
59275928
dType=pEvo->EVOHOME2.type;
59285929
dSubType=pEvo->EVOHOME2.subtype;
59295930

5931+
szID << std::hex << (int)RFX_GETID3(pEvo->EVOHOME2.id1, pEvo->EVOHOME2.id2, pEvo->EVOHOME2.id3);
5932+
szDevID = szID.str();
5933+
59305934
CEvohome *pEvoHW = reinterpret_cast<CEvohome*>(GetHardware(HwdID));
59315935
if(!pEvoHW)
59325936
return;
59335937
if(dType==pTypeEvohomeWater)
59345938
name="Hot Water";
5939+
else if (dType == pTypeEvohomeZone && !szDevID.empty())
5940+
name = "Zone Temp";
59355941
else
59365942
name=pEvoHW->GetZoneName(Unit-1);
59375943
if(name.empty())

www/app/HardwareController.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,6 +3579,8 @@ define(['app'], function (app) {
35793579
$.devIdx=idx;
35803580
if(devtype=="Relay")
35813581
ShowNotify($.t('Hold bind button on relay...'),2500);
3582+
else if (devtype == "AllSensors")
3583+
ShowNotify($.t('Creating additional sensors...'));
35823584
else if (devtype == "ZoneSensor")
35833585
ShowNotify($.t('Binding Domoticz zone temperature sensor to controller...'),2500);
35843586
else
@@ -3609,7 +3611,9 @@ define(['app'], function (app) {
36093611
if ((bNewDevice == true) && (bIsUsed == false))
36103612
{
36113613
if(devtype=="Relay")
3612-
ShowNotify($.t('Relay bound, and can be found in the devices tab!'),2500);
3614+
ShowNotify($.t('Relay bound, and can be found in the devices tab!'), 2500);
3615+
else if (devtype == "AllSensors")
3616+
ShowNotify($.t('New sensors will appear in the devices tab after 10min'), 2500);
36133617
else if (devtype == "ZoneSensor")
36143618
ShowNotify($.t('Sensor bound, and can be found in the devices tab!'),2500);
36153619
else
@@ -3967,7 +3971,8 @@ define(['app'], function (app) {
39673971
else
39683972
{
39693973
HwTypeStr+=' <span class="label label-info lcursor" onclick="BindEvohome(' + item.idx + ',\'' + item.Name + '\',\'Relay\');">Bind Relay</span>';
3970-
HwTypeStr+=' <span class="label label-info lcursor" onclick="BindEvohome(' + item.idx + ',\'' + item.Name + '\',\'OutdoorSensor\');">Outdoor Sensor</span>';
3974+
HwTypeStr += ' <span class="label label-info lcursor" onclick="BindEvohome(' + item.idx + ',\'' + item.Name + '\',\'OutdoorSensor\');">Outdoor Sensor</span>';
3975+
HwTypeStr += ' <span class="label label-info lcursor" onclick="BindEvohome(' + item.idx + ',\'' + item.Name + '\',\'AllSensors\');">All Sensors</span>';
39713976
HwTypeStr += ' <span class="label label-info lcursor" onclick="BindEvohome(' + item.idx + ',\'' + item.Name + '\',\'ZoneSensor\');">Bind Temp Sensor</span>';
39723977
}
39733978
}

0 commit comments

Comments
 (0)