Skip to content
Permalink
Browse files

Bug fixes Trådfri open/close remote and new Trådfri motion sensor.

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 27, 2019
1 parent dd7962e commit dc0d508d6a8c49d4cf59a3b72791f31f726d801b
Showing with 32 additions and 13 deletions.
  1. +16 −3 bindings.cpp
  2. +7 −5 de_web_plugin.cpp
  3. +9 −5 sensor.cpp
@@ -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);
@@ -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")))
{

}
@@ -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;

@@ -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);
}

@@ -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);

@@ -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[] = {
@@ -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[] = {
@@ -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"))
{

0 comments on commit dc0d508

Please sign in to comment.
You can’t perform that action at this time.