diff --git a/libnymea-core/ruleengine.cpp b/libnymea-core/ruleengine.cpp index 524fca02..be772004 100644 --- a/libnymea-core/ruleengine.cpp +++ b/libnymea-core/ruleengine.cpp @@ -809,6 +809,15 @@ QList RuleEngine::findRules(const DeviceId &deviceId) const offending = true; break; } + foreach (const RuleActionParam &ruleActionParam, action.ruleActionParams()) { + if (ruleActionParam.stateDeviceId() == deviceId) { + offending = true; + break; + } + } + if (offending) { + break; + } } } @@ -818,6 +827,15 @@ QList RuleEngine::findRules(const DeviceId &deviceId) const offending = true; break; } + foreach (const RuleActionParam &ruleActionParam, action.ruleActionParams()) { + if (ruleActionParam.stateDeviceId() == deviceId) { + offending = true; + break; + } + } + if (offending) { + break; + } } } @@ -886,6 +904,13 @@ void RuleEngine::removeDeviceFromRule(const RuleId &id, const DeviceId &deviceId for (int i = 0; i < actions.count(); i++) { if (actions.at(i).deviceId() == deviceId) { removeIndexes.append(i); + continue; + } + foreach (const RuleActionParam ¶m, actions.at(i).ruleActionParams()) { + if (param.stateDeviceId() == deviceId) { + removeIndexes.append(i); + break; + } } } while (removeIndexes.count() > 0) { @@ -897,6 +922,13 @@ void RuleEngine::removeDeviceFromRule(const RuleId &id, const DeviceId &deviceId for (int i = 0; i < exitActions.count(); i++) { if (exitActions.at(i).deviceId() == deviceId) { removeIndexes.append(i); + continue; + } + foreach (const RuleActionParam ¶m, exitActions.at(i).ruleActionParams()) { + if (param.stateDeviceId() == deviceId) { + removeIndexes.append(i); + break; + } } } while (removeIndexes.count() > 0) { @@ -1464,7 +1496,6 @@ void RuleEngine::init() param.setStateDeviceId(stateDeviceId); param.setStateTypeId(stateTypeId); params.append(param); - params.append(param); settings.endGroup(); } } diff --git a/tests/auto/rules/testrules.cpp b/tests/auto/rules/testrules.cpp index c4efee05..ced4bc1e 100644 --- a/tests/auto/rules/testrules.cpp +++ b/tests/auto/rules/testrules.cpp @@ -119,7 +119,6 @@ private slots: void testHousekeeping_data(); void testHousekeeping(); - }; void TestRules::cleanupMockHistory() {