Changing remote branch to PLRG Git server.
[smartapps.git] / official / simple-sync-trigger.groovy
index 3fd4d08b03a1abb471a9f650de4e54b2d50fc62d..e8b64f4eb82239992aad533c48622e781c8f846a 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
@@ -42,30 +42,44 @@ def agentSelection()
        }\r
 }\r
 \r
+// input "motion", "capability.motionSensor", title: "Motion Detected", required: false, multiple: true\r
+// input "motionInactive", "capability.motionSensor", title: "Motion Stops", required: false, multiple: true\r
+// input "contact", "capability.contactSensor", title: "Contact Opens", required: false, multiple: true\r
+// input "contactClosed", "capability.contactSensor", title: "Contact Closes", required: false, multiple: true\r
+// input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false, multiple: true\r
+// input "mySwitch", "capability.switch", title: "Switch Turned On", required: false, multiple: true\r
+// input "mySwitchOff", "capability.switch", title: "Switch Turned Off", required: false, multiple: true\r
+// input "arrivalPresence", "capability.presenceSensor", title: "Arrival Of", required: false, multiple: true\r
+// input "departurePresence", "capability.presenceSensor", title: "Departure Of", required: false, multiple: true\r
+// input "button1", "capability.button", title: "Button Press", required:false, multiple:true //remove from production\r
+// input "triggerModes", "mode", title: "System Changes Mode", required: false, multiple: true\r
+// input "timeOfDay", "time", title: "At a Scheduled Time", required: false\r
+\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
@@ -98,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
@@ -115,7 +129,7 @@ def control()
                        mode title: "Set for specific mode(s)"\r
                }\r
        }\r
-    }\r
+    //}\r
 }\r
 \r
 private anythingSet() {\r
@@ -210,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
@@ -293,4 +307,4 @@ private hhmm(time, fmt = "h:mm a")
 private timeIntervalLabel()\r
 {\r
        (starting && ending) ? hhmm(starting) + "-" + hhmm(ending, "h:mm a z") : ""\r
-}
\ No newline at end of file
+}\r