Skip to content

Commit 7390a2c

Browse files
committed
- Implemented: RFXCom, support for Home Confort TEL-010
1 parent ea4b80a commit 7390a2c

File tree

12 files changed

+457
-57
lines changed

12 files changed

+457
-57
lines changed

History.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Version 3.xxx
2+
- Implemented: RFXCom, support for Home Confort TEL-010
3+
14
Version 3.521 (October 31th 2015)
25
- Implemented "Stop" state in blockly in switch states
36
- Implemented: Ability to parse data coming from an HTTP POST data with a lua script (seb)

main/Helper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ bool IsLightOrSwitch(const int devType, const int subType)
566566
case pTypeThermostat3:
567567
case pTypeRemote:
568568
case pTypeGeneralSwitch:
569+
case pTypeHomeConfort:
569570
bIsLightSwitch = true;
570571
break;
571572
case pTypeRadiator1:

main/RFXNames.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ const char *RFX_Type_Desc(const unsigned char i, const unsigned char snum)
381381
{ pTypeLighting4, "Lighting 4" , "lightbulb", },
382382
{ pTypeLighting5, "Lighting 5" , "lightbulb", },
383383
{ pTypeLighting6, "Lighting 6" , "lightbulb", },
384+
{ pTypeHomeConfort, "Home Confort" , "lightbulb" },
384385
{ pTypeLimitlessLights, "Lighting Limitless/Applamp" , "lightbulb" },
385386
{ pTypeCurtain, "Curtain" , "blinds" },
386387
{ pTypeBlinds, "Blinds" , "blinds" },
@@ -535,9 +536,12 @@ const char *RFX_Type_SubType_Desc(const unsigned char dType, const unsigned char
535536
{ pTypeLighting5, sTypeEurodomest, "Eurodomest" },
536537
{ pTypeLighting5, sTypeLivoloAppliance, "Livolo Appliance" },
537538
{ pTypeLighting5, sTypeRGB432W, "RGB432W" },
539+
{ pTypeLighting5, sTypeMDREMOTE107, "MDRemote 107" },
538540

539541
{ pTypeLighting6, sTypeBlyss, "Blyss" },
540542

543+
{ pTypeHomeConfort, sTypeHomeConfortTEL010 , "TEL-010" },
544+
541545
{ pTypeCurtain, sTypeHarrison, "Harrison" },
542546

543547
{ pTypeBlinds, sTypeBlindsT0, "RollerTrol, Hasta new" },
@@ -824,9 +828,12 @@ const char *RFX_Type_SubType_Values(const unsigned char dType, const unsigned ch
824828
{ pTypeLighting5, sTypeEurodomest, "Status" },
825829
{ pTypeLighting5, sTypeLivoloAppliance, "Status" },
826830
{ pTypeLighting5, sTypeRGB432W, "Status" },
831+
{ pTypeLighting5, sTypeMDREMOTE107, "Status" },
827832

828833
{ pTypeLighting6, sTypeBlyss, "Status" },
829834

835+
{ pTypeHomeConfort, sTypeHomeConfortTEL010, "Status" },
836+
830837
{ pTypeCurtain, sTypeHarrison, "Status" },
831838

832839
{ pTypeBlinds, sTypeBlindsT0, "Status" },
@@ -1484,6 +1491,29 @@ void GetLightStatus(
14841491
}
14851492
}
14861493
break;
1494+
case pTypeHomeConfort:
1495+
switch (dSubType)
1496+
{
1497+
case sTypeHomeConfortTEL010:
1498+
bHaveGroupCmd = true;
1499+
switch (nValue)
1500+
{
1501+
case HomeConfort_sOff:
1502+
lstatus = "Off";
1503+
break;
1504+
case HomeConfort_sOn:
1505+
lstatus = "On";
1506+
break;
1507+
case HomeConfort_sGroupOn:
1508+
lstatus = "Group On";
1509+
break;
1510+
case HomeConfort_sGroupOff:
1511+
lstatus = "Group Off";
1512+
break;
1513+
}
1514+
break;
1515+
}
1516+
break;
14871517
case pTypeGeneralSwitch:
14881518
maxDimLevel = 100;
14891519

@@ -2135,6 +2165,40 @@ bool GetLightCommand(
21352165
else
21362166
return false;
21372167
break;
2168+
case pTypeHomeConfort:
2169+
if (switchtype == STYPE_Doorbell)
2170+
{
2171+
if ((switchcmd == "On") || (switchcmd == "Group On"))
2172+
{
2173+
cmd = HomeConfort_sGroupOn;
2174+
return true;
2175+
}
2176+
//no other combinations for the door switch
2177+
return false;
2178+
}
2179+
if (switchcmd == "Off")
2180+
{
2181+
cmd = HomeConfort_sOff;
2182+
return true;
2183+
}
2184+
else if (switchcmd == "On")
2185+
{
2186+
cmd = HomeConfort_sOn;
2187+
return true;
2188+
}
2189+
else if (switchcmd == "Group Off")
2190+
{
2191+
cmd = HomeConfort_sGroupOff;
2192+
return true;
2193+
}
2194+
else if (switchcmd == "Group On")
2195+
{
2196+
cmd = HomeConfort_sGroupOn;
2197+
return true;
2198+
}
2199+
else
2200+
return false;
2201+
break;
21382202
case pTypeGeneralSwitch:
21392203
if (switchtype == STYPE_Doorbell)
21402204
{

main/RFXtrx.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ portions of this file.
2727
*/
2828

2929
/*
30+
SDK version 9.03
31+
MDremote version 107 added
32+
33+
SDK version 9.02
34+
Home Confort added
35+
3036
SDK version 9.01
3137
RFY - ASA blinds added
3238
@@ -382,6 +388,7 @@ SDK version 4.9
382388
#define sTypeUrgb 0x13
383389
#define sTypeUrfy 0x14
384390
#define sTypeUselectplus 0x15
391+
#define sTypeUhomeconfort 0x16
385392

386393
//types for Lighting
387394
#define pTypeLighting1 0x10
@@ -451,6 +458,7 @@ SDK version 4.9
451458
#define sTypeEurodomest 0x09
452459
#define sTypeLivoloAppliance 0x0A
453460
#define sTypeRGB432W 0x0B
461+
#define sTypeMDREMOTE107 0x0C
454462

455463
#define light5_sOff 0x0
456464
#define light5_sOn 0x1
@@ -500,6 +508,15 @@ SDK version 4.9
500508
#define light5_sRGBdim 0x03
501509
#define light5_sRGBcolorplus 0x04
502510
#define light5_sRGBcolormin 0x05
511+
#define light5_sMD107_Power 0x0
512+
#define light5_sMD107_Bright 0x1
513+
#define light5_sMD107_Dim 0x2
514+
#define light5_sMD107_100 0x3
515+
#define light5_sMD107_80 0x4
516+
#define light5_sMD107_60 0x5
517+
#define light5_sMD107_40 0x6
518+
#define light5_sMD107_20 0x7
519+
#define light5_sMD107_10 0x8
503520

504521
#define pTypeLighting6 0x15
505522
#define sTypeBlyss 0x0
@@ -601,6 +618,14 @@ SDK version 4.9
601618
#define rfy_sEnableSunWind 0x13
602619
#define rfy_sDisableSun 0x14
603620

621+
//types for Home Confort
622+
#define pTypeHomeConfort 0x1B
623+
#define sTypeHomeConfortTEL010 0x0
624+
#define HomeConfort_sOff 0x0
625+
#define HomeConfort_sOn 0x1
626+
#define HomeConfort_sGroupOff 0x2
627+
#define HomeConfort_sGroupOn 0x3
628+
604629
//types for Security1
605630
#define pTypeSecurity1 0x20
606631
#define sTypeSecX10 0x0 //X10 security
@@ -1146,7 +1171,27 @@ typedef union tRBUF {
11461171
BYTE rssi : 4;
11471172
#endif
11481173
} LIGHTING6;
1149-
1174+
struct {
1175+
BYTE packetlength;
1176+
BYTE packettype;
1177+
BYTE subtype;
1178+
BYTE seqnbr;
1179+
BYTE id1;
1180+
BYTE id2;
1181+
BYTE id3;
1182+
BYTE housecode;
1183+
BYTE unitcode;
1184+
BYTE cmnd;
1185+
BYTE rfu1;
1186+
BYTE rfu2;
1187+
#ifdef IS_BIG_ENDIAN
1188+
BYTE rssi : 4;
1189+
BYTE filler : 4;
1190+
#else
1191+
BYTE filler : 4;
1192+
BYTE rssi : 4;
1193+
#endif
1194+
} HOMECONFORT;
11501195
struct {
11511196
BYTE packetlength;
11521197
BYTE packettype;

main/SQLHelper.cpp

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,7 @@ void CSQLHelper::Do_Work()
20302030
case pTypeLighting6:
20312031
case pTypeLimitlessLights:
20322032
case pTypeGeneralSwitch:
2033+
case pTypeHomeConfort:
20332034
SwitchLightFromTasker(itt->_idx, "Off", 0, -1);
20342035
break;
20352036
case pTypeSecurity1:
@@ -2471,6 +2472,9 @@ unsigned long long CSQLHelper::UpdateValue(const int HardwareID, const char* ID,
24712472
case pTypeGeneralSwitch:
24722473
newnValue = gswitch_sOff;
24732474
break;
2475+
case pTypeHomeConfort:
2476+
newnValue = HomeConfort_sOff;
2477+
break;
24742478
default:
24752479
continue;
24762480
}
@@ -2550,6 +2554,9 @@ unsigned long long CSQLHelper::UpdateValue(const int HardwareID, const char* ID,
25502554
case pTypeGeneralSwitch:
25512555
newnValue = gswitch_sOff;
25522556
break;
2557+
case pTypeHomeConfort:
2558+
newnValue = HomeConfort_sOff;
2559+
break;
25532560
default:
25542561
continue;
25552562
}
@@ -2671,6 +2678,7 @@ unsigned long long CSQLHelper::UpdateValueInt(const int HardwareID, const char*
26712678
case pTypeThermostat3:
26722679
case pTypeRemote:
26732680
case pTypeGeneralSwitch:
2681+
case pTypeHomeConfort:
26742682
case pTypeRadiator1:
26752683
if ((devType == pTypeRadiator1) && (subType != sTypeSmartwaresSwitchRadiator))
26762684
break;
@@ -2849,6 +2857,10 @@ unsigned long long CSQLHelper::UpdateValueInt(const int HardwareID, const char*
28492857
cmd = gswitch_sOff;
28502858
bAdd2DelayQueue = true;
28512859
break;
2860+
case pTypeHomeConfort:
2861+
cmd = HomeConfort_sOff;
2862+
bAdd2DelayQueue = true;
2863+
break;
28522864
}
28532865
}
28542866
/* Smoke detectors are manually reset!
@@ -5658,6 +5670,49 @@ void CSQLHelper::Lighting2GroupCmd(const std::string &ID, const unsigned char su
56585670
GroupCmd);
56595671
}
56605672

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, &ltime);
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+
56615716
void CSQLHelper::GeneralSwitchGroupCmd(const std::string &ID, const unsigned char subType, const unsigned char GroupCmd)
56625717
{
56635718
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()
58395894

58405895
std::vector<std::vector<std::string> > result;
58415896
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",
58435898
ltime.tm_year+1900,ltime.tm_mon+1, ltime.tm_mday, ltime.tm_hour, ltime.tm_min, ltime.tm_sec,
58445899
pTypeLighting1,
58455900
pTypeLighting2,
@@ -5857,7 +5912,8 @@ void CSQLHelper::CheckDeviceTimeout()
58575912
pTypeThermostat2,
58585913
pTypeThermostat3,
58595914
pTypeRemote,
5860-
pTypeGeneralSwitch
5915+
pTypeGeneralSwitch,
5916+
pTypeHomeConfort
58615917
);
58625918
if (result.size()<1)
58635919
return;

main/SQLHelper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,12 @@ class CSQLHelper
190190
unsigned long long UpdateValue(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, const unsigned char subType, const unsigned char signallevel, const unsigned char batterylevel, const char* sValue, std::string &devname, const bool bUseOnOffAction=true);
191191
unsigned long long UpdateValue(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, const unsigned char subType, const unsigned char signallevel, const unsigned char batterylevel, const int nValue, const char* sValue, std::string &devname, const bool bUseOnOffAction=true);
192192
unsigned long long UpdateValueLighting2GroupCmd(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, const unsigned char subType, const unsigned char signallevel, const unsigned char batterylevel, const int nValue, const char* sValue, std::string &devname, const bool bUseOnOffAction = true);
193+
unsigned long long UpdateValueHomeConfortGroupCmd(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, const unsigned char subType, const unsigned char signallevel, const unsigned char batterylevel, const int nValue, const char* sValue, std::string &devname, const bool bUseOnOffAction = true);
193194

194195
bool GetLastValue(const int HardwareID, const char* DeviceID, const unsigned char unit, const unsigned char devType, const unsigned char subType, int &nvalue, std::string &sValue, struct tm &LastUpdateTime);
195196

196197
void Lighting2GroupCmd(const std::string &ID, const unsigned char subType, const unsigned char GroupCmd);
198+
void HomeConfortGroupCmd(const std::string &ID, const unsigned char subType, const unsigned char GroupCmd);
197199
void GeneralSwitchGroupCmd(const std::string &ID, const unsigned char subType, const unsigned char GroupCmd);
198200

199201
void GetAddjustment(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, const unsigned char subType, float &AddjValue, float &AddjMulti);

0 commit comments

Comments
 (0)