Advertisement
Datamupp

Filterlist for Homey

Aug 13th, 2020 (edited)
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. The purpose of this script is to be used as a condition (AND Section) in your flows.
  3. If the argument sent to the script is found in the list below it will return true, otherwise false.
  4.  
  5. 1. Login to homeyscript.homey.app, create a new script and paste this script into it.
  6. 2. Get the Homeyscript app for your homey.
  7. 3. Add the homeyscript flowcard "Run a script with an argument" in the "AND" section.
  8.  
  9. When the argument is received it will be converted to lowercase, so enter all your words
  10. in lowercase in the list below otherwise they won't match.
  11.  
  12. Below you can see I remove the last character (length-1). This is because when a tag or
  13. variable is sent as an argument a space is added for some reason. If plain text is sent
  14. instead of a tag or variable you will have to remove length-1
  15. */
  16.  
  17. //These words will result in TRUE.
  18. var filterList = ["word one", "word two", "and so on"];
  19.  
  20. if (args[0] != null) {
  21.   if (filterList.indexOf(args[0].substr(0,args[0].length-1).toLowerCase())>=0) {
  22.       return true;
  23.   }
  24.   else
  25.   {
  26.       return false;
  27.   }
  28. }
  29. else {
  30.   console.log("This script must be called with an argument")
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement