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