Skip to content

Commit

Permalink
Merge pull request #3 from dresden-elektronik/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Smanar authored Oct 2, 2020
2 parents 1dffbdc + 3ae19cf commit c9d02c1
Show file tree
Hide file tree
Showing 15 changed files with 974 additions and 193 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ For community based support with deCONZ or Phoscon, please visit the [deCONZ Dis
The Phoscon App is a browser based web application and supports lights, sensors and switches. For more information and screenshots visit the [Phoscon App Documentation](https://phoscon.de/app/doc?ref=gh).


### Release Schedule

deCONZ is having a beta release at the 15th day of the month in which the beta of last month becomes stable. Pull requests done before the 10th of the month, are getting included in the next beta (if there are no issues ofcourse!). Stable release would be around the 1st - 5th of the month after latest beta.
Current Beta: 2.05.82
Current Stable: 2.05.81

Next Beta: 2.05.85 expected at the 15th of October.
Next Stable: 2.05.84 expected at 8th October (minor fixes and new firmware files)

Installation
============

Expand Down Expand Up @@ -118,3 +127,4 @@ License
=======
The plugin is available as open source and licensed under the BSD (3-Clause) license.


66 changes: 62 additions & 4 deletions bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
return sendConfigureReportingRequest(bt, {rq, rq2, rq3, rq4});
}

else if ( (sensor && sensor->modelId() == QLatin1String("eTRV0100")) || // Danfoss Ally
else if ( (sensor && sensor->modelId() == QLatin1String("eTRV0100")) || // Danfoss Ally
(sensor && sensor->modelId() == QLatin1String("TRV001")) ) // Hive TRV
{
rq.dataType = deCONZ::Zcl16BitInt;
Expand Down Expand Up @@ -1183,7 +1183,54 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
return sendConfigureReportingRequest(bt, {rq, rq2, rq3}) || // Use OR because of manuf. specific attributes
sendConfigureReportingRequest(bt, {rq4, rq5});
}
else if (sensor && sensor->modelId() == QLatin1String("902010/32")) // Bitron thermostat
{
rq.dataType = deCONZ::Zcl16BitInt;
rq.attributeId = 0x0000; // local temperature
rq.minInterval = 0;
rq.maxInterval = 300;
rq.reportableChange16bit = 10;

ConfigureReportingRequest rq2;
rq2.dataType = deCONZ::Zcl8BitUint;
rq2.attributeId = 0x0012; // Occupied heating setpoint
rq2.minInterval = 1;
rq2.maxInterval = 600;
rq2.reportableChange8bit = 1;

return sendConfigureReportingRequest(bt, {rq, rq2});
}
else if (sensor && sensor->modelId().startsWith(QLatin1String("TH112"))) // Sinope Thermostat TH1123ZB & TH1124ZB
{
rq.dataType = deCONZ::Zcl16BitInt;
rq.attributeId = 0x0000; // Local Temperature
rq.minInterval = 1;
rq.maxInterval = 600;
rq.reportableChange16bit = 10;

ConfigureReportingRequest rq2;
rq2.dataType = deCONZ::Zcl16BitInt;
rq2.attributeId = 0x0001; // Outdoor temperature
rq2.minInterval = 1;
rq2.maxInterval = 600;
rq2.reportableChange8bit = 10;

ConfigureReportingRequest rq3;
rq3.dataType = deCONZ::Zcl8BitUint;
rq3.attributeId = 0x0008; // Pi heating demand
rq3.minInterval = 60;
rq3.maxInterval = 3600;
rq3.reportableChange8bit = 1;

ConfigureReportingRequest rq4;
rq4.dataType = deCONZ::Zcl16BitInt;
rq4.attributeId = 0x0012; // Occupied heating setpoint
rq4.minInterval = 1;
rq4.maxInterval = 600;
rq4.reportableChange16bit = 50;

return sendConfigureReportingRequest(bt, {rq, rq2, rq3, rq4});
}
else
{
rq.dataType = deCONZ::Zcl16BitInt;
Expand Down Expand Up @@ -1331,7 +1378,8 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
sensor->modelId() == QLatin1String("Zen-01") ||
sensor->modelId() == QLatin1String("Bell") ||
sensor->modelId() == QLatin1String("SLT2") ||
sensor->modelId().startsWith(QLatin1String("3315"))))
sensor->modelId().startsWith(QLatin1String("3315")) ||
sensor->modelId().startsWith(QLatin1String("4655BC0"))))
{
rq.attributeId = 0x0020; // battery voltage
rq.minInterval = 3600;
Expand Down Expand Up @@ -1960,6 +2008,12 @@ void DeRestPluginPrivate::checkLightBindingsForAttributeReporting(LightNode *lig
else if (lightNode->manufacturer() == QLatin1String("Immax"))
{
}
else if (lightNode->manufacturer().startsWith(QLatin1String("EcoDim")))
{
}
else if (lightNode->manufacturer().startsWith(QLatin1String("ROBB smarrt")))
{
}
else if (lightNode->manufacturer() == QLatin1String("sengled"))
{
}
Expand Down Expand Up @@ -2256,8 +2310,8 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
// LG
sensor->modelId() == QLatin1String("LG IP65 HMS") ||
// Sinope
sensor->modelId() == QLatin1String("WL4200S") ||
sensor->modelId().startsWith(QLatin1String("TH112")) ||
sensor->modelId().startsWith(QLatin1String("WL4200")) || // water leak sensor
sensor->modelId().startsWith(QLatin1String("TH112")) || // thermostat
//LifeControl smart plug
sensor->modelId() == QLatin1String("RICI01") ||
//LifeControl enviroment sensor
Expand Down Expand Up @@ -2286,6 +2340,8 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
sensor->modelId().startsWith(QLatin1String("ZB-ONOFFPlug-D0005")) ||
// Aurora
sensor->modelId().startsWith(QLatin1String("DoubleSocket50AU")) ||
// Ecolink
sensor->modelId().startsWith(QLatin1String("4655BC0")) ||
// Bosch
sensor->modelId().startsWith(QLatin1String("ISW-ZDL1-WP11G")) ||
sensor->modelId().startsWith(QLatin1String("ISW-ZPR1-WP13")) ||
Expand All @@ -2303,6 +2359,7 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
sensor->modelId().startsWith(QLatin1String("TS01")) ||
sensor->modelId().startsWith(QLatin1String("TS02")) ||
sensor->modelId().startsWith(QLatin1String("TS03")) ||
sensor->modelId().startsWith(QLatin1String("TS0043")) || // to test
// Tuyatec
sensor->modelId().startsWith(QLatin1String("RH3040")) ||
sensor->modelId().startsWith(QLatin1String("RH3001")) ||
Expand Down Expand Up @@ -2509,6 +2566,7 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
sensor->modelId().startsWith(QLatin1String("3323")) ||
sensor->modelId().startsWith(QLatin1String("3326-L")) ||
sensor->modelId().startsWith(QLatin1String("3305-S")) ||
sensor->modelId().startsWith(QLatin1String("4655BC0")) ||
sensor->modelId() == QLatin1String("113D"))
{
val = sensor->getZclValue(*i, 0x0020); // battery voltage
Expand Down
11 changes: 11 additions & 0 deletions button_maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,17 @@
[1, "0x04", "LEVEL_CONTROL", "MOVE_WITH_ON_OFF", "1", "S_BUTTON_8", "S_BUTTON_ACTION_HOLD", "Move down (with on/off)"],
[1, "0x04", "LEVEL_CONTROL", "STOP_WITH_ON_OFF", "1", "S_BUTTON_8", "S_BUTTON_ACTION_LONG_RELEASED", "Stop_ (with on/off)"]
],
"Tuya3gangMap": [
[1, "0x01", "ONOFF", "0xfd", "0", "S_BUTTON_1", "S_BUTTON_ACTION_SHORT_RELEASED", "B1 short"],
[1, "0x01", "ONOFF", "0xfd", "1", "S_BUTTON_1", "S_BUTTON_ACTION_DOUBLE_PRESS", "B1 double"],
[1, "0x01", "ONOFF", "0xfd", "2", "S_BUTTON_1", "S_BUTTON_ACTION_LONG_RELEASED", "B1 long"],
[1, "0x02", "ONOFF", "0xfd", "0", "S_BUTTON_2", "S_BUTTON_ACTION_SHORT_RELEASED", "B2 short"],
[1, "0x02", "ONOFF", "0xfd", "1", "S_BUTTON_2", "S_BUTTON_ACTION_DOUBLE_PRESS", "B2 double"],
[1, "0x02", "ONOFF", "0xfd", "2", "S_BUTTON_2", "S_BUTTON_ACTION_LONG_RELEASED", "B2 long"],
[1, "0x03", "ONOFF", "0xfd", "0", "S_BUTTON_3", "S_BUTTON_ACTION_SHORT_RELEASED", "B3 short"],
[1, "0x03", "ONOFF", "0xfd", "1", "S_BUTTON_3", "S_BUTTON_ACTION_DOUBLE_PRESS", "B3 double"],
[1, "0x03", "ONOFF", "0xfd", "2", "S_BUTTON_3", "S_BUTTON_ACTION_LONG_RELEASED", "B3 long"]
],
"legrandSwitchRemote": [
[1, "0x01", "ONOFF", "ON", "0", "S_BUTTON_1", "S_BUTTON_ACTION_SHORT_RELEASED", "On"],
[1, "0x01", "ONOFF", "OFF", "0", "S_BUTTON_2", "S_BUTTON_ACTION_SHORT_RELEASED", "Off"],
Expand Down
59 changes: 58 additions & 1 deletion database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,45 @@ static int sqliteLoadLightNodeCallback(void *user, int ncols, char **colval , ch
return 0;
}

/*! Loads data (if available) for a LightNode from the database according to the adress
*/
QString DeRestPluginPrivate::loadDataForLightNodeFromDb(QString extAddress)
{

DBG_Assert(db != nullptr);

if (!db || extAddress.isEmpty())
{
return NULL;
}

QString sql = QString("SELECT manufacturername FROM nodes WHERE mac LIKE '%1%' COLLATE NOCASE").arg(extAddress);
DBG_Printf(DBG_INFO_L2, "sql exec %s\n", qPrintable(sql));

const char * val = nullptr;
sqlite3_stmt *res = NULL;
int rc;

rc = sqlite3_prepare_v2(db, qPrintable(sql), -1, &res, nullptr);
if (rc == SQLITE_OK)
{
rc = sqlite3_step(res);
}

if (rc == SQLITE_ROW)
{
val = reinterpret_cast<const char*>(sqlite3_column_text(res, 0));
DBG_Printf(DBG_INFO, "DB %s: %s\n", qPrintable(sql), val);
}

if (res)
{
rc = sqlite3_finalize(res);
}

return QString(val);
}

/*! Loads data (if available) for a LightNode from the database.
*/
void DeRestPluginPrivate::loadLightNodeFromDb(LightNode *lightNode)
Expand Down Expand Up @@ -3160,6 +3199,17 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
item = sensor.addItem(DataTypeUInt16, RStateSpectralZ);
item->setValue(0);
}
else if (sensor.type().endsWith(QLatin1String("Tuya")))
{
clusterId = clusterId ? clusterId : TUYA_CLUSTER_ID;

item = sensor.addItem(DataTypeInt16, RStateTemperature);
item->setValue(0);
item = sensor.addItem(DataTypeUInt16, RStateHumidity);
item->setValue(0);
item = sensor.addItem(DataTypeBool, RStateAlarm);
item->setValue(false);
}
else if (sensor.type().endsWith(QLatin1String("Humidity")))
{
if (sensor.fingerPrint().hasInCluster(RELATIVE_HUMIDITY_CLUSTER_ID))
Expand Down Expand Up @@ -3346,6 +3396,7 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
(sensor.modelId() != QLatin1String("TS0121")) &&
(!sensor.modelId().startsWith(QLatin1String("BQZ10-AU"))) &&
(!sensor.modelId().startsWith(QLatin1String("ROB_200"))) &&
(!sensor.modelId().startsWith(QLatin1String("lumi.plug.ma"))) &&
(sensor.modelId() != QLatin1String("Plug-230V-ZB3.0")) &&
(sensor.modelId() != QLatin1String("lumi.switch.b1naus01")) &&
(sensor.modelId() != QLatin1String("Connected socket outlet")) &&
Expand Down Expand Up @@ -3456,14 +3507,16 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
sensor.modelId() == QLatin1String("TS0601") ) // Tuya
{
sensor.addItem(DataTypeUInt8, RStateValve);
sensor.addItem(DataTypeBool, RStateLowBattery);
item = sensor.addItem(DataTypeBool, RStateLowBattery);
item->setValue(false);
}

if (sensor.modelId() == QLatin1String("kud7u2l") || // Tuya
sensor.modelId() == QLatin1String("TS0601") ) // Tuya
{
sensor.addItem(DataTypeString, RConfigPreset);
sensor.addItem(DataTypeBool, RConfigLocked);
sensor.addItem(DataTypeBool, RConfigWindowOpen);
}

if (sensor.modelId().startsWith(QLatin1String("SPZB"))) // Eurotronic Spirit
Expand Down Expand Up @@ -3510,6 +3563,10 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
{
clusterId = POWER_CONFIGURATION_CLUSTER_ID;
}
if (sensor.manufacturer() == QLatin1String("_TYST11_xu1rkty3"))
{
clusterId = TUYA_CLUSTER_ID;
}
item = sensor.addItem(DataTypeUInt8, RStateBattery);
item->setValue(100);
}
Expand Down
1 change: 1 addition & 0 deletions de_web.pro
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ HEADERS = bindings.h \
rule.h \
scene.h \
sensor.h \
tuya.h \
websocket_server.h

SOURCES = authorisation.cpp \
Expand Down
Loading

0 comments on commit c9d02c1

Please sign in to comment.