Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support for ORVIBO switch, dimmer and motion sensor
  • Loading branch information
udoewich authored and manup committed Aug 26, 2019
1 parent 24454d8 commit 95aa010
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
7 changes: 6 additions & 1 deletion bindings.cpp
Expand Up @@ -1521,6 +1521,9 @@ void DeRestPluginPrivate::checkLightBindingsForAttributeReporting(LightNode *lig
else if (lightNode->modelId() == QLatin1String("SPLZB-131"))
{
}
else if (lightNode->manufacturer() == QString("欧瑞博") || lightNode->manufacturer() == QLatin1String("ORVIBO"))
{
}
else
{
return;
Expand Down Expand Up @@ -1734,7 +1737,9 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
// Sinope
sensor->modelId() == QLatin1String("WL4200S") ||
//LifeControl smart plug
sensor->modelId() == QLatin1String("RICI01"))
sensor->modelId() == QLatin1String("RICI01"))||
// ORVIBO
sensor->modelId().startsWith(QLatin1String("SN10ZW")))
{
deviceSupported = true;
if (!sensor->node()->nodeDescriptor().receiverOnWhenIdle() ||
Expand Down
74 changes: 73 additions & 1 deletion de_web_plugin.cpp
Expand Up @@ -209,6 +209,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, "SN10ZW", jennicMacPrefix }, // ORVIBO motion sensor
{ 0, nullptr, 0 }
};

Expand Down Expand Up @@ -1547,6 +1548,7 @@ void DeRestPluginPrivate::addLightNode(const deCONZ::Node *node)

case DEV_ID_MAINS_POWER_OUTLET:
case DEV_ID_HA_ONOFF_LIGHT:
case DEV_ID_LEVEL_CONTROL_SWITCH:
case DEV_ID_ONOFF_OUTPUT:
case DEV_ID_LEVEL_CONTROLLABLE_OUTPUT:
case DEV_ID_HA_DIMMABLE_LIGHT:
Expand Down Expand Up @@ -1760,6 +1762,24 @@ void DeRestPluginPrivate::addLightNode(const deCONZ::Node *node)
{ q->nodeUpdated(lightNode.address().ext(), QLatin1String("modelid"), lightNode.modelId()); }
}

// "translate" ORVIBO vendor name
if (lightNode.manufacturer() == QString("欧瑞博"))
{
lightNode.setManufacturerName(QLatin1String("ORVIBO"));
lightNode.setNeedSaveDatabase(true);
}
// replace ORVIBO model IDs
if (lightNode.modelId() == QLatin1String("abb71ca5fe1846f185cfbda554046cce"))
{
lightNode.setModelId(QLatin1String("T10D1ZW dimmer"));
lightNode.setNeedSaveDatabase(true);
}
else if (lightNode.modelId() == QLatin1String("545df2981b704114945f6df1c780515a"))
{
lightNode.setModelId(QLatin1String("T10W1ZW switch"));
lightNode.setNeedSaveDatabase(true);
}

// add light node to default group
GroupInfo *groupInfo = getGroupInfo(&lightNode, gwGroup0);
if (!groupInfo)
Expand Down Expand Up @@ -2097,6 +2117,7 @@ LightNode *DeRestPluginPrivate::updateLightNode(const deCONZ::NodeEvent &event)
case DEV_ID_ZLL_DIMMABLE_PLUGIN_UNIT:
case DEV_ID_Z30_DIMMABLE_PLUGIN_UNIT:
case DEV_ID_HA_ONOFF_LIGHT:
case DEV_ID_LEVEL_CONTROL_SWITCH:
case DEV_ID_ONOFF_OUTPUT:
case DEV_ID_LEVEL_CONTROLLABLE_OUTPUT:
case DEV_ID_ZLL_ONOFF_LIGHT:
Expand Down Expand Up @@ -2473,6 +2494,17 @@ LightNode *DeRestPluginPrivate::updateLightNode(const deCONZ::NodeEvent &event)
QString str = ia->toString();
if (!str.isEmpty() && str != lightNode->manufacturer())
{
if (str == QString("欧瑞博"))
{
if (lightNode->manufacturer() == QLatin1String("ORVIBO"))
{
continue; // skip if already 'translated'
}
else
{
str = QLatin1String("ORVIBO");
}
}
lightNode->setManufacturerName(str);
lightNode->setNeedSaveDatabase(true);
queSaveDb(DB_LIGHTS, DB_LONG_SAVE_DELAY);
Expand All @@ -2486,6 +2518,28 @@ LightNode *DeRestPluginPrivate::updateLightNode(const deCONZ::NodeEvent &event)
ResourceItem *item = lightNode->item(RAttrModelId);
if (item && !str.isEmpty() && str != item->toString())
{
if (str == QLatin1String("abb71ca5fe1846f185cfbda554046cce"))
{
if (lightNode->modelId().startsWith(QLatin1String("T10D1ZW")))
{
continue; // skip if already replaced
}
else
{
str = QLatin1String("T10D1ZW dimmer");
}
}
else if (str == QLatin1String("545df2981b704114945f6df1c780515a"))
{
if (lightNode->modelId().startsWith(QLatin1String("T10W1ZW")))
{
continue; // skip if already replaced
}
else
{
str = QLatin1String("T10W1ZW switch");
}
}
lightNode->setModelId(str);
item->setValue(str);
lightNode->setNeedSaveDatabase(true);
Expand Down Expand Up @@ -3508,6 +3562,11 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const deCONZ::
else if (modelId.isEmpty() && j->id() == 0x0005) // model id
{
modelId = j->toString().trimmed();
// replace ORVIBO model ID
if (modelId == QLatin1String("895a2d80097f4ae2b2d40500d5e03dcc"))
{
modelId = QLatin1String("SN10ZW motion sensor");
}
}
}
}
Expand Down Expand Up @@ -3627,7 +3686,8 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const deCONZ::
}
else if (modelId.startsWith(QLatin1String("PIR_")) || // Heiman motion sensor
modelId == QLatin1String("3AFE14010402000D") || // Konke motion sensor
modelId.startsWith(QLatin1String("902010/22"))) // Bitron motion sensor
modelId.startsWith(QLatin1String("902010/22")) || // Bitron motion sensor
modelId.startsWith(QLatin1String("SN10ZW"))) // ORVIBO motion sensor
{
fpPresenceSensor.inClusters.push_back(ci->id());
}
Expand Down Expand Up @@ -5985,6 +6045,17 @@ void DeRestPluginPrivate::updateSensorNode(const deCONZ::NodeEvent &event)
{
if (i->modelId() != str)
{
if (str == QLatin1String("895a2d80097f4ae2b2d40500d5e03dcc"))
{
if (i->modelId().startsWith(QLatin1String("SN10ZW")))
{
continue; // skip if already replaced
}
else
{
str = QLatin1String("SN10ZW motion sensor");
}
}
i->setModelId(str);
i->setNeedSaveDatabase(true);
checkInstaModelId(&*i);
Expand Down Expand Up @@ -7285,6 +7356,7 @@ bool DeRestPluginPrivate::processZclAttributes(LightNode *lightNode)
//case DEV_ID_ZLL_DIMMABLE_LIGHT: // same as DEV_ID_HA_ONOFF_LIGHT
case DEV_ID_ZLL_DIMMABLE_PLUGIN_UNIT:
case DEV_ID_Z30_DIMMABLE_PLUGIN_UNIT:
case DEV_ID_LEVEL_CONTROL_SWITCH:
//fall through

case DEV_ID_MAINS_POWER_OUTLET:
Expand Down
5 changes: 4 additions & 1 deletion light_node.cpp
Expand Up @@ -370,9 +370,11 @@ void LightNode::setHaEndpoint(const deCONZ::SimpleDescriptor &endpoint)
}
else if (i->id() == COLOR_CLUSTER_ID)
{
if (manufacturerCode() == VENDOR_NONE && deviceId == DEV_ID_ZLL_DIMMABLE_LIGHT)
if ((manufacturerCode() == VENDOR_NONE && deviceId == DEV_ID_ZLL_DIMMABLE_LIGHT) ||
(manufacturerCode() == VENDOR_NONE && deviceId == DEV_ID_LEVEL_CONTROL_SWITCH))
{
// GLEDOPTO GL-C-009 advertises non-functional color cluster
// ORVIBO T10D1ZW in-wall dimmer does the same
}
else
{
Expand Down Expand Up @@ -490,6 +492,7 @@ void LightNode::setHaEndpoint(const deCONZ::SimpleDescriptor &endpoint)
else { ltype = QLatin1String("Dimmable light"); }
}
break;
case DEV_ID_LEVEL_CONTROL_SWITCH: ltype = QLatin1String("Level control switch"); break;
case DEV_ID_ONOFF_OUTPUT: ltype = QLatin1String("On/Off output"); break;
case DEV_ID_LEVEL_CONTROLLABLE_OUTPUT: ltype = QLatin1String("Level controllable output"); break;
case DEV_ID_Z30_ONOFF_PLUGIN_UNIT: ltype = QLatin1String("On/Off plug-in unit"); break;
Expand Down

0 comments on commit 95aa010

Please sign in to comment.