Skip to content

Commit

Permalink
Merge remote-tracking branch 'bastshoes/MCLH-08'
Browse files Browse the repository at this point in the history
  • Loading branch information
manup committed Oct 22, 2019
2 parents f4702c3 + 0436805 commit ac43c16
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
10 changes: 10 additions & 0 deletions bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,8 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
sensor->modelId() == QLatin1String("WL4200S") ||
//LifeControl smart plug
sensor->modelId() == QLatin1String("RICI01") ||
//LifeControl enviroment sensor
sensor->modelId() == QLatin1String("VOC_Sensor") ||
//Legrand Plug
sensor->modelId() == QLatin1String("Connected outlet") ||
//Legrand shutter switch
Expand Down Expand Up @@ -2235,6 +2237,14 @@ bool DeRestPluginPrivate::checkSensorBindingsForClientClusters(Sensor *sensor)
srcEndpoints.push_back(0x04);
sensor->setMgmtBindSupported(true);
}
// LifeControl Enviroment Sensor
else if (sensor->modelId().startsWith(QLatin1String("VOC_Sensor")))
{
clusters.push_back(TEMPERATURE_MEASUREMENT_CLUSTER_ID);
srcEndpoints.push_back(0x00);
srcEndpoints.push_back(0x01);
sensor->setMgmtBindSupported(true);
}
else
{
return false;
Expand Down
61 changes: 58 additions & 3 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ static const SupportedDevice supportedDevices[] = {
{ VENDOR_EMBER, "3AFE140103020000", konkeMacPrefix }, // Konke Kit Pro-FT Temp Humidity Sensor
{ VENDOR_EMBER, "3AFE130104020015", konkeMacPrefix }, // Konke Kit Pro-Door Entry Sensor
{ VENDOR_NONE, "RICI01", tiMacPrefix}, // LifeControl smart plug
{ VENDOR_JENNIC, "VOC_Sensor", jennicMacPrefix}, //LifeControl Enviroment sensor
{ VENDOR_JENNIC, "SN10ZW", jennicMacPrefix }, // ORVIBO motion sensor
{ VENDOR_OSRAM_STACK, "SF2", heimanMacPrefix }, // ORVIBO (Heiman) smoke sensor
{ VENDOR_LEGRAND, "Dimmer switch w/o neutral", legrandMacPrefix }, // Legrand Dimmer switch wired
Expand Down Expand Up @@ -3880,13 +3881,27 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const deCONZ::

case TEMPERATURE_MEASUREMENT_CLUSTER_ID:
{
fpTemperatureSensor.inClusters.push_back(ci->id());
if (modelId.startsWith(QLatin1String("VOC_Sensor") && i->endpoint() == 0x01)
{
fpHumiditySensor.inClusters.push_back(ci->id());
}
else
{
fpTemperatureSensor.inClusters.push_back(ci->id());
}
}
break;

case RELATIVE_HUMIDITY_CLUSTER_ID:
{
fpHumiditySensor.inClusters.push_back(ci->id());
if (modelId.startsWith(QLatin1String("VOC_Sensor"))
{
// Ignore RELATIVE HUMIDITY CLUSTER
}
else
{
fpHumiditySensor.inClusters.push_back(ci->id());
}
}
break;

Expand Down Expand Up @@ -4002,7 +4017,14 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const deCONZ::

case THERMOSTAT_CLUSTER_ID:
{
fpThermostatSensor.inClusters.push_back(ci->id());
if (modelId.startsWith(QLatin1String("VOC_Sensor"))
{
// Ignore THERMOSTAT CLUSTER
}
else
{
fpThermostatSensor.inClusters.push_back(ci->id());
}
}
break;

Expand Down Expand Up @@ -5762,6 +5784,39 @@ void DeRestPluginPrivate::updateSensorNode(const deCONZ::NodeEvent &event)

updateSensorEtag(&*i);
}

else if (i->modelId().startsWith(QLatin1String("VOC_Sensor")) && ia->id() == 0x0001) // LifeControl MCLH-08 relative humidity
{
// humidity sensor values are transferred via temperature cluster 0x0001 attribute
// see: https://github.com/dresden-elektronik/deconz-rest-plugin/pull/1964

if (updateType != NodeValue::UpdateInvalid)
{
i->setZclValue(updateType, event.clusterId(), 0x0001, ia->numericValue());
pushZclValueDb(event.node()->address().ext(), event.endpoint(), event.clusterId(), ia->id(), ia->numericValue().u16);
}

int humidity = ia->numericValue().u16;
ResourceItem *item = i->item(RStateHumidity);

if (item)
{
ResourceItem *item2 = i->item(RConfigOffset);
if (item2 && item2->toNumber() != 0)
{
qint16 _humidity = humidity + item2->toNumber();
humidity = _humidity < 0 ? 0 : _humidity > 10000 ? 10000 : _humidity;
}
item->setValue(humidity);
i->updateStateTimestamp();
i->setNeedSaveDatabase(true);
Event e(RSensors, RStateHumidity, i->id(), item);
enqueueEvent(e);
enqueueEvent(Event(RSensors, RStateLastUpdated, i->id()));
}

updateSensorEtag(&*i);
}
}
}
else if (event.clusterId() == RELATIVE_HUMIDITY_CLUSTER_ID)
Expand Down

0 comments on commit ac43c16

Please sign in to comment.