Skip to content

Commit

Permalink
Added initial support for Sonoff SNZB-01 (WB01)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwoopX authored and manup committed Aug 12, 2020
1 parent e7f975a commit eea1f34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bindings.cpp
Expand Up @@ -2272,6 +2272,7 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
// Sage
sensor->modelId() == QLatin1String("Bell") ||
// Sonoff
sensor->modelId() == QLatin1String("WB01") ||
sensor->modelId() == QLatin1String("MS01") ||
sensor->modelId() == QLatin1String("TH01") ||
sensor->modelId() == QLatin1String("DS01") ||
Expand Down Expand Up @@ -2721,7 +2722,9 @@ bool DeRestPluginPrivate::checkSensorBindingsForClientClusters(Sensor *sensor)
srcEndpoints.push_back(sensor->fingerPrint().endpoint);
}
// IKEA Trådfri on/off switch
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI on/off switch")))
// Sonoff SNZB-01
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI on/off switch")) ||
sensor->modelId().startsWith(QLatin1String("WB01")))
{
clusters.push_back(ONOFF_CLUSTER_ID);
srcEndpoints.push_back(sensor->fingerPrint().endpoint);
Expand Down Expand Up @@ -3045,7 +3048,8 @@ void DeRestPluginPrivate::checkSensorGroup(Sensor *sensor)
// sensor->modelId().startsWith(QLatin1String("SYMFONISK")) ||
sensor->modelId().startsWith(QLatin1String("902010/23")) || // bitron remote
sensor->modelId().startsWith(QLatin1String("Bell")) || // Sage doorbell sensor
sensor->modelId().startsWith(QLatin1String("ZBT-DIMSwitch"))) // Linkind 1 key Remote Control / ZS23000178
sensor->modelId().startsWith(QLatin1String("ZBT-DIMSwitch")) || // Linkind 1 key Remote Control / ZS23000178
sensor->modelId().startsWith(QLatin1String("WB01"))) // Sonoff SNZB-01
{

}
Expand Down
1 change: 1 addition & 0 deletions de_web_plugin.cpp
Expand Up @@ -348,6 +348,7 @@ static const SupportedDevice supportedDevices[] = {
{ VENDOR_PLUGWISE_BV, "160-01", emberMacPrefix }, // Plugwise smart plug
{ VENDOR_NIKO_NV, "Connected socket outlet", konkeMacPrefix }, // Niko smart socket 170-33505
{ VENDOR_ATMEL, "Bell", dishMacPrefix }, // Sage doorbell sensor
{ VENDOR_NONE, "WB01", tiMacPrefix }, // Sonoff SNZB-01
{ VENDOR_NONE, "MS01", tiMacPrefix }, // Sonoff SNZB-03
{ VENDOR_NONE, "TH01", tiMacPrefix }, // Sonoff SNZB-02
{ VENDOR_NONE, "DS01", tiMacPrefix }, // Sonoff SNZB-04
Expand Down
12 changes: 12 additions & 0 deletions sensor.cpp
Expand Up @@ -869,6 +869,14 @@ static const Sensor::ButtonMap sageMap[] = {
{ Sensor::ModeNone, 0x00, 0x0000, 0x00, 0, 0, nullptr }
};

static const Sensor::ButtonMap sonoffOnOffMap[] = {
// mode ep cluster cmd param button name
{ Sensor::ModeScenes, 0x01, 0x0006, 0x01, 0, S_BUTTON_1 + S_BUTTON_ACTION_SHORT_RELEASED, "On" },
{ Sensor::ModeScenes, 0x01, 0x0006, 0x00, 0, S_BUTTON_2 + S_BUTTON_ACTION_SHORT_RELEASED, "Off" },
// end
{ Sensor::ModeNone, 0x00, 0x0000, 0x00, 0, 0, nullptr }
};

/*! Returns a fingerprint as JSON string. */
QString SensorFingerprint::toString() const
{
Expand Down Expand Up @@ -1479,6 +1487,10 @@ const Sensor::ButtonMap *Sensor::buttonMap()
{
if (modelid == QLatin1String("ZBT-DIMSwitch")) { m_buttonMap = ikeaOnOffMap; }
}
else if (manufacturer == QLatin1String("eWeLink"))
{
if (modelid == QLatin1String("WB01")) { m_buttonMap = sonoffOnOffMap; }
}
}

return m_buttonMap;
Expand Down

0 comments on commit eea1f34

Please sign in to comment.