Update simple-sync-trigger.groovy
authorRahmadi Trimananda <rahmadi.trimananda@uci.edu>
Fri, 9 Aug 2019 21:03:56 +0000 (14:03 -0700)
committerGitHub Enterprise <noreply@github.uci.edu>
Fri, 9 Aug 2019 21:03:56 +0000 (14:03 -0700)
official/simple-sync-trigger.groovy

index b6709e1..e8b64f4 100755 (executable)
@@ -18,7 +18,7 @@ definition(
 \r
 preferences {\r
        page(name: "agentSelection", title: "Select your Simple Sync")\r
-       page(name: "refreshActivities", title: "Updating list of Simple Sync activities")\r
+       //page(name: "refreshActivities", title: "Updating list of Simple Sync activities")\r
     page(name: "control", title: "Run a Simple Control activity when something happens")\r
        page(name: "timeIntervalInput", title: "Only during a certain time", install: true, uninstall: true) {\r
                section {\r
@@ -30,10 +30,10 @@ preferences {
 \r
 def agentSelection()\r
 {\r
-       if (agent)\r
-    {\r
-               state.refreshCount = 0\r
-    }\r
+       //if (agent)\r
+    //{\r
+       //      state.refreshCount = 0\r
+    //}\r
     \r
        dynamicPage(name: "agentSelection", title: "Select your Simple Sync", nextPage: "control", install: false, uninstall: true) {\r
                section {\r
@@ -57,28 +57,29 @@ def agentSelection()
 \r
 def control()\r
 {\r
-       def activities = agent.latestValue('activities')\r
+       //def activities = agent.latestValue('activities')\r
+       //def activities\r
     \r
-    if (!activities || !state.refreshCount)\r
-    {\r
-           int refreshCount = !state.refreshCount ? 0 : state.refreshCount as int\r
-           state.refreshCount = refreshCount + 1\r
-           def refreshInterval = refreshCount == 0 ? 2 : 4\r
+    //if (!activities || !state.refreshCount)\r
+    //{\r
+       //    int refreshCount = !state.refreshCount ? 0 : state.refreshCount as int\r
+       //    state.refreshCount = refreshCount + 1\r
+       //    def refreshInterval = refreshCount == 0 ? 2 : 4\r
                \r
            // Request activities every 5th attempt\r
-       if((refreshCount % 5) == 0)\r
-        {\r
-           agent.getAllActivities()\r
-               }\r
+    // if((refreshCount % 5) == 0)\r
+    //    {\r
+           //agent.getAllActivities()\r
+       //      }\r
         \r
-        dynamicPage(name: "control", title: "Updating list of Simple Control activities", nextPage: "", refreshInterval: refreshInterval, install: false, uninstall: true) {\r
-               section("") {\r
-               paragraph "Retrieving activities from Simple Sync"\r
-            }\r
-        }\r
-       }\r
-       else\r
-    {\r
+    //    dynamicPage(name: "control", title: "Updating list of Simple Control activities", nextPage: "", refreshInterval: refreshInterval, install: false, uninstall: true) {\r
+    //         section("") {\r
+    //         paragraph "Retrieving activities from Simple Sync"\r
+    //        }\r
+    //    }\r
+       //}\r
+       //else\r
+    //{\r
        dynamicPage(name: "control", title: "Run a Simple Control activity when something happens", nextPage: "timeIntervalInput", install: false, uninstall: true) {\r
                def anythingSet = anythingSet()\r
                if (anythingSet) {\r
@@ -111,13 +112,13 @@ def control()
                        ifUnset "triggerModes", "mode", title: "System Changes Mode", required: false, multiple: true\r
                        ifUnset "timeOfDay", "time", title: "At a Scheduled Time", required: false\r
                }\r
-               section("Run this activity"){\r
-               input "activity", "enum", title: "Activity?", required: true, options: new groovy.json.JsonSlurper().parseText(activities ?: "[]").activities?.collect { ["${it.uuid}": it.name] }\r
-               }\r
+               //section("Run this activity"){\r
+           //    input "activity", "enum", title: "Activity?", required: true, options: new groovy.json.JsonSlurper().parseText(activities ?: "[]").activities?.collect { ["${it.uuid}": it.name] }\r
+               //}\r
         \r
                section("More options", hideable: true, hidden: true) {\r
                        input "frequency", "decimal", title: "Minimum time between actions (defaults to every event)", description: "Minutes", required: false\r
-                       href "timeIntervalInput", title: "Only during a certain time", description: timeLabel ?: "Tap to set", state: timeLabel ? "complete" : "incomplete"\r
+                       //href "timeIntervalInput", title: "Only during a certain time", description: timeLabel ?: "Tap to set", state: timeLabel ? "complete" : "incomplete"\r
                        input "days", "enum", title: "Only on certain days of the week", multiple: true, required: false,\r
                                options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]\r
                        input "modes", "mode", title: "Only when mode is", multiple: true, required: false\r
@@ -128,7 +129,7 @@ def control()
                        mode title: "Set for specific mode(s)"\r
                }\r
        }\r
-    }\r
+    //}\r
 }\r
 \r
 private anythingSet() {\r
@@ -223,7 +224,7 @@ def appTouchHandler(evt) {
 }\r
 \r
 private startActivity(evt) {\r
-       agent.startActivity(activity)\r
+       //agent.startActivity(activity)\r
 \r
        if (frequency) {\r
                state.lastActionTimeStamp = now()\r