Skip to content

Commit

Permalink
Bug fixes Trådfri open/close remote and new Trådfri motion sensor.
Browse files Browse the repository at this point in the history
See #1121 and #1676
- Consistent check on `modelId()`;
- Whitelist open/close remote and motion sensor for group binding;
- Add final ModeNode entry to button map for on/off switch and open/close remote.
  • Loading branch information
ebaauw authored and manup committed Aug 28, 2019
1 parent dd7962e commit dc0d508
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
19 changes: 16 additions & 3 deletions bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,19 @@ bool DeRestPluginPrivate::checkSensorBindingsForClientClusters(Sensor *sensor)
clusters.push_back(ONOFF_CLUSTER_ID);
srcEndpoints.push_back(sensor->fingerPrint().endpoint);
}
// IKEA Trådfri open/close remote
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI open/close remote")))
{
clusters.push_back(WINDOW_COVERING_CLUSTER_ID);
srcEndpoints.push_back(sensor->fingerPrint().endpoint);
}
// IKEA Trådfri motion sensor
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI motion sensor")))
{
clusters.push_back(ONOFF_CLUSTER_ID);
clusters.push_back(LEVEL_CLUSTER_ID);
srcEndpoints.push_back(sensor->fingerPrint().endpoint);
}
else if (sensor->modelId().startsWith(QLatin1String("D1")))
{
clusters.push_back(ONOFF_CLUSTER_ID);
Expand Down Expand Up @@ -2307,9 +2320,9 @@ void DeRestPluginPrivate::checkSensorGroup(Sensor *sensor)
return;
}
}
else if (sensor->modelId() == QLatin1String("TRADFRI on/off switch") ||
sensor->modelId() == QLatin1String("TRADFRI open/close remote") ||
sensor->modelId() == QLatin1String("TRADFRI motion sensor"))
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI on/off switch")) ||
sensor->modelId().startsWith(QLatin1String("TRADFRI open/close remote")) ||
sensor->modelId().startsWith(QLatin1String("TRADFRI motion sensor")))
{

}
Expand Down
12 changes: 7 additions & 5 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3039,9 +3039,9 @@ void DeRestPluginPrivate::checkSensorButtonEvent(Sensor *sensor, const deCONZ::A
sensor->setMode(Sensor::ModeDimmer);
}
}
else if (sensor->modelId() == QLatin1String("TRADFRI on/off switch") ||
sensor->modelId() == QLatin1String("TRADFRI open/close remote") ||
sensor->modelId() == QLatin1String("TRADFRI motion sensor"))
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI on/off switch")) ||
sensor->modelId().startsWith(QLatin1String("TRADFRI open/close remote")) ||
sensor->modelId().startsWith(QLatin1String("TRADFRI motion sensor")))
{
checkReporting = true;

Expand Down Expand Up @@ -3460,7 +3460,7 @@ void DeRestPluginPrivate::checkSensorButtonEvent(Sensor *sensor, const deCONZ::A
#endif

quint8 pl0 = zclFrame.payload().isEmpty() ? 0 : zclFrame.payload().at(0);
DBG_Printf(DBG_INFO, "no button handler for: %s ep: 0x%02X cl: 0x%04X cmd: 0x%02X pl[0]: 0%02X\n",
DBG_Printf(DBG_INFO, "no button handler for: %s ep: 0x%02X cl: 0x%04X cmd: 0x%02X pl[0]: 0x%02X\n",
qPrintable(sensor->modelId()), ind.srcEndpoint(), ind.clusterId(), zclFrame.commandId(), pl0);
}

Expand Down Expand Up @@ -13547,7 +13547,9 @@ void DeRestPluginPrivate::delayedFastEnddeviceProbe(const deCONZ::NodeEvent *eve
queryTime = queryTime.addSecs(1);
}
}
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI on/off switch")))
else if (sensor->modelId().startsWith(QLatin1String("TRADFRI on/off switch")) ||
sensor->modelId().startsWith(QLatin1String("TRADFRI open/close remote")) ||
sensor->modelId().startsWith(QLatin1String("TRADFRI motion sensor")))
{
checkSensorGroup(sensor);

Expand Down
14 changes: 9 additions & 5 deletions sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ static const Sensor::ButtonMap ikeaOnOffMap[] = {
{ Sensor::ModeScenes, 0x01, 0x0008, 0x01, 1, S_BUTTON_2 + S_BUTTON_ACTION_HOLD, "Move down" },
{ Sensor::ModeScenes, 0x01, 0x0008, 0x07, 0, S_BUTTON_1 + S_BUTTON_ACTION_LONG_RELEASED, "Stop (with on/off)" },
{ Sensor::ModeScenes, 0x01, 0x0008, 0x07, 1, S_BUTTON_2 + S_BUTTON_ACTION_LONG_RELEASED, "Stop" },
// end
{ Sensor::ModeNone, 0x00, 0x0000, 0x00, 0, 0, nullptr }
};

static const Sensor::ButtonMap ikeaOpenCloseMap[] = {
Expand All @@ -147,6 +149,8 @@ static const Sensor::ButtonMap ikeaOpenCloseMap[] = {
{ Sensor::ModeScenes, 0x01, 0x0102, 0x02, 0, S_BUTTON_1 + S_BUTTON_ACTION_LONG_RELEASED, "Stop" },
{ Sensor::ModeScenes, 0x01, 0x0102, 0x01, 0, S_BUTTON_2 + S_BUTTON_ACTION_SHORT_RELEASED, "Close" },
{ Sensor::ModeScenes, 0x01, 0x0102, 0x02, 1, S_BUTTON_2 + S_BUTTON_ACTION_LONG_RELEASED, "Stop" },
// end
{ Sensor::ModeNone, 0x00, 0x0000, 0x00, 0, 0, nullptr }
};

static const Sensor::ButtonMap ikeaRemoteMap[] = {
Expand Down Expand Up @@ -1010,11 +1014,11 @@ const Sensor::ButtonMap *Sensor::buttonMap()
}
else if (manufacturer.startsWith(QLatin1String("IKEA")))
{
if (modelid.contains(QLatin1String("remote"))) { m_buttonMap = ikeaRemoteMap; }
else if (modelid.contains(QLatin1String("motion"))) { m_buttonMap = ikeaMotionSensorMap; }
else if (modelid.contains(QLatin1String("dimmer"))) { m_buttonMap = ikeaDimmerMap; }
else if (modelid.contains(QLatin1String("on/off"))) { m_buttonMap = ikeaOnOffMap; }
else if (modelid.contains(QLatin1String("open/close"))) { m_buttonMap = ikeaOpenCloseMap; }
if (modelid.startsWith(QLatin1String("TRADFRI remote control"))) { m_buttonMap = ikeaRemoteMap; }
else if (modelid.startsWith(QLatin1String("TRADFRI motion sensor"))) { m_buttonMap = ikeaMotionSensorMap; }
else if (modelid.startsWith(QLatin1String("TRADFRI wireless dimmer"))) { m_buttonMap = ikeaDimmerMap; }
else if (modelid.startsWith(QLatin1String("TRADFRI on/off switch"))) { m_buttonMap = ikeaOnOffMap; }
else if (modelid.startsWith(QLatin1String("TRADFRI open/close remote"))) { m_buttonMap = ikeaOpenCloseMap; }
}
else if (manufacturer == QLatin1String("ubisys"))
{
Expand Down

0 comments on commit dc0d508

Please sign in to comment.