From 44c4776756ebbf6fc244d22d7cd9d358f6f3e2de Mon Sep 17 00:00:00 2001 From: Patrick Fink Date: Sat, 7 Apr 2018 00:55:14 +0200 Subject: [PATCH] IFTTT integration: Listen to all item events if no itemStatus is defined within the trigger Signed-off-by: Patrick Fink --- routes/ifttt.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routes/ifttt.js b/routes/ifttt.js index f8e6262..4d41741 100644 --- a/routes/ifttt.js +++ b/routes/ifttt.js @@ -196,7 +196,11 @@ exports.v1triggeritemstate = [ Item.findOne({openhab: openhab._id, name: itemName}, function (error, item) { if (!error && item) { if (eventLimit > 0) { - Event.find({openhab: openhab._id, source: item.name, status: itemStatus}) + var eventFilters = {openhab: openhab._id, source: item.name}; + if(itemStatus != undefined && itemStatus.length > 0) { + eventFilters["status"] = itemStatus; + } + Event.find(eventFilters) .sort({when: 'desc'}) .limit(eventLimit) .lean()