Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DDF for Danfoss Ally thermostat #5793

Merged
merged 6 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1456,8 +1456,7 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)

return sendConfigureReportingRequest(bt, {rq, rq2, rq3, rq4, rq5});
}
else if (modelId == QLatin1String("eTRV0100") || // Danfoss Ally
modelId == QLatin1String("TRV001") || // Hive TRV
else if (modelId == QLatin1String("TRV001") || // Hive TRV
modelId == QLatin1String("eT093WRO")) // POPP smart thermostat
{
rq.dataType = deCONZ::Zcl16BitInt;
Expand Down Expand Up @@ -1687,8 +1686,7 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
}
else if (bt.binding.clusterId == THERMOSTAT_UI_CONFIGURATION_CLUSTER_ID)
{
if (modelId == QLatin1String("eTRV0100") || // Danfoss Ally
modelId == QLatin1String("TRV001") || // Hive TRV
if (modelId == QLatin1String("TRV001") || // Hive TRV
modelId == QLatin1String("eT093WRO")) // POPP smart thermostat
{
rq.dataType = deCONZ::Zcl8BitEnum;
Expand Down Expand Up @@ -1726,8 +1724,7 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
}
else if (bt.binding.clusterId == DIAGNOSTICS_CLUSTER_ID)
{
if (modelId == QLatin1String("eTRV0100") || // Danfoss Ally
modelId == QLatin1String("TRV001") || // Hive TRV
if (modelId == QLatin1String("TRV001") || // Hive TRV
modelId == QLatin1String("eT093WRO")) // POPP smart thermostat
{
rq.dataType = deCONZ::Zcl16BitBitMap;
Expand Down Expand Up @@ -1832,8 +1829,7 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
rq.maxInterval = 900; // value used by Hue bridge
rq.reportableChange8bit = 4; // value used by Hue bridge
}
else if (modelId == QLatin1String("eTRV0100") || // Danfoss Ally
modelId == QLatin1String("eT093WRO") || // POPP smart thermostat
else if (modelId == QLatin1String("eT093WRO") || // POPP smart thermostat
modelId == QLatin1String("TRV001") || // Hive TRV
modelId == QLatin1String("0x8020") || // Danfoss RT24V Display thermostat
modelId == QLatin1String("0x8021") || // Danfoss RT24V Display thermostat with floor sensor
Expand Down Expand Up @@ -3184,7 +3180,6 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
sensor->modelId() == QLatin1String("TH01") ||
sensor->modelId() == QLatin1String("DS01") ||
// Danfoss
sensor->modelId() == QLatin1String("eTRV0100") ||
sensor->modelId() == QLatin1String("0x8020") ||
sensor->modelId() == QLatin1String("0x8021") ||
sensor->modelId() == QLatin1String("0x8030") ||
Expand Down Expand Up @@ -3507,8 +3502,7 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
}
else if (*i == DIAGNOSTICS_CLUSTER_ID)
{
if (sensor->modelId() == QLatin1String("eTRV0100") || // Danfoss Ally
sensor->modelId() == QLatin1String("TRV001") || // Hive TRV
if (sensor->modelId() == QLatin1String("TRV001") || // Hive TRV
sensor->modelId() == QLatin1String("eT093WRO")) // POPP smart thermostat
{
val = sensor->getZclValue(*i, 0x4000); // SW error code
Expand Down
3 changes: 1 addition & 2 deletions database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3931,8 +3931,7 @@ static int sqliteLoadAllSensorsCallback(void *user, int ncols, char **colval , c
sensor.addItem(DataTypeString, RConfigMode);
sensor.addItem(DataTypeString, RConfigFanMode);
}
else if (sensor.modelId() == QLatin1String("eTRV0100") || // Danfoss Ally
sensor.modelId() == QLatin1String("TRV001") || // Hive TRV
else if (sensor.modelId() == QLatin1String("TRV001") || // Hive TRV
sensor.modelId() == QLatin1String("eT093WRO")) // POPP smart thermostat
{
sensor.addItem(DataTypeUInt8, RStateValve);
Expand Down
96 changes: 8 additions & 88 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ static const SupportedDevice supportedDevices[] = {
{ VENDOR_SCHNEIDER, "CCT593011_AS", emberMacPrefix }, // LK Wiser Temperature and Humidity Sensor
{ VENDOR_SCHNEIDER, "CCT595011_AS", emberMacPrefix }, // LK Wiser Motion Sensor
{ VENDOR_DANFOSS, "eT093WRO", silabs5MacPrefix }, // POPP Smart Thermostat
{ VENDOR_DANFOSS, "eTRV0100", silabs2MacPrefix }, // Danfoss Ally thermostat
{ VENDOR_DANFOSS, "0x8020", silabs6MacPrefix }, // Danfoss RT24V Display thermostat
{ VENDOR_DANFOSS, "0x8021", silabs6MacPrefix }, // Danfoss RT24V Display thermostat with floor sensor
{ VENDOR_DANFOSS, "0x8030", silabs6MacPrefix }, // Danfoss RTbattery Display thermostat
Expand Down Expand Up @@ -1308,7 +1307,7 @@ void DeRestPluginPrivate::apsdeDataIndication(const deCONZ::ApsDataIndication &i
break;

case POWER_CONFIGURATION_CLUSTER_ID:
if (!DEV_TestStrict()) { handlePowerConfigurationClusterIndication(ind, zclFrame); }
if (!DEV_TestStrict() && !devManaged) { handlePowerConfigurationClusterIndication(ind, zclFrame); }
break;

case XAL_CLUSTER_ID:
Expand Down Expand Up @@ -1341,11 +1340,11 @@ void DeRestPluginPrivate::apsdeDataIndication(const deCONZ::ApsDataIndication &i
break;

case THERMOSTAT_UI_CONFIGURATION_CLUSTER_ID:
if (!DEV_TestStrict()) { handleThermostatUiConfigurationClusterIndication(ind, zclFrame); }
if (!DEV_TestStrict() && !devManaged) { handleThermostatUiConfigurationClusterIndication(ind, zclFrame); }
break;

case DIAGNOSTICS_CLUSTER_ID:
if (!DEV_TestStrict()) { handleDiagnosticsClusterIndication(ind, zclFrame); }
if (!DEV_TestStrict() && !devManaged) { handleDiagnosticsClusterIndication(ind, zclFrame); }
break;

case IDENTIFY_CLUSTER_ID:
Expand Down Expand Up @@ -6412,7 +6411,6 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const deCONZ::
{
// Many Xiaomi devices advertise non-functional Time cluster, so better use whitelist.
if (modelId == QLatin1String("Thermostat") || // eCozy
modelId == QLatin1String("eTRV0100") || // Danfoss
modelId == QLatin1String("eT093WRO")) // POPP smart thermostat
{
fpTimeSensor.inClusters.push_back(ci->id());
Expand Down Expand Up @@ -7725,8 +7723,7 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const SensorFi
sensorNode.addItem(DataTypeString, RConfigMode);
sensorNode.addItem(DataTypeString, RConfigFanMode);
}
else if (modelId == QLatin1String("eTRV0100") || // Danfoss Ally
modelId == QLatin1String("TRV001") || // Hive TRV
else if (modelId == QLatin1String("TRV001") || // Hive TRV
modelId == QLatin1String("eT093WRO")) // POPP smart thermostat
{
sensorNode.addItem(DataTypeUInt8, RStateValve);
Expand Down Expand Up @@ -8597,7 +8594,6 @@ void DeRestPluginPrivate::updateSensorNode(const deCONZ::NodeEvent &event)
case BINARY_INPUT_CLUSTER_ID:
case DOOR_LOCK_CLUSTER_ID:
case SAMJIN_CLUSTER_ID:
case TIME_CLUSTER_ID:
case VENDOR_CLUSTER_ID:
case BOSCH_AIR_QUALITY_CLUSTER_ID:
break;
Expand Down Expand Up @@ -10067,84 +10063,6 @@ void DeRestPluginPrivate::updateSensorNode(const deCONZ::NodeEvent &event)
updateSensorEtag(&*i);
}
}
else if (event.clusterId() == TIME_CLUSTER_ID)
{
bool updated = false;
const QDateTime epoch = QDateTime(QDate(2000, 1, 1), QTime(0, 0), Qt::UTC);

if (!DEV_TestStrict())
{
for (;ia != enda; ++ia)
{
if (ia->id() == 0x0000) // Time (utc, in UTC)
{
if (updateType != NodeValue::UpdateInvalid)
{
i->setZclValue(updateType, event.endpoint(), event.clusterId(), ia->id(), ia->numericValue());
}
QDateTime time = epoch.addSecs(ia->numericValue().u32);
ResourceItem *item = i->item(RStateUtc);
if (item && item->toVariant().toDateTime().toMSecsSinceEpoch() != time.toMSecsSinceEpoch())
{
item->setValue(time);
enqueueEvent(Event(RSensors, RStateUtc, i->id(), item));
updated = true;
}
const qint32 drift = QDateTime::currentDateTimeUtc().secsTo(time);
DBG_Printf(DBG_INFO, " >>> %s sensor %s: drift %d\n", qPrintable(i->type()), qPrintable(i->name()), drift);

if (!i->mustRead(WRITE_TIME))
{
if (drift < -10 || drift > 10)
{
DBG_Printf(DBG_INFO, " >>> %s sensor %s: drift: %d: set WRITE_TIME\n", qPrintable(i->type()), qPrintable(i->name()), drift);
i->setNextReadTime(WRITE_TIME, queryTime);
i->setLastRead(WRITE_TIME, idleTotalCounter);
i->enableRead(WRITE_TIME);
queryTime = queryTime.addSecs(1);
}
}
}
else if (ia->id() == 0x0007) // Local Time (u32, in local time)
{
if (updateType != NodeValue::UpdateInvalid)
{
i->setZclValue(updateType, event.endpoint(), event.clusterId(), ia->id(), ia->numericValue());
}
QDateTime time = epoch.addSecs(ia->numericValue().u32 - QDateTime::currentDateTime().offsetFromUtc());
ResourceItem *item = i->item(RStateLocaltime);
if (item && item->toVariant().toDateTime().toMSecsSinceEpoch() != time.toMSecsSinceEpoch())
{
item->setValue(time);
enqueueEvent(Event(RSensors, RStateLocaltime, i->id(), item));
updated = true;
}
}
else if (ia->id() == 0x0008) // Last set time (utc, in UTC)
{
if (updateType != NodeValue::UpdateInvalid)
{
i->setZclValue(updateType, event.endpoint(), event.clusterId(), ia->id(), ia->numericValue());
}
QDateTime time = epoch.addSecs(ia->numericValue().u32);
ResourceItem *item = i->item(RStateLastSet);
if (item && item->toVariant().toDateTime().toMSecsSinceEpoch() != time.toMSecsSinceEpoch())
{
item->setValue(time);
enqueueEvent(Event(RSensors, RStateLastSet, i->id(), item));
updated = true;
}
}
}
}
if (updated)
{
i->updateStateTimestamp();
i->setNeedSaveDatabase(true);
enqueueEvent(Event(RSensors, RStateLastUpdated, i->id()));
updateSensorEtag(&*i);
}
}
}
}
}
Expand Down Expand Up @@ -16725,6 +16643,9 @@ void DeRestPlugin::idleTimerFired()

if ((d->otauLastBusyTimeDelta() > OTA_LOW_PRIORITY_TIME) && (sensorNode->lastRead(READ_BINDING_TABLE) < (d->idleTotalCounter - IDLE_READ_LIMIT)))
{
Device *device = sensorNode->parentResource() ? static_cast<Device*>(sensorNode->parentResource()) : nullptr;
const bool devManaged = device && device->managed();

std::vector<quint16>::const_iterator ci = sensorNode->fingerPrint().inClusters.begin();
std::vector<quint16>::const_iterator cend = sensorNode->fingerPrint().inClusters.end();
for (;ci != cend; ++ci)
Expand Down Expand Up @@ -16771,7 +16692,7 @@ void DeRestPlugin::idleTimerFired()
}
}

if (*ci == THERMOSTAT_CLUSTER_ID)
if (*ci == THERMOSTAT_CLUSTER_ID && !devManaged)
{
if (sensorNode->modelId() == QLatin1String("Thermostat")) // eCozy
{
Expand All @@ -16790,7 +16711,6 @@ void DeRestPlugin::idleTimerFired()
sensorNode->modelId().startsWith(QLatin1String("TRV001")) || // Hive TRV
sensorNode->modelId().startsWith(QLatin1String("TH112")) || // Sinope devices
sensorNode->modelId().startsWith(QLatin1String("TH1300ZB")) || // Sinope devices
sensorNode->modelId().startsWith(QLatin1String("eTRV0100")) || // Danfoss Ally
sensorNode->modelId().startsWith(QLatin1String("eT093WRO")) || // POPP smart thermostat
sensorNode->modelId().startsWith(QLatin1String("0x8020")) || // Danfoss RT24V Display thermostat
sensorNode->modelId().startsWith(QLatin1String("0x8021")) || // Danfoss RT24V Display thermostat with floor sensor
Expand Down
13 changes: 13 additions & 0 deletions devices/danfoss/danfoss_errorcode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var arr = [];
var hex;
let str = Attr.val;

for (var i = 0; i < str.length; i++)
{
hex = str.charCodeAt(i).toString(16);
if (hex.length < 2) { hex = "0" + hex.toUpperCase(); }
arr.push(hex);
}

var res = arr.join("");
Item.val = res.toString(16);
17 changes: 17 additions & 0 deletions devices/danfoss/danfoss_windowopen_state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
switch (Attr.val) {
case "0":
Item.val = "Quarantine";
break;
case "1":
Item.val = "Closed";
break;
case "2":
Item.val = "Hold";
break;
case "3":
Item.val = "Open";
break;
case "4":
Item.val = "Open (external), closed (internal)";
break;
}
Loading