this.deviceNumbers = deviceNumbers
this.accelerationSensors = []
- def init = Verify.getBoolean()
+ /*def init = Verify.getBoolean()
if (init) {
this.acceleration = "inactive"
this.accelerationLatestValue = "inactive"
} else {
this.acceleration = "active"
this.accelerationLatestValue = "active"
- }
+ }*/
accelerationSensors.add(new AccelerationSensor(id, label, displayName, this.acceleration, this.accelerationLatestValue))
}
this.deviceNumbers = deviceNumbers
this.alarms = []
- def init = Verify.getBoolean()
+ /*def init = Verify.getBoolean()
if (init) {
this.alarm = "off"
this.currentAlarm = "off"
this.alarm = "on"
this.currentAlarm = "on"
this.alarmLatestValue = "on"
- }
+ }*/
alarms.add(new Alarm(sendEvent, id, label, displayName, this.alarm, this.currentAlarm, this.alarmLatestValue))
}
this.deviceNumbers = deviceNumbers
this.batteries = []
- def init = Verify.getIntFromList(30, 50, 70)
- this.battery = init
+ //def init = Verify.getIntFromList(30, 50, 70)
+ //this.battery = init
batteries.add(new Battery(id, label, displayName, this.battery))
}
this.deviceNumbers = deviceNumbers
this.beaconSensors = []
- def init = Verify.getBoolean()
+ /*def init = Verify.getBoolean()
if (init) {
this.presence = "not present"
this.presenceLatestValue = "not present"
} else {
this.presence = "present"
this.presenceLatestValue = "present"
- }
+ }*/
beaconSensors.add(new BeaconSensor(id, label, displayName, this.presence, this.presenceLatestValue))
}
this.deviceNumbers = deviceNumbers
this.carbonMonoxideDetectors = []
- def init = Verify.getInt(0,2)
+ /*def init = Verify.getInt(0,2)
if (init == 0) {
this.carbonMonoxide = "clear"
this.carbonMonoxideLatestValue = "clear"
} else {
this.carbonMonoxide = "tested"
this.carbonMonoxideLatestValue = "tested"
- }
+ }*/
carbonMonoxideDetectors.add(new CarbonMonoxideDetector(id, label, displayName, this.currentCarbonMonoxideValue, this.carbonMonoxideLatestValue))
}
this.deviceNumbers = deviceNumbers
this.colorControls = []
- def initHue = Verify.getIntFromList(30, 50, 70)
+ /*def initHue = Verify.getIntFromList(30, 50, 70)
this.hue = initHue
def initSat = Verify.getIntFromList(40, 50, 60)
this.saturation = initSat
this.color = "green"
} else {
this.color = "blue"
- }
+ }*/
colorControls.add(new ColorControl(id, label, displayName, this.color, this.hue, this.saturation, this.level, this.currentSwitch, this.colorTemperature))
}
this.deviceNumbers = deviceNumbers
this.contacts = []
- def initSensor = Verify.getBoolean()
+ /*def initSensor = Verify.getBoolean()
if (initSensor) {
this.contactState = "closed"
this.currentContact = "closed"
this.alarmState = "armed"
} else {
this.alarmState = "not armed"
- }
+ }*/
contacts.add(new ContactSensor(id, label, displayName, this.contactState, this.currentContact, this.alarmState, this.latestValue))
}
this.deviceNumbers = deviceNumbers
this.doorControls = []
- def init = Verify.getBoolean()
+ /*def init = Verify.getBoolean()
if (init) {
this.doorState = "closed"
this.doorLatestValue = "closed"
} else {
this.doorState = "open"
this.doorLatestValue = "open"
- }
+ }*/
doorControls.add(new DoorControl(sendEvent, id, label, displayName, this.doorState, this.doorLatestValue))
}
this.deviceNumbers = deviceNumbers
this.energyMeters = []
- def init = Verify.getIntFromList(30, 50, 70)
- this.energy = init
+ //def init = Verify.getIntFromList(30, 50, 70)
+ //this.energy = init
energyMeters.add(new EnergyMeter(id, label, displayName, this.energy))
}
+++ /dev/null
-/**
- * Color Coordinator
- * Version 1.1.1 - 11/9/16
- * By Michael Struck
- *
- * 1.0.0 - Initial release
- * 1.1.0 - Fixed issue where master can be part of slaves. This causes a loop that impacts SmartThings.
- * 1.1.1 - Fix NPE being thrown for slave/master inputs being empty.
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under the License.
- *
- */
-definition(
- name: "Color Coordinator",
- namespace: "MichaelStruck",
- author: "Michael Struck",
- description: "Ties multiple colored lights to one specific light's settings",
- category: "Convenience",
- iconUrl: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/ColorCoordinator/CC.png",
- iconX2Url: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/ColorCoordinator/CC@2x.png"
-)
-
-preferences {
- page name: "mainPage"
-}
-
-def mainPage() {
- section("Master Light") {
- input "master", "capability.colorControl", title: "Colored Light", required: true
- }
- section("Lights that follow the master settings") {
- input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: true, submitOnChange: true
- }
- section([mobileOnly:true], "Options") {
- input "randomYes", "bool",title: "When Master Turned On, Randomize Color", defaultValue: false
- href "pageAbout", title: "About ${textAppName()}", description: "Tap to get application version, license and instructions"
- }
-
- dynamicPage(name: "mainPage", title: "", install: true, uninstall: false) {
- def masterInList = slaves?.id?.find{it==master?.id}
- if (masterInList) {
- section ("**WARNING**"){
- paragraph "You have included the Master Light in the Slave Group. This will cause a loop in execution. Please remove this device from the Slave Group.", image: "https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/img/caution.png"
- }
- }
-
- page(name: "pageAbout", title: "About ${textAppName()}", uninstall: true) {
- section {
- paragraph "${textVersion()}\n${textCopyright()}\n\n${textLicense()}\n"
- }
- section("Instructions") {
- paragraph textHelp()
- }
- section("Tap button below to remove application"){
- }
- }
-
- }
-}
-
-def installed() {
- init()
-}
-
-def updated(){
- unsubscribe()
- init()
-}
-
-def init() {
- subscribe(master, "switch", onOffHandler)
- subscribe(master, "level", colorHandler)
- subscribe(master, "hue", colorHandler)
- subscribe(master, "saturation", colorHandler)
- subscribe(master, "colorTemperature", tempHandler)
-}
-//-----------------------------------
-def onOffHandler(evt){
- if (slaves && master) {
- if (!slaves?.id.find{it==master?.id}){
- if (master?.currentValue("switch") == "on"){
- if (randomYes) getRandomColorMaster()
- else slaves?.on()
- }
- else {
- slaves?.off()
- }
- }
- }
-}
-
-def colorHandler(evt) {
- if (slaves && master) {
- if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
- log.debug "Changing Slave units H,S,L"
- def dimLevel = master?.currentValue("level")
- def hueLevel = master?.currentValue("hue")
- def saturationLevel = master.currentValue("saturation")
- def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
- slaves?.setColor(newValue)
- try {
- log.debug "Changing Slave color temp"
- def tempLevel = master?.currentValue("colorTemperature")
- slaves?.setColorTemperature(tempLevel)
- }
- catch (e){
- log.debug "Color temp for master --"
- }
- }
- }
-}
-
-def getRandomColorMaster(){
- def hueLevel = Math.floor(Math.random() *1000)
- def saturationLevel = Math.floor(Math.random() * 100)
- def dimLevel = master?.currentValue("level")
- def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
- log.debug hueLevel
- log.debug saturationLevel
- master.setColor(newValue)
- slaves?.setColor(newValue)
-}
-
-def tempHandler(evt){
- if (slaves && master) {
- if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
- if (evt.value != "--") {
- log.debug "Changing Slave color temp based on Master change"
- def tempLevel = master.currentValue("colorTemperature")
- slaves?.setColorTemperature(tempLevel)
- }
- }
- }
-}
-
-//Version/Copyright/Information/Help
-
-private def textAppName() {
- def text = "Color Coordinator"
-}
-
-private def textVersion() {
- def text = "Version 1.1.1 (12/13/2016)"
-}
-
-private def textCopyright() {
- def text = "Copyright © 2016 Michael Struck"
-}
-
-private def textLicense() {
- def text =
- "Licensed under the Apache License, Version 2.0 (the 'License'); "+
- "you may not use this file except in compliance with the License. "+
- "You may obtain a copy of the License at"+
- "\n\n"+
- " http://www.apache.org/licenses/LICENSE-2.0"+
- "\n\n"+
- "Unless required by applicable law or agreed to in writing, software "+
- "distributed under the License is distributed on an 'AS IS' BASIS, "+
- "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. "+
- "See the License for the specific language governing permissions and "+
- "limitations under the License."
-}
-
-private def textHelp() {
- def text =
- "This application will allow you to control the settings of multiple colored lights with one control. " +
- "Simply choose a master control light, and then choose the lights that will follow the settings of the master, "+
- "including on/off conditions, hue, saturation, level and color temperature. Also includes a random color feature."
-}
-
+++ /dev/null
-/**
- * Medicine Management - Contact Sensor
- *
- * Copyright 2016 Jim Mangione
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
- * for the specific language governing permissions and limitations under the License.
- *
- * Logic:
- * --- Send notification at the medicine reminder time IF draw wasn't alread opened in past 60 minutes
- * --- If draw still isn't open 10 minutes AFTER reminder time, LED will turn RED.
- * --- ----- Once draw IS open, LED will return back to it's original color
- *
- */
-import groovy.time.TimeCategory
-
-definition(
- name: "Medicine Management - Contact Sensor",
- namespace: "MangioneImagery",
- author: "Jim Mangione",
- description: "This supports devices with capabilities of ContactSensor and ColorControl (LED). It sends an in-app and ambient light notification if you forget to open the drawer or cabinet where meds are stored. A reminder will be set to a single time per day. If the draw or cabinet isn't opened within 60 minutes of that reminder, an in-app message will be sent. If the draw or cabinet still isn't opened after an additional 10 minutes, then an LED light turns red until the draw or cabinet is opened",
- category: "Health & Wellness",
- iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
- iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
- iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
-
-
-preferences {
-
- section("My Medicine Draw/Cabinet"){
- input "deviceContactSensor", "capability.contactSensor", title: "Opened Sensor"
- }
-
- section("Remind me to take my medicine at"){
- input "reminderTime", "time", title: "Time"
- }
-
- // NOTE: Use REAL device - virtual device causes compilation errors
- section("My LED Light"){
- input "deviceLight", "capability.colorControl", title: "Smart light"
- }
-
-}
-
-def installed() {
- log.debug "Installed with settings: ${settings}"
-
- initialize()
-}
-
-def updated() {
- log.debug "Updated with settings: ${settings}"
-
- unsubscribe()
-
- initialize()
-}
-
-def initialize() {
-
- // will stop LED notification incase it was set by med reminder
- subscribe(deviceContactSensor, "contact", contactHandler)
-
- // how many minutes to look in the past from the reminder time, for an open draw
- state.minutesToCheckOpenDraw = 60
-
- // is true when LED notification is set after exceeding 10 minutes past reminder time
- state.ledNotificationTriggered = false
-
- // Set a timer to run once a day to notify if draw wasn't opened yet
- schedule(reminderTime, checkOpenDrawInPast)
-
-}
-
-// Should turn off any LED notification on OPEN state
-def contactHandler(evt){
- if (evt.value == "open") {
- // if LED notification triggered, reset it.
- log.debug "Cabinet opened"
- if (state.ledNotificationTriggered) {
- resetLEDNotification()
- }
- }
-}
-
-// If the draw was NOT opened within 60 minutes of the timer send notification out.
-def checkOpenDrawInPast(){
- log.debug "Checking past 60 minutes of activity from $reminderTime"
-
- // check activity of sensor for past 60 minutes for any OPENED status
- def cabinetOpened = isOpened(state.minutesToCheckOpenDraw)
- log.debug "Cabinet found opened: $cabinetOpened"
-
- // if it's opened, then do nothing and assume they took their meds
- if (!cabinetOpened) {
- sendNotification("Hi, please remember to take your meds in the cabinet")
-
- // if no open activity, send out notification and set new reminder
- def reminderTimePlus10 = new Date(now() + (10 * 60000))
-
- // needs to be scheduled if draw wasn't already opened
- runOnce(reminderTimePlus10, checkOpenDrawAfterReminder)
- }
-}
-
-// If the draw was NOT opened after 10 minutes past reminder, use LED notification
-def checkOpenDrawAfterReminder(){
- log.debug "Checking additional 10 minutes of activity from $reminderTime"
-
- // check activity of sensor for past 10 minutes for any OPENED status
- def cabinetOpened = isOpened(10)
-
- log.debug "Cabinet found opened: $cabinetOpened"
-
- // if no open activity, blink lights
- if (!cabinetOpened) {
- log.debug "Set LED to Notification color"
- setLEDNotification()
- }
-
-}
-
-// Helper function for sending out an app notification
-def sendNotification(msg){
- log.debug "Message Sent: $msg"
- sendPush(msg)
-}
-
-// Check if the sensor has been opened since the minutes entered
-// Return true if opened found, else false.
-def isOpened(minutes){
- // query last X minutes of activity log
- def previousDateTime = new Date(now() - (minutes * 60000))
-
- // capture all events recorded
- def evts = deviceContactSensor.eventsSince(previousDateTime)
- def cabinetOpened = false
- if (evts.size() > 0) {
- evts.each{
- if(it.value == "open") {
- cabinetOpened = true
- }
- }
- }
-
- return cabinetOpened
-}
-
-// Saves current color and sets the light to RED
-def setLEDNotification(){
-
- state.ledNotificationTriggered = true
-
- // turn light back off when reset is called if it was originally off
- state.ledState = deviceLight.currentValue("switch")
-
- // set light to RED and store original color until stopped
- state.origColor = deviceLight.currentValue("hue")
- deviceLight.on()
- deviceLight.setHue(100)
-
- log.debug "LED set to RED. Original color stored: $state.origColor"
-
-}
-
-// Sets the color back to the original saved color
-def resetLEDNotification(){
-
- state.ledNotificationTriggered = false
-
- // return color to original
- log.debug "Reset LED color to: $state.origColor"
- if (state.origColor != null) {
- deviceLight.setHue(state.origColor)
- }
-
- // if the light was turned on just for the notification, turn it back off now
- if (state.ledState == "off") {
- deviceLight.off()
- }
-
-}
ToReturn = ""
eventList = []
eventVarMap = {}
+eventVarCounterMap = {}
capabilityMap = {}
+capabilityList = []
app1Capabilities = []
app2Capabilities = []
app1Subscribe = False
#Check input capability
if (Temp == "input"):
- Temp = GetToken(F) #Get '"'
+ while Temp != "\"":
+ Temp = GetToken(F)
variable = GetToken(F)
Temp = GetToken(F) #Get '"'
Temp = GetToken(F) #Get ','
- Temp = GetToken(F) #Get '"'
- Temp = GetToken(F) #Get capability...
- capability = Temp
+ while Temp != "\"":
+ Temp = GetToken(F)
+ capability = GetToken(F)
capabilityMap[variable] = capability
#Check subscribed events
while (Temp != "\"" and Temp != "app" and Temp != "location"):
Temp = GetToken(F)
if Temp == "\"":
- Temp = GetToken(F)
- if Temp not in eventList:
+ Temp = GetToken(F)
+ if Temp == "app" or Temp == "location":
+ if Temp not in eventList:
+ eventList.append(Temp)
+ elif Temp not in eventList or (variable in capabilityMap.keys() and capabilityMap[variable] not in capabilityList):
+ # We do not repeat the same capability twice
+ capability = capabilityMap[variable]
+ capabilityList.append(capability)
eventList.append(Temp)
- eventVarMap[Temp] = variable
+ if Temp in eventVarMap.keys():
+ listOfEvents = eventVarMap[Temp]
+ listOfEvents.append(variable)
+ else:
+ eventVarMap[Temp] = [variable]
+ #print "DEBUG: %s - %s" % (variable, Temp)
+ #print capabilityMap
+ #print eventList
#Check and analyze capabilities for physical interaction
AnalyzeCapabilities(Temp, appName, F)
AnalyzePhysicalInteraction(app1Capabilities, app2Capabilities)
AnalyzePhysicalInteraction(app2Capabilities, app1Capabilities)
-
def AnalyzeCapabilities(Temp, appName, F):
#Illuminance related
if (Temp == "capability.switch" or
global eventList
global eventVarMap
global capabilityMap
+ global eventVarCounterMap
extractedEvents.write("while(true) {\n")
extractedEvents.write("\tdef eventNumber = Verify.getInt(0,%d)\n" % (len(eventList) - 1))
extractedEvents.write("\tswitch(eventNumber) {\n")
for i in range(len(eventList)):
extractedEvents.write("\t\tcase %d:\n" % i)
if eventList[i] == "lock":
- event = open("eventSimulator/lockEvent.groovy", "r")
+ #Write two events subsequently
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ event = open("eventSimulator/lockLockedEvent.groovy", "r")
for line in event:
- extractedEvents.write(line)
+ extractedEvents.write("\t\t" + line)
event.close()
+ extractedEvents.write("\t\t\t} else {\n")
+ event = open("eventSimulator/lockUnlockedEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t}\n")
elif eventList[i] == "unlock":
event = open("eventSimulator/unlockEvent.groovy", "r")
for line in event:
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t}\n")
- elif eventList[i] == "presence":
+ elif eventList[i] == "water":
#Write two events subsequently
extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
extractedEvents.write("\t\t\tif (event == 0) {\n")
- event = open("eventSimulator/presencePresentEvent.groovy", "r")
+ event = open("eventSimulator/waterDryEvent.groovy", "r")
for line in event:
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t} else {\n")
- event = open("eventSimulator/presenceLeftEvent.groovy", "r")
+ event = open("eventSimulator/waterWetEvent.groovy", "r")
for line in event:
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "presence":
+ #Check which capability
+ variable = eventVarMap[eventList[i]]
+ if eventList[i] not in eventVarCounterMap.keys():
+ eventVarCounterMap[eventList[i]] = 1
+ eventVarCount = 0
+ else:
+ eventVarCount = eventVarCounterMap[eventList[i]]
+ eventVarCounterMap[eventList[i]] = eventVarCount + 1
+ capability = capabilityMap[variable[eventVarCount]]
+ #Write three events subsequently
+ if capability == "capability.presenceSensor":
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,2)\n")
+ elif capability == "capability.beacon":
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ if capability == "capability.presenceSensor":
+ event = open("eventSimulator/presencePresentEvent.groovy", "r")
+ elif capability == "capability.beacon":
+ event = open("eventSimulator/beaconPresentEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 1) {\n")
+ if capability == "capability.presenceSensor":
+ event = open("eventSimulator/presenceLeftEvent.groovy", "r")
+ elif capability == "capability.beacon":
+ event = open("eventSimulator/beaconLeftEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ elif eventList[i] == "presence.present": #Case for Touched event
+ event = open("eventSimulator/presencePresencePresentEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
elif eventList[i] == "doorState":
#Write two events subsequently
extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
elif eventList[i] == "carbonMonoxide":
#Check which capability
variable = eventVarMap[eventList[i]]
- capability = capabilityMap[variable]
-
+ if eventList[i] not in eventVarCounterMap.keys():
+ eventVarCounterMap[eventList[i]] = 1
+ eventVarCount = 0
+ else:
+ eventVarCount = eventVarCounterMap[eventList[i]]
+ eventVarCounterMap[eventList[i]] = eventVarCount + 1
+ capability = capabilityMap[variable[eventVarCount]]
#Write three events subsequently
extractedEvents.write("\t\t\tdef event = Verify.getInt(0,2)\n")
extractedEvents.write("\t\t\tif (event == 0) {\n")
event.close()
extractedEvents.write("\t\t\t}\n")
elif eventList[i] == "battery":
- event = open("eventSimulator/batteryChargeEvent.groovy", "r")
+ #Check which capability
+ variable = eventVarMap[eventList[i]]
+ if eventList[i] not in eventVarCounterMap.keys():
+ eventVarCounterMap[eventList[i]] = 1
+ eventVarCount = 0
+ else:
+ eventVarCount = eventVarCounterMap[eventList[i]]
+ eventVarCounterMap[eventList[i]] = eventVarCount + 1
+ capability = capabilityMap[variable[eventVarCount]]
+ if capability == "capability.smokeDetector":
+ event = open("eventSimulator/smokeDetectorBatteryEvent.groovy", "r")
+ elif capability == "capability.battery":
+ event = open("eventSimulator/batteryBatteryEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event.close()
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "thermostatFanMode":
+ #Write five events subsequently
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,4)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ event = open("eventSimulator/thermostatAutoFanModeEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 1) {\n")
+ event = open("eventSimulator/thermostatFanCirculateFanModeEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 2) {\n")
+ event = open("eventSimulator/thermostatCirculateFanModeEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 3) {\n")
+ event = open("eventSimulator/thermostatFanOnFanModeEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else {\n")
+ event = open("eventSimulator/thermostatOnFanModeEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "thermostatOperatingState":
+ #Write five events subsequently
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,4)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ event = open("eventSimulator/thermostatOperatingStateAutoEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 1) {\n")
+ event = open("eventSimulator/thermostatOperatingStateCoolEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 2) {\n")
+ event = open("eventSimulator/thermostatOperatingStateOffEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 3) {\n")
+ event = open("eventSimulator/thermostatOperatingStateEmergencyHeatEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else {\n")
+ event = open("eventSimulator/thermostatOperatingStateHeatEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t}\n")
elif eventList[i] == "switch":
+ #Check which capability
+ variable = eventVarMap[eventList[i]]
+ if eventList[i] not in eventVarCounterMap.keys():
+ eventVarCounterMap[eventList[i]] = 1
+ eventVarCount = 0
+ else:
+ eventVarCount = eventVarCounterMap[eventList[i]]
+ eventVarCounterMap[eventList[i]] = eventVarCount + 1
+ capability = capabilityMap[variable[eventVarCount]]
#Write two events subsequently
extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
extractedEvents.write("\t\t\tif (event == 0) {\n")
- event = open("eventSimulator/switchOnEvent.groovy", "r")
+ if capability == "capability.switch":
+ event = open("eventSimulator/switchOnEvent.groovy", "r")
+ elif capability == "capability.switchLevel":
+ event = open("eventSimulator/switchLevelOnEvent.groovy", "r")
+ elif capability == "capability.relaySwitch":
+ event = open("eventSimulator/relaySwitchOnEvent.groovy", "r")
for line in event:
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t} else {\n")
- event = open("eventSimulator/switchOffEvent.groovy", "r")
+ if capability == "capability.switch":
+ event = open("eventSimulator/switchOffEvent.groovy", "r")
+ elif capability == "capability.switchLevel":
+ event = open("eventSimulator/switchLevelOffEvent.groovy", "r")
+ elif capability == "capability.relaySwitch":
+ event = open("eventSimulator/relaySwitchOffEvent.groovy", "r")
for line in event:
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t}\n")
- elif eventList[i] == "beacon":
+ elif eventList[i] == "sleeping":
#Write two events subsequently
extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
extractedEvents.write("\t\t\tif (event == 0) {\n")
- event = open("eventSimulator/beaconPresenceEvent.groovy", "r")
+ event = open("eventSimulator/sleepSleepingEvent.groovy", "r")
for line in event:
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t} else {\n")
- event = open("eventSimulator/beaconLeftEvent.groovy", "r")
+ event = open("eventSimulator/sleepNotSleepingEvent.groovy", "r")
for line in event:
extractedEvents.write("\t\t" + line)
event.close()
extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "goal":
+ event = open("eventSimulator/stepGoalEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "steps":
+ event = open("eventSimulator/stepStepsEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
elif eventList[i] == "color":
- event = open("eventSimulator/colorChangeEvent.groovy", "r")
+ event = open("eventSimulator/colorChangedEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event.close()
elif eventList[i] == "hue":
- event = open("eventSimulator/hueChangeEvent.groovy", "r")
+ event = open("eventSimulator/hueChangedEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event.close()
elif eventList[i] == "saturation":
- event = open("eventSimulator/saturationChangeEvent.groovy", "r")
+ event = open("eventSimulator/saturationChangedEvent.groovy", "r")
for line in event:
extractedEvents.write(line)
event.close()
-
+ elif eventList[i] == "energy":
+ event = open("eventSimulator/energyMeterEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "power":
+ event = open("eventSimulator/powerMeterEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "illuminance":
+ event = open("eventSimulator/illuminanceMeasurementEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "humidity":
+ event = open("eventSimulator/humidityMeasurementEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "alarm":
+ #Write four events subsequently
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,3)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ event = open("eventSimulator/alarmBothEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 1) {\n")
+ event = open("eventSimulator/alarmSirenEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 2) {\n")
+ event = open("eventSimulator/alarmStrobeEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else {\n")
+ event = open("eventSimulator/alarmOffEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "contact":
+ #Check which capability
+ variable = eventVarMap[eventList[i]]
+ if eventList[i] not in eventVarCounterMap.keys():
+ eventVarCounterMap[eventList[i]] = 1
+ eventVarCount = 0
+ else:
+ eventVarCount = eventVarCounterMap[eventList[i]]
+ eventVarCounterMap[eventList[i]] = eventVarCount + 1
+ capability = capabilityMap[variable[eventVarCount]]
+ #Write two events subsequently
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ if capability == "capability.contactSensor":
+ event = open("eventSimulator/contactDefaultClosedEvent.groovy", "r")
+ elif capability == "capability.valve":
+ event = open("eventSimulator/valveClosedEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else {\n")
+ if capability == "capability.contactSensor":
+ event = open("eventSimulator/contactDefaultOpenEvent.groovy", "r")
+ elif capability == "capability.valve":
+ event = open("eventSimulator/valveOpenEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "status":
+ #Write three events subsequently
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,2)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ event = open("eventSimulator/musicPlayerPlayingEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else if (event == 1) {\n")
+ event = open("eventSimulator/musicPlayerStoppedEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else {\n")
+ event = open("eventSimulator/musicPlayerPausedEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "level":
+ #Check which capability
+ variable = eventVarMap[eventList[i]]
+ if eventList[i] not in eventVarCounterMap.keys():
+ eventVarCounterMap[eventList[i]] = 1
+ eventVarCount = 0
+ else:
+ eventVarCount = eventVarCounterMap[eventList[i]]
+ eventVarCounterMap[eventList[i]] = eventVarCount + 1
+ capability = capabilityMap[variable[eventVarCount]]
+ if capability == "capability.musicPlayer":
+ event = open("eventSimulator/musicPlayerLevelEvent.groovy", "r")
+ elif capability == "capability.switchLevel":
+ event = open("eventSimulator/switchLevelEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "trackDescription":
+ event = open("eventSimulator/musicPlayerTrackDescriptionEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "trackData":
+ event = open("eventSimulator/musicPlayerTrackDataEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "mute":
+ #Write two events subsequently
+ extractedEvents.write("\t\t\tdef event = Verify.getInt(0,1)\n")
+ extractedEvents.write("\t\t\tif (event == 0) {\n")
+ event = open("eventSimulator/musicPlayerUnmutedEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t} else {\n")
+ event = open("eventSimulator/musicPlayerMutedEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write("\t\t" + line)
+ event.close()
+ extractedEvents.write("\t\t\t}\n")
+ elif eventList[i] == "temperature":
+ #Check which capability
+ variable = eventVarMap[eventList[i]]
+ if eventList[i] not in eventVarCounterMap.keys():
+ eventVarCounterMap[eventList[i]] = 1
+ eventVarCount = 0
+ else:
+ eventVarCount = eventVarCounterMap[eventList[i]]
+ eventVarCounterMap[eventList[i]] = eventVarCount + 1
+ capability = capabilityMap[variable[eventVarCount]]
+ if capability == "capability.thermostat":
+ event = open("eventSimulator/temperatureEvent.groovy", "r")
+ elif capability == "capability.temperatureMeasurement":
+ event = open("eventSimulator/temperatureMeasurementEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "heatingSetpoint":
+ event = open("eventSimulator/heatingSetpointEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "coolingSetpoint":
+ event = open("eventSimulator/coolingSetpointEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+ elif eventList[i] == "thermostatSetpoint":
+ event = open("eventSimulator/thermostatSetpointEvent.groovy", "r")
+ for line in event:
+ extractedEvents.write(line)
+ event.close()
+
###TODO: Add more events later
extractedEvents.write("\t\t\tbreak\n")
extractedEvents.write("\t}\n")
if item != "nfcTouch" and item != "app":
onlyTouchEvents = False
if onlyTouchEvents is True and app1Subscribe is True and app2Subscribe is True:
+ # Write error log file
+ extractError = open("appCreationError.log", "w+")
+ extractError.write("Direct-Direct Interaction detected: we are skipping this pair...\n")
+ extractError.close()
raise Exception("\n\nDirect-Direct Interaction detected: we are skipping this pair...\n\n")
package IlluminanceMeasurement
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class IlluminanceMeasurements {
private int deviceNumbers
private List illuminanceMeasurements
this.deviceNumbers = deviceNumbers
this.illuminanceMeasurements = []
+ //def init = Verify.getIntFromList(40000, 50000, 60000)
+ //this.illuminance = init
+
illuminanceMeasurements.add(new IlluminanceMeasurement(id, label, displayName, this.illuminance))
}
this.deviceNumbers = deviceNumbers
this.imageCaptureSensors = []
- def initAlarm = Verify.getBoolean()
+ /*def initAlarm = Verify.getBoolean()
if (initAlarm) {
this.alarmState = "armed"
} else {
this.alarmState = "not armed"
- }
+ }*/
imageCaptureSensors.add(new ImageCapture(id, label, displayName, this.image, this.alarmState))
}
def lock() {
if (lockState != "locked") {
println("the door with id:$id is locked!")
+<<<<<<< HEAD
+=======
+ //this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.lockLatestValue = "locked"
this.lockState = "locked"
this.currentLock = "locked"
if (lockState != "locked") {
def task = timers.runAfter(metaData["delay"]) {
println("the door with id:$id is locked!")
+<<<<<<< HEAD
+=======
+ //this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.lockLatestValue = "locked"
this.lockState = "locked"
this.currentLock = "locked"
def unlock() {
if (lockState != "unlocked") {
println("the door with id:$id is unlocked!")
+<<<<<<< HEAD
+=======
+ //this.lockLatestValue = this.lockState
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.lockLatestValue = "unlocked"
this.lockState = "unlocked"
this.currentLock = "unlocked"
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+<<<<<<< HEAD
sendEvent([name: "lock.unlocked", value: "unlocked", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+=======
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
}
}
if (lockState != "unlocked") {
def task = timers.runAfter(metaData["delay"]) {
println("the door with id:$id is locked!")
+<<<<<<< HEAD
this.lockLatestValue = "unlocked"
this.lockState = "unlocked"
this.currentLock = "unlocked"
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
sendEvent([name: "lock.unlocked", value: "unlocked", deviceId: this.id, descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+=======
+ //this.lockLatestValue = this.lockState
+ this.lockLatestValue = "locked"
+ this.lockState = "locked"
+ this.currentLock = "locked"
+ sendEvent([name: "unlock", value: "unlocked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+ sendEvent([name: "lock", value: "unlocked", deviceId: this.id, descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
}
}
}
//By Apps
def lock() {
if (lockState != "locked") {
- locks[0].lock()
- lockLatestValue = lockState
+ //lockLatestValue = lockState
+ lockLatestValue = "locked"
lockState = "locked"
currentLock = "locked"
+ locks[0].lock()
}
}
def lock(LinkedHashMap metaData) {
if (lockState != "locked") {
def task = timers.runAfter(metaData["delay"]) {
- locks[0].lock()
- lockLatestValue = lockState
+ //lockLatestValue = lockState
+ lockLatestValue = "locked"
lockState = "locked"
currentLock = "locked"
+ locks[0].lock()
}
}
}
def unlock() {
if (lockState != "unlocked") {
- locks[0].unlock()
- lockLatestValue = lockState
+ //lockLatestValue = lockState
+ lockLatestValue = "unlocked"
lockState = "unlocked"
currentLock = "unlocked"
+ locks[0].unlock()
}
}
def unlock(LinkedHashMap metaData) {
if (lockState != "unlocked") {
def task = timers.runAfter(metaData["delay"]) {
- locks[0].unlock()
- lockLatestValue = lockState
+ //lockLatestValue = lockState
+ lockLatestValue = "unlocked"
lockState = "unlocked"
currentLock = "unlocked"
+ locks[0].unlock()
}
}
}
this.deviceNumbers = deviceNumbers
this.motionSensors = []
- def init = Verify.getBoolean()
+ /*def init = Verify.getBoolean()
if (init) {
this.motion = "inactive"
this.motionLatestValue = "inactive"
} else {
this.motion = "active"
this.motionLatestValue = "active"
- }
+ }*/
motionSensors.add(new MotionSensor(id, label, displayName, this.motion, this.motionLatestValue))
}
private int trackNumber
private String trackData
private String trackDescription
+ def sendEvent
MusicPlayer(Closure sendEvent, String id, String label, String displayName, int level, String mute, String status, int trackNumber, String trackData, String trackDescription) {
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.musicPlayers = []
- def initLevel = Verify.getIntFromList(10, 20, 30)
+ /*def initLevel = Verify.getIntFromList(10, 20, 30)
this.level = initLevel
def initMute = Verify.getBoolean()
if (initMute) {
this.mute = "unmuted"
} else {
- this.mute = "mute"
+ this.mute = "muted"
}
- def initStatus = Verify.getBoolean()
- if (initStatus) {
+ def initStatus = Verify.getInt(0,2)
+ if (initStatus == 0) {
this.status = "paused"
- } else {
+ } else if (initStatus == 1) {
this.status = "playing"
+ } else {
+ this.status = "stopped"
}
+<<<<<<< HEAD
+=======
+ def initTrack = Verify.getIntFromList(1, 2, 3)
+ this.trackNumber = initTrack
+ def initData = Verify.getBoolean()
+ if (initData) {
+ this.trackData = "someTrack"
+ } else {
+ this.trackData = "someOtherTrack"
+ }
+ def initDesc = Verify.getBoolean()
+ if (initDesc) {
+ this.trackDescription = "someDescriptions"
+ } else {
+ this.trackDescription = "someOtherDescriptions"
+ }*/
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
musicPlayers.add(new MusicPlayer(sendEvent, id, label, displayName, this.level, this.mute, this.status, this.trackNumber, this.trackData, this.trackDescription))
}
package PowerMeter
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class PowerMeters {
private int deviceNumbers
private List powerMeters
this.deviceNumbers = deviceNumbers
this.powerMeters = []
+ //def init = Verify.getIntFromList(30, 50, 70)
+ //this.power = init
+
powerMeters.add(new PowerMeter(id, label, displayName, this.power))
}
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.presenceSensors = []
- def init = Verify.getBoolean()
+ /*def init = Verify.getBoolean()
if (init) {
this.presence = "not present"
this.presenceLatestValue = "not present"
} else {
this.presence = "present"
this.presenceLatestValue = "present"
- }
+ }*/
presenceSensors.add(new PresenceSensor(id, label, displayName, this.presence, this.presenceLatestValue))
}
package RelativeHumidityMeasurement
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class RelativeHumidityMeasurements {
private int deviceNumbers
private List humidityMeasurements
this.deviceNumbers = deviceNumbers
this.humidityMeasurements = []
+ //def init = Verify.getIntFromList(30, 50, 70)
+ //this.humidity = init
+
humidityMeasurements.add(new RelativeHumidityMeasurement(id, label, displayName, this.humidity))
}
package RelaySwitch
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class RelaySwitches {
int deviceNumbers
List relaySwitches
this.deviceNumbers = deviceNumbers
this.relaySwitches = []
+ /*def init = Verify.getBoolean()
+ if (init) {
+ this.switchState = "off"
+ this.currentSwitch = "off"
+ this.switchLatestValue = "off"
+ } else {
+ this.switchState = "on"
+ this.currentSwitch = "on"
+ this.switchLatestValue = "on"
+ }*/
relaySwitches.add(new RelaySwitch(sendEvent, id, label, displayName, this.switchState, this.currentSwitch, this.switchLatestValue))
}
package SleepSensor
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class SleepSensors {
private int deviceNumbers
private List sleepSensors
this.deviceNumbers = deviceNumbers
this.sleepSensors = []
+ /*def init = Verify.getBoolean()
+ if (init) {
+ this.sleeping = "sleeping"
+ } else {
+ this.sleeping = "not sleeping"
+ }*/
sleepSensors.add(new SleepSensor(id, label, displayName, this.sleeping))
}
this.deviceNumbers = deviceNumbers
this.smokeDetectors = []
+<<<<<<< HEAD
def initBattery = Verify.getIntFromList(30, 50, 70)
this.battery = initBattery
this.batteryLatestValue = initBattery
def initSmoke = Verify.getInt(0,2)
if (initSmoke == 0) {
+=======
+ /*def init = Verify.getInt(0,2)
+ if (init == 0) {
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
this.currentSmokeValue = "clear"
this.smokeLatestValue = "clear"
} else if (initSmoke == 1) {
} else {
this.currentSmokeValue = "tested"
this.smokeLatestValue = "tested"
+<<<<<<< HEAD
}
def initCarbonMonoxide = Verify.getInt(0,2)
}
smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue, this.currentCarbonMonoxideValue,
this.carbonMonoxideLatestValue, this.battery))
+=======
+ }*/
+ smokeDetectors.add(new SmokeDetector(id, label, displayName, this.currentSmokeValue, this.smokeLatestValue))
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
}
//By Model Checker
this.deviceNumbers = deviceNumbers
this.speechSynthesises = []
- def init = Verify.getIntFromList(30, 50, 70)
- this.level = init
+ //def init = Verify.getIntFromList(30, 50, 70)
+ //this.level = init
speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level))
}
package StepSensor
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class StepSensors {
private int deviceNumbers
private List stepSensors
this.deviceNumbers = deviceNumbers
this.stepSensors = []
+ /*def initGoal = Verify.getIntFromList(1000, 2000, 3000)
+ this.goal = initGoal
+ def initSteps = Verify.getIntFromList(0, 1, 2)
+ this.steps = initSteps*/
+
stepSensors.add(new StepSensor(id, label, displayName, this.steps, this.goal))
}
this.deviceNumbers = deviceNumbers
this.switches = []
- def initLevel = Verify.getIntFromList(30, 50, 70)
+ /*def initLevel = Verify.getIntFromList(30, 50, 70)
this.currentLevel = initLevel
def init = Verify.getBoolean()
if (init) {
this.switchState = "on"
this.currentSwitch = "on"
this.switchLatestValue = "on"
- }
+ }*/
switches.add(new Switch(sendEvent, id, label, displayName, this.switchState, this.currentSwitch, this.currentLevel, this.switchLatestValue))
}
package SwitchLevel
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class SwitchLevels {
int deviceNumbers
List switchLevels
this.deviceNumbers = deviceNumbers
this.switchLevels = []
+ /*def initLevel = Verify.getIntFromList(30, 50, 70)
+ this.level = initLevel
+ def init = Verify.getBoolean()
+ if (init) {
+ this.switchState = "off"
+ this.currentSwitch = "off"
+ this.switchLatestValue = "off"
+ } else {
+ this.switchState = "on"
+ this.currentSwitch = "on"
+ this.switchLatestValue = "on"
+ }*/
switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, this.level, this.switchState, this.switchLatestValue))
}
package TemperatureMeasurement
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class TemperatureMeasurements {
private int deviceNumbers
private List temperatureMeasurements
private String label = "temperatureMeasurement0"
private String displayName = "temperatureMeasurement0"
private int temperature = 50
+<<<<<<< HEAD
private int currentTemperature = 50
+=======
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
-
-
TemperatureMeasurements(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.temperatureMeasurements = []
+
+ //def initTemp = Verify.getIntFromList(30, 50, 70)
+ //this.temperature = initTemp
temperatureMeasurements.add(new TemperatureMeasurement(id, label, displayName, this.temperature))
}
this.deviceNumbers = deviceNumbers
this.thermostats = []
- def initTemperature = Verify.getIntFromList(60, 66, 70)
+ /*def initTemperature = Verify.getIntFromList(60, 66, 70)
this.temperature = initTemperature
this.currentTemperature = initTemperature
} else {
this.thermostatMode = "off"
this.currentThermostatMode = "off"
+<<<<<<< HEAD
this.thermostatLatestMode = "off"
}
+=======
+ }*/
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
thermostats.add(new Thermostat(sendEvent, id, label, displayName, this.temperature, this.currentCoolingSetpoint,
this.currentHeatingSetpoint, this.coolingSetpoint, this.thermostatSetpoint, this.heatingSetpoint, this.coolingSetpointRange,
package Valve
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class Valves {
int deviceNumbers
List valves
this.deviceNumbers = deviceNumbers
this.valves = []
+ /*def init = Verify.getBoolean()
+ if (init) {
+ this.valve = "closed"
+ this.valveLatestValue = "closed"
+ } else {
+ this.valve = "open"
+ this.valveLatestValue = "open"
+ }*/
valves.add(new Valve(sendEvent, id, label, displayName, this.valve, this.valveLatestValue))
}
package WaterSensor
import Timer.SimulatedTimer
+//JPF's Verify API
+import gov.nasa.jpf.vm.Verify
+
public class WaterSensors {
private int deviceNumbers
private List waterSensors
this.deviceNumbers = deviceNumbers
this.waterSensors = []
+ /*def init = Verify.getBoolean()
+ if (init) {
+ this.water = "dry"
+ } else {
+ this.water = "wet"
+ }*/
waterSensors.add(new WaterSensor(id, label, displayName, this.water))
}
--- /dev/null
+#!/bin/bash
+
+java -classpath bin/main:lib/jpf.jar:../jpf-core/lib/groovy-2.5.7/:../jpf-core/lib/groovy-dateutil-2.5.7/:../jpf-core/lib/groovy-json-2.5.7/ main
--- /dev/null
+ alarmObject.setValue([name: "alarm", value: "both", deviceId: "alarmID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ alarmObject.setValue([name: "alarm", value: "off", deviceId: "alarmID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ alarmObject.setValue([name: "alarm", value: "siren", deviceId: "alarmID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ alarmObject.setValue([name: "alarm", value: "strobe", deviceId: "alarmID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ batteryObject.setValue([name: "battery", value: "50"/*number between 0 to 100 as a string*/, deviceId: "batteryID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+++ /dev/null
- smokeDetectorObject.setValue([name: "battery", value: "5", deviceId: "smokeDetectorID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ contactObject.setValue([name: "contact", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
--- /dev/null
+ contactObject.setValue([name: "contact", value: "open", deviceId: "contactSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
--- /dev/null
+ thermostatObject.setValue([name: "coolingSetpoint", value: "60", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ energyMeterObject.setValue([name: "energy", value: "45"/*A number between 0 to 100 as a charge*/, deviceId: "energyMeterID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
case 0:
def event = Verify.getInt(0,1)
if (event == 0) {
+<<<<<<< HEAD
switchObject.setValue([name: "switch", value: "on", deviceId: "switchID0", descriptionText: "",
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
} else {
switchObject.setValue([name: "switch", value: "off", deviceId: "switchID0", descriptionText: "",
+=======
+ lockObject.setValue([name: "lock", value: "locked", deviceId: "lockID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']) } else {
+ lockObject.setValue([name: "lock", value: "unlocked", deviceId: "lockID0", descriptionText: "",
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
}
break
displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
break
case 4:
+<<<<<<< HEAD
break
case 5:
+=======
+ appObject.setValue([name: "Touched", value: "touched", deviceId: "touchedSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+>>>>>>> a02c9807815a35c0f57241ee6510a3d312499049
break
}
}
--- /dev/null
+ thermostatObject.setValue([name: "heatingSetpoint", value: "40", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ humidityMeasurementObject.setValue([name: "humidity", value: "70"/*A number between 0 to 100 as a charge*/, deviceId: "humidityMeasurementID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ illuminanceMeasurementObject.setValue([name: "illuminance", value: "70"/*A number between 0 to 100 as a charge*/, deviceId: "illuminanceMeasurementID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+++ /dev/null
- lockObject.setValue([name: "lock", value: "locked", deviceId: "lockID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ lockObject.setValue([name: "lock", value: "locked", deviceId: "lockID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ lockObject.setValue([name: "lock", value: "unlocked", deviceId: "lockID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "level", value: "36"/*A number between 0 to 100 as a charge*/, deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "mute", value: "muted", deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "status", value: "paused", deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "status", value: "playing", deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "status", value: "stopped", deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "trackData", value: "someTrack", deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "trackDescription", value: "someDescriptions", deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ musicPlayerObject.setValue([name: "mute", value: "umuted", deviceId: "musicPlayerID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ powerMeterObject.setValue([name: "power", value: "70"/*A number between 0 to 100 as a charge*/, deviceId: "powerMeterID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ presenceSensorObject.setValue([name: "presence.present", value: "presence.present", deviceId: "presenceSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"presence":"1","dni":"mobile0"}'])
--- /dev/null
+ relaySwitchObject.setValue([name: "switch", value: "on", deviceId: "relaySwitchID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ relaySwitchObject.setValue([name: "switch", value: "off", deviceId: "relaySwitchID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ sleepSensorObject.setValue([name: "sleeping", value: "not sleeping", deviceId: "sleepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ sleepSensorObject.setValue([name: "sleeping", value: "sleeping", deviceId: "sleepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ smokeDetectorObject.setValue([name: "battery", value: "5"/*A number between 0 to 100 as a charge*/, deviceId: "smokeDetectorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ stepSensorObject.setValue([name: "goal", value: "100"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ stepSensorObject.setValue([name: "steps", value: "46"/*A number*/, deviceId: "stepSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ switchLevelObject.setValue([name: "level", value: "45"/*A number between 0 to 100*/, deviceId: "switchLevelID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ switchLevelObject.setValue([name: "switch", value: "off", deviceId: "switchLevelID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ switchLevelObject.setValue([name: "switch", value: "on", deviceId: "switchLevelID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "temperature", value: "55", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ temperatureMeasurementObject.setValue([name: "temperature", value: "45"/*A number between 0 to 100*/, deviceId: "temperatureMeasurementID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatFanMode", value: "auto", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatFanMode", value: "circulate", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatFanMode", value: "fanCirculate", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatFanMode", value: "fanOn", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatFanMode", value: "on", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatOperatingState", value: "auto", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatOperatingState", value: "cool", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatOperatingState", value: "emergencyHeat", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatOperatingState", value: "heat", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatOperatingState", value: "off", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ thermostatObject.setValue([name: "thermostatSetpoint", value: "50", deviceId: "thermostatID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ valveObject.setValue([name: "contact", value: "closed", deviceId: "valveID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ valveObject.setValue([name: "contact", value: "open", deviceId: "valveID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ waterSensorObject.setValue([name: "water", value: "dry", deviceId: "waterSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
--- /dev/null
+ waterSensorObject.setValue([name: "water", value: "wet", deviceId: "waterSensorID0", descriptionText: "",
+ displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+++ /dev/null
-//Infrastructure for SmartThings Application
-//Importing Libraries
-import groovy.transform.Field
-import groovy.json.JsonSlurper
-
-//Importing Classes
-import ContactSensor.ContactSensor
-import ContactSensor.ContactSensors
-import DoorControl.DoorControl
-import DoorControl.DoorControls
-import Lock.Lock
-import Lock.Locks
-import Thermostat.Thermostat
-import Thermostat.Thermostats
-import Switch.Switch
-import Switch.Switches
-import PresenceSensor.PresenceSensor
-import PresenceSensor.PresenceSensors
-import Logger.Logger
-import Location.LocationVar
-import Location.Phrase
-import appTouch.Touched
-import NfcTouch.NfcTouch
-import AeonKeyFob.AeonKeyFob
-import AeonKeyFob.AeonKeyFobs
-import MusicPlayer.MusicPlayer
-import MusicPlayer.MusicPlayers
-import MotionSensor.MotionSensor
-import MotionSensor.MotionSensors
-import ImageCapture.ImageCapture
-import ImageCapture.ImageCaptures
-import SmokeDetector.SmokeDetector
-import SmokeDetector.SmokeDetectors
-import Alarm.Alarm
-import Alarm.Alarms
-import SpeechSynthesis.SpeechSynthesis
-import SpeechSynthesis.SpeechSynthesises
-import AccelerationSensor.AccelerationSensor
-import AccelerationSensor.AccelerationSensors
-import Battery.Battery
-import Battery.Batteries
-import BeaconSensor.BeaconSensor
-import BeaconSensor.BeaconSensors
-import CarbonMonoxideDetector.CarbonMonoxideDetector
-import CarbonMonoxideDetector.CarbonMonoxideDetectors
-import ColorControl.ColorControl
-import ColorControl.ColorControls
-import EnergyMeter.EnergyMeter
-import EnergyMeter.EnergyMeters
-import IlluminanceMeasurement.IlluminanceMeasurement
-import IlluminanceMeasurement.IlluminanceMeasurements
-import PowerMeter.PowerMeter
-import PowerMeter.PowerMeters
-import RelativeHumidityMeasurement.RelativeHumidityMeasurement
-import RelativeHumidityMeasurement.RelativeHumidityMeasurements
-import RelaySwitch.RelaySwitch
-import RelaySwitch.RelaySwitches
-import SleepSensor.SleepSensor
-import SleepSensor.SleepSensors
-import StepSensor.StepSensor
-import StepSensor.StepSensors
-import SwitchLevel.SwitchLevel
-import SwitchLevel.SwitchLevels
-import TemperatureMeasurement.TemperatureMeasurement
-import TemperatureMeasurement.TemperatureMeasurements
-import WaterSensor.WaterSensor
-import WaterSensor.WaterSensors
-import Valve.Valve
-import Valve.Valves
-import MobilePresence.MobilePresence
-import MobilePresence.MobilePresences
-import Event.Event
-import Timer.SimulatedTimer
-
-//JPF's Verify API
-import gov.nasa.jpf.vm.Verify
-
-//Global eventHandler
-/////////////////////////////////////////////////////////////////////
-def eventHandler(LinkedHashMap eventDataMap) {
- def value = eventDataMap["value"]
- def name = eventDataMap["name"]
- def deviceId = eventDataMap["deviceId"]
- def descriptionText = eventDataMap["descriptionText"]
- def displayed = eventDataMap["displayed"]
- def linkText = eventDataMap["linkText"]
- def isStateChange = eventDataMap["isStateChange"]
- def unit = eventDataMap["unit"]
- def data = eventDataMap["data"]
-
- for (int i = 0;i < app2.eventList.size();i++) {
- if (app2.eventList[i] == name) {
- def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
- if (app2.functionList[i] instanceof String) {
- String toCall = app2.functionList[i]
- app2."$toCall"(event)
- }
- else
- app2.functionList[i](event)
- }
- }
-
- for (int i = 0;i < app1.eventList.size();i++) {
- if (app1.eventList[i] == name) {
- def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
- if (app1.functionList[i] instanceof String) {
- String toCall = app1.functionList[i]
- app1."$toCall"(event)
- }
- else
- app1.functionList[i](event)
- }
- }
-}
-
-//GlobalVariables for both Apps
-//Create a global variable for send event
-@Field def sendEvent = {eventDataMap ->
- eventHandler(eventDataMap)
- }
-//Object for location
-@Field def locationObject = new LocationVar(sendEvent)
-//Object for touch to call function
-@Field def appObject = new Touched(sendEvent, 0)
-//Create a global list for events
-//@Field def evt = []
-//Global Object for class Touch Sensor!
-@Field def touchSensorObject = new NfcTouch(sendEvent, 1)
-//Global Object for class switch!
-@Field def switchObject = new Switches(sendEvent, 1)
-//Global Object for class lock!
-@Field def lockObject = new Locks(sendEvent, 1)
-//Global Object for class door control!
-@Field def doorControlObject = new DoorControls(sendEvent, 1)
-//Global Object for class contact sensor!
-@Field def contactObject = new ContactSensors(sendEvent, 1)
-//Global Object for class presence sensor!
-@Field def presenceSensorObject = new PresenceSensors(sendEvent, 1)
-//Global Object for class thermostat!
-@Field def thermostatObject = new Thermostats(sendEvent, 1)
-//Global Object for class aeon key fob!
-@Field def aeonKeyFobObject = new AeonKeyFobs(sendEvent, 1)
-//Global Object for class music player!
-@Field def musicPlayerObject = new MusicPlayers(sendEvent, 1)
-//Global Object for class motion sensor!
-@Field def motionSensorObject = new MotionSensors(sendEvent, 1)
-//Global Object for class image capture!
-@Field def imageCaptureObject = new ImageCaptures(sendEvent, 1)
-//Global Object for class smoke detector!
-@Field def smokeDetectorObject = new SmokeDetectors(sendEvent, 1)
-//Global Object for class alarm!
-@Field def alarmObject = new Alarms(sendEvent, 1)
-//Global Object for class speech synthesis!
-@Field def speechSynthesisObject = new SpeechSynthesises(sendEvent, 1)
-//Global Object for class acceleration sensor!
-@Field def accelerationSensorObject = new AccelerationSensors(sendEvent, 1)
-//Global Object for class Battery!
-@Field def batteryObject = new Batteries(sendEvent, 1)
-//Global Object for class beacon sensor!
-@Field def beaconSensorObject = new BeaconSensors(sendEvent, 1)
-//Global Object for class carbon monoxide!
-@Field def carbonMonoxideDetectorObject = new CarbonMonoxideDetectors(sendEvent, 1)
-//Global Object for class color control!
-@Field def colorControlObject = new ColorControls(sendEvent, 1)
-//Global Object for class energy meter!
-@Field def energyMeterObject = new EnergyMeters(sendEvent, 1)
-//Global Object for class illuminance measurement!
-@Field def illuminanceMeasurementObject = new IlluminanceMeasurements(sendEvent, 1)
-//Global Object for class power meter!
-@Field def powerMeterObject = new PowerMeters(sendEvent, 1)
-//Global Object for class humidity measurement!
-@Field def humidityMeasurementObject = new RelativeHumidityMeasurements(sendEvent, 1)
-//Global Object for class relay switch!
-@Field def relaySwitchObject = new RelaySwitches(sendEvent, 1)
-//Global Object for class sleep sensor!
-@Field def sleepSensorObject = new SleepSensors(sendEvent, 1)
-//Global Object for class step sensor!
-@Field def stepSensorObject = new StepSensors(sendEvent, 1)
-//Global Object for class switch level!
-@Field def switchLevelObject = new SwitchLevels(sendEvent, 1)
-//Global Object for class temperature measurement!
-@Field def temperatureMeasurementObject = new TemperatureMeasurements(sendEvent, 1)
-//Global Object for class water sensor!
-@Field def waterSensorObject = new WaterSensors(sendEvent, 1)
-//Global Object for class valves!
-@Field def valveObject = new Valves(sendEvent, 1)
-//Global Object for class mobile presence!
-@Field def mobilePresenceObject = new MobilePresences(sendEvent, 1)
-
-//Application #1
-class App1 {
- def reference
- def location
- def app
-
- //Extracted objects for App1
- //Object for class color control!
- def master
- //Object for class color control!
- def slaves
- //Global variable for boolean!
- def randomYes = "1"
-
- //Extracted objects for functions for App1
- //Global Object for functions in subscribe method!
- def mainPage = this.&mainPage
- //Global Object for functions in subscribe method!
- def installed = this.&installed
- //Global Object for functions in subscribe method!
- def updated = this.&updated
- //Global Object for functions in subscribe method!
- def init = this.&init
- //Global Object for functions in subscribe method!
- def onOffHandler = this.&onOffHandler
- //Global Object for functions in subscribe method!
- def colorHandler = this.&colorHandler
- //Global Object for functions in subscribe method!
- def getRandomColorMaster = this.&getRandomColorMaster
- //Global Object for functions in subscribe method!
- def tempHandler = this.&tempHandler
- //Global Object for functions in subscribe method!
- def textAppName = this.&textAppName
- //Global Object for functions in subscribe method!
- def textVersion = this.&textVersion
- //Global Object for functions in subscribe method!
- def textCopyright = this.&textCopyright
- //Global Object for functions in subscribe method!
- def textLicense = this.&textLicense
- //Global Object for functions in subscribe method!
- def textHelp = this.&textHelp
-
- App1(Object obj) {
- reference = obj
- location = obj.locationObject
- app = obj.appObject
- master = obj.colorControlObject
- slaves = obj.colorControlObject
- //Global variable for settings!
- settings = [app: app, master: master, slaves: slaves, randomYes: randomYes, END: "END"]
- }
- //Global variables for each app
- //Global variable for state[mode]
- def state = [home:[],away:[],night:[]]
- //Create a global logger object for methods
- def log = new Logger()
- //Create a global variable for Functions in Subscribe method
- def functionList = []
- //Create a global variable for Objects in Subscribe method
- def objectList = []
- //Create a global variable for Events in Subscribe method
- def eventList = []
- //Create a global list for function schedulers
- def timersFuncList = []
- //Create a global list for timer schedulers
- def timersList = []
- //Create a global variable for settings
- def settings
- //Zip code
- def zipCode = 92617
- //atomicState variable
- def atomicState = [version: "1.01"]
-
- //Methods
- /////////////////////////////////////////////////////////////////////
- def setLocationMode(String mode) {
- location.setValue([name: "Location", value: "$mode", deviceId: "locationID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
- location.setValue([name: "mode", value: "$mode", deviceId: "locationID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
- }
-
- /////////////////////////////////////////////////////////////////////
- ////subscribe(obj, func)
- def subscribe(Object obj, Closure FunctionToCall) {
- if (obj == app) {
- objectList.add(obj)
- eventList.add("Touched")
- functionList.add(FunctionToCall)
- } else if (obj == location) {
- objectList.add(obj)
- eventList.add("Location")
- functionList.add(FunctionToCall)
- }
- }
- ////subscribe(obj, event, func)
- def subscribe(Object obj, String event, Closure FunctionToCall) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(FunctionToCall)
- }
- ////subscribe(obj, event, nameOfFunc)
- def subscribe(Object obj, String event, String nameOfFunction) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(nameOfFunction)
- }
- ////subscribe(obj, event, func, data)
- def subscribe(Object obj, String event, Closure FunctionToCall, LinkedHashMap metaData) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(FunctionToCall)
- }
- /////////////////////////////////////////////////////////////////////
- ////runIn(time, func)
- def runIn(int seconds, Closure functionToCall) {
- if (timersFuncList.contains(functionToCall)) {
- timersList[timersFuncList.indexOf(functionToCall)].cancel()
- def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
- } else {
- timersFuncList.add(functionToCall)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
- }
- }
-
- def runIn(int seconds, Closure functionToCall, LinkedHashMap metaData) {
- runIn(seconds, functionToCall)
- }
-
- def runIn(int seconds, String nameOfFunction, LinkedHashMap metaData) {
- runIn(seconds, nameOfFunction)
- }
-
- def runIn(int seconds, String nameOfFunction) {
- timersFuncList.add(nameOfFunction)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(seconds*1000*0) {
- "$nameOfFunction"()
- }
- }
- /////////////////////////////////////////////////////////////////////
- ////unschedule(func)
- def unschedule(Closure functionToUnschedule) {
- for (int i = 0;i < timersFuncList.size();i++) {
- if (timersFuncList[i] == functionToUnschedule) {
- if (timersList != null)
- timersList[i].cancel()
- }
- }
- }
-
- def unschedule(String nameOfFunctionToUnschedule) {
- for (int i = 0;i < timersFuncList.size();i++) {
- if (timersFuncList[i] instanceof String) {
- if (timersFuncList[i] == nameOfFunctionToUnschedule) {
- if (timersList != null)
- timersList[i].cancel()
- }
- }
- }
- }
-
-
- def unschedule() {
- for (int i = 0;i < timersFuncList.size();i++) {
- if (timersList != null)
- timersList[i].cancel()
- }
- }
- /////////////////////////////////////////////////////////////////////
- ////sendNotificationToContacts(text, recipients)
- def sendNotificationToContacts(String text, String recipients) {
- for (int i = 0;i < recipients.size();i++) {
- for (int j = 0;j < location.contacts.size();j++) {
- if (recipients[i] == location.contacts[j]) {
- println("Sending \""+text+"\" to "+location.phoneNumbers[j].toString())
- }
- }
- }
- }
-
- def sendNotificationToContacts(String text, String recipients, LinkedHashMap metaData) {
- for (int i = 0;i < recipients.size();i++) {
- for (int j = 0;j < location.contacts.size();j++) {
- if (recipients[i] == location.contacts[j]) {
- println("Sending \""+text+"\" to "+location.phoneNumbers[j].toString())
- }
- }
- }
- }
- /////////////////////////////////////////////////////////////////////
- ////sendSms(phone, text)
- def sendSms(long phoneNumber, String text) {
- println("Sending \""+text+"\" to "+phoneNumber.toString())
- }
-
- def sendSMS(long phoneNumber, String text) {
- println("Sending \""+text+"\" to "+phoneNumber.toString())
- }
- /////////////////////////////////////////////////////////////////////
- ////sendPush(text)
- def sendPush(String text) {
- println(text)
- }
- /////////////////////////////////////////////////////////////////////
- ////schedule(time, nameOfFunction as String)
- def schedule(String time, String nameOfFunction) {
- def _inputTime = time.split(':')
- Date date = new Date()
- def _currentTime = date.format("HH:mm:ss").split(':')
-
- //Convert input time and current time to minutes
- def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60
- def currentTime = Integer.parseInt(_currentTime[0])*3600+Integer.parseInt(_currentTime[1])*60+Integer.parseInt(_currentTime[2])
- def delay
-
- if (inputTime < currentTime) {
- delay = 24*60*60-inputTime+currentTime
- } else {
- delay = inputTime-currentTime
- }
-
- timersFuncList.add(nameOfFunction)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*1000*0) {
- "$nameOfFunction"()
- }
- }
- ////schedule(time, nameOfFunction as Closure)
- def schedule(String time, Closure nameOfFunction) {
- def _inputTime = time.split(':')
- Date date = new Date()
- def _currentTime = date.format("HH:mm:ss").split(':')
-
- //Convert input time and current time to minutes
- def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60
- def currentTime = Integer.parseInt(_currentTime[0])*3600+Integer.parseInt(_currentTime[1])*60+Integer.parseInt(_currentTime[2])
- def delay
-
- if (inputTime < currentTime) {
- delay = 24*60*60-inputTime+currentTime
- } else {
- delay = inputTime-currentTime
- }
-
- if (timersFuncList.contains(nameOfFunction)) {
- timersList[timersFuncList.indexOf(nameOfFunction)].cancel()
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*0, nameOfFunction)
- } else {
- timersFuncList.add(nameOfFunction)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*0, nameOfFunction)
- }
- }
- /////////////////////////////////////////////////////////////////////
- def now() {
- return System.currentTimeMillis()
- }
- /////////////////////////////////////////////////////////////////////
- def getTemperatureScale() {
- return 'F' //Celsius for now
- }
-
- /////////////////////////////////////////////////////////////////////
- def getSunriseAndSunset(LinkedHashMap metaData) {
- def sunRiseSetInfo = [sunrise:[time:1563800160000],sunset:[time:1563850740000]]
- return sunRiseSetInfo
- }
- /////////////////////////////////////////////////////////////////////
- def httpPostJson(LinkedHashMap metaData, Closure inputData) {
- inputData(metaData)
- }
- /////////////////////////////////////////////////////////////////////
- def runEvery15Minutes(Closure inputData) {
- inputData()
- }
- /////////////////////////////////////////////////////////////////////
- def timeToday(String time, Object timeZone) {
- def timeOfDay = new Date()
- def _inputTime = time.split(':')
- def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60+1564191100415
- timeOfDay.time = inputTime
- return timeOfDay
- }
- /////////////////////////////////////////////////////////////////////
- def sendNotification(String text, LinkedHashMap metaData) {
- println("Sending \""+text+"\" to "+metaData.phone.toString())
- }
- /////////////////////////////////////////////////////////////////////
- def canSchedule() {
- return true
- }
- /////////////////////////////////////////////////////////////////////
- def createAccessToken() {
- state.accessToken = "accessToken"
- return state.accessToken
- }
- /////////////////////////////////////////////////////////////////////
- def runOnce(Date date, Closure methodToCall) {
- methodTocall()
- }
-
- def mainPage() {
- section("Master Light") {
- input "master", "capability.colorControl", title: "Colored Light", required: true
- }
- section("Lights that follow the master settings") {
- input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: true, submitOnChange: true
- }
- section([mobileOnly:true], "Options") {
- input "randomYes", "bool",title: "When Master Turned On, Randomize Color", defaultValue: false
- href "pageAbout", title: "About ${textAppName()}", description: "Tap to get application version, license and instructions"
- }
-
- dynamicPage(name: "mainPage", title: "", install: true, uninstall: false) {
- def masterInList = slaves?.id?.find{it==master?.id}
- if (masterInList) {
- section ("**WARNING**"){
- paragraph "You have included the Master Light in the Slave Group. This will cause a loop in execution. Please remove this device from the Slave Group.", image: "https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/img/caution.png"
- }
- }
-
- page(name: "pageAbout", title: "About ${textAppName()}", uninstall: true) {
- section {
- paragraph "${textVersion()}\n${textCopyright()}\n\n${textLicense()}\n"
- }
- section("Instructions") {
- paragraph textHelp()
- }
- section("Tap button below to remove application"){
- }
- }
-
- }
- }
-
- def installed() {
- init()
- }
-
- def updated(){
- unsubscribe()
- init()
- }
-
- def init() {
- subscribe(master, "switch", onOffHandler)
- subscribe(master, "level", colorHandler)
- subscribe(master, "hue", colorHandler)
- subscribe(master, "saturation", colorHandler)
- subscribe(master, "colorTemperature", tempHandler)
- }
- //-----------------------------------
- def onOffHandler(evt){
- if (slaves && master) {
- if (!slaves?.id.find{it==master?.id}){
- if (master?.currentValue("switch") == "on"){
- if (randomYes) getRandomColorMaster()
- else slaves?.on()
- }
- else {
- slaves?.off()
- }
- }
- }
- }
-
- def colorHandler(evt) {
- if (slaves && master) {
- if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
- log.debug "Changing Slave units H,S,L"
- def dimLevel = master?.currentValue("level")
- def hueLevel = master?.currentValue("hue")
- def saturationLevel = master.currentValue("saturation")
- def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
- slaves?.setColor(newValue)
- try {
- log.debug "Changing Slave color temp"
- def tempLevel = master?.currentValue("colorTemperature")
- slaves?.setColorTemperature(tempLevel)
- }
- catch (e){
- log.debug "Color temp for master --"
- }
- }
- }
- }
-
- def getRandomColorMaster(){
- def hueLevel = Math.floor(Math.random() *1000)
- def saturationLevel = Math.floor(Math.random() * 100)
- def dimLevel = master?.currentValue("level")
- def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
- log.debug hueLevel
- log.debug saturationLevel
- master.setColor(newValue)
- slaves?.setColor(newValue)
- }
-
- def tempHandler(evt){
- if (slaves && master) {
- if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
- if (evt.value != "--") {
- log.debug "Changing Slave color temp based on Master change"
- def tempLevel = master.currentValue("colorTemperature")
- slaves?.setColorTemperature(tempLevel)
- }
- }
- }
- }
-
- //Version/Copyright/Information/Help
-
- private def textAppName() {
- def text = "Color Coordinator"
- }
-
- private def textVersion() {
- def text = "Version 1.1.1 (12/13/2016)"
- }
-
- private def textCopyright() {
- def text = "Copyright © 2016 Michael Struck"
- }
-
- private def textLicense() {
- def text =
- "Licensed under the Apache License, Version 2.0 (the 'License'); "+
- "you may not use this file except in compliance with the License. "+
- "You may obtain a copy of the License at"+
- "\n\n"+
- " http://www.apache.org/licenses/LICENSE-2.0"+
- "\n\n"+
- "Unless required by applicable law or agreed to in writing, software "+
- "distributed under the License is distributed on an 'AS IS' BASIS, "+
- "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. "+
- "See the License for the specific language governing permissions and "+
- "limitations under the License."
- }
-
- private def textHelp() {
- def text =
- "This application will allow you to control the settings of multiple colored lights with one control. " +
- "Simply choose a master control light, and then choose the lights that will follow the settings of the master, "+
- "including on/off conditions, hue, saturation, level and color temperature. Also includes a random color feature."
- }
-
-}
-
-
-//Application #2
-class App2 {
- def reference
- def location
- def app
-
- //Extracted objects for App2
- //Object for class contactSensor!
- def deviceContactSensor
- //Global variable for time!
- def reminderTime = "15:00"
- //Object for class color control!
- def deviceLight
-
- //Extracted objects for functions for App2
- //Global Object for functions in subscribe method!
- def installed = this.&installed
- //Global Object for functions in subscribe method!
- def updated = this.&updated
- //Global Object for functions in subscribe method!
- def initialize = this.&initialize
- //Global Object for functions in subscribe method!
- def contactHandler = this.&contactHandler
- //Global Object for functions in subscribe method!
- def checkOpenDrawInPast = this.&checkOpenDrawInPast
- //Global Object for functions in subscribe method!
- def checkOpenDrawAfterReminder = this.&checkOpenDrawAfterReminder
- //Global Object for functions in subscribe method!
- def sendNotification = this.&sendNotification
- //Global Object for functions in subscribe method!
- def isOpened = this.&isOpened
- //Global Object for functions in subscribe method!
- def setLEDNotification = this.&setLEDNotification
- //Global Object for functions in subscribe method!
- def resetLEDNotification = this.&resetLEDNotification
-
- App2(Object obj) {
- reference = obj
- location = obj.locationObject
- app = obj.appObject
- deviceContactSensor = obj.contactObject
- deviceLight = obj.colorControlObject
- //Global variable for settings!
- settings = [app: app, deviceContactSensor: deviceContactSensor, reminderTime: reminderTime, deviceLight: deviceLight, END: "END"]
- }
- //Global variables for each app
- //Global variable for state[mode]
- def state = [home:[],away:[],night:[]]
- //Create a global logger object for methods
- def log = new Logger()
- //Create a global variable for Functions in Subscribe method
- def functionList = []
- //Create a global variable for Objects in Subscribe method
- def objectList = []
- //Create a global variable for Events in Subscribe method
- def eventList = []
- //Create a global list for function schedulers
- def timersFuncList = []
- //Create a global list for timer schedulers
- def timersList = []
- //Create a global variable for settings
- def settings
- //Zip code
- def zipCode = 92617
- //atomicState variable
- def atomicState = [version: "1.01"]
-
- //Methods
- /////////////////////////////////////////////////////////////////////
- def setLocationMode(String mode) {
- location.setValue([name: "Location", value: "$mode", deviceId: "locationID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
- location.setValue([name: "mode", value: "$mode", deviceId: "locationID0", descriptionText: "",
- displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
- }
-
- /////////////////////////////////////////////////////////////////////
- ////subscribe(obj, func)
- def subscribe(Object obj, Closure FunctionToCall) {
- if (obj == app) {
- objectList.add(obj)
- eventList.add("Touched")
- functionList.add(FunctionToCall)
- } else if (obj == location) {
- objectList.add(obj)
- eventList.add("Location")
- functionList.add(FunctionToCall)
- }
- }
- ////subscribe(obj, event, func)
- def subscribe(Object obj, String event, Closure FunctionToCall) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(FunctionToCall)
- }
- ////subscribe(obj, event, nameOfFunc)
- def subscribe(Object obj, String event, String nameOfFunction) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(nameOfFunction)
- }
- ////subscribe(obj, event, func, data)
- def subscribe(Object obj, String event, Closure FunctionToCall, LinkedHashMap metaData) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(FunctionToCall)
- }
- /////////////////////////////////////////////////////////////////////
- ////runIn(time, func)
- def runIn(int seconds, Closure functionToCall) {
- if (timersFuncList.contains(functionToCall)) {
- timersList[timersFuncList.indexOf(functionToCall)].cancel()
- def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
- } else {
- timersFuncList.add(functionToCall)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
- }
- }
-
- def runIn(int seconds, Closure functionToCall, LinkedHashMap metaData) {
- runIn(seconds, functionToCall)
- }
-
- def runIn(int seconds, String nameOfFunction, LinkedHashMap metaData) {
- runIn(seconds, nameOfFunction)
- }
-
- def runIn(int seconds, String nameOfFunction) {
- timersFuncList.add(nameOfFunction)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(seconds*1000*0) {
- "$nameOfFunction"()
- }
- }
- /////////////////////////////////////////////////////////////////////
- ////unschedule(func)
- def unschedule(Closure functionToUnschedule) {
- for (int i = 0;i < timersFuncList.size();i++) {
- if (timersFuncList[i] == functionToUnschedule) {
- if (timersList != null)
- timersList[i].cancel()
- }
- }
- }
-
- def unschedule(String nameOfFunctionToUnschedule) {
- for (int i = 0;i < timersFuncList.size();i++) {
- if (timersFuncList[i] instanceof String) {
- if (timersFuncList[i] == nameOfFunctionToUnschedule) {
- if (timersList != null)
- timersList[i].cancel()
- }
- }
- }
- }
-
-
- def unschedule() {
- for (int i = 0;i < timersFuncList.size();i++) {
- if (timersList != null)
- timersList[i].cancel()
- }
- }
- /////////////////////////////////////////////////////////////////////
- ////sendNotificationToContacts(text, recipients)
- def sendNotificationToContacts(String text, String recipients) {
- for (int i = 0;i < recipients.size();i++) {
- for (int j = 0;j < location.contacts.size();j++) {
- if (recipients[i] == location.contacts[j]) {
- println("Sending \""+text+"\" to "+location.phoneNumbers[j].toString())
- }
- }
- }
- }
-
- def sendNotificationToContacts(String text, String recipients, LinkedHashMap metaData) {
- for (int i = 0;i < recipients.size();i++) {
- for (int j = 0;j < location.contacts.size();j++) {
- if (recipients[i] == location.contacts[j]) {
- println("Sending \""+text+"\" to "+location.phoneNumbers[j].toString())
- }
- }
- }
- }
- /////////////////////////////////////////////////////////////////////
- ////sendSms(phone, text)
- def sendSms(long phoneNumber, String text) {
- println("Sending \""+text+"\" to "+phoneNumber.toString())
- }
-
- def sendSMS(long phoneNumber, String text) {
- println("Sending \""+text+"\" to "+phoneNumber.toString())
- }
- /////////////////////////////////////////////////////////////////////
- ////sendPush(text)
- def sendPush(String text) {
- println(text)
- }
- /////////////////////////////////////////////////////////////////////
- ////schedule(time, nameOfFunction as String)
- def schedule(String time, String nameOfFunction) {
- def _inputTime = time.split(':')
- Date date = new Date()
- def _currentTime = date.format("HH:mm:ss").split(':')
-
- //Convert input time and current time to minutes
- def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60
- def currentTime = Integer.parseInt(_currentTime[0])*3600+Integer.parseInt(_currentTime[1])*60+Integer.parseInt(_currentTime[2])
- def delay
-
- if (inputTime < currentTime) {
- delay = 24*60*60-inputTime+currentTime
- } else {
- delay = inputTime-currentTime
- }
-
- timersFuncList.add(nameOfFunction)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*1000*0) {
- "$nameOfFunction"()
- }
- }
- ////schedule(time, nameOfFunction as Closure)
- def schedule(String time, Closure nameOfFunction) {
- def _inputTime = time.split(':')
- Date date = new Date()
- def _currentTime = date.format("HH:mm:ss").split(':')
-
- //Convert input time and current time to minutes
- def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60
- def currentTime = Integer.parseInt(_currentTime[0])*3600+Integer.parseInt(_currentTime[1])*60+Integer.parseInt(_currentTime[2])
- def delay
-
- if (inputTime < currentTime) {
- delay = 24*60*60-inputTime+currentTime
- } else {
- delay = inputTime-currentTime
- }
-
- if (timersFuncList.contains(nameOfFunction)) {
- timersList[timersFuncList.indexOf(nameOfFunction)].cancel()
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*0, nameOfFunction)
- } else {
- timersFuncList.add(nameOfFunction)
- timersList.add(new SimulatedTimer())
- def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*0, nameOfFunction)
- }
- }
- /////////////////////////////////////////////////////////////////////
- def now() {
- return System.currentTimeMillis()
- }
- /////////////////////////////////////////////////////////////////////
- def getTemperatureScale() {
- return 'F' //Celsius for now
- }
-
- /////////////////////////////////////////////////////////////////////
- def getSunriseAndSunset(LinkedHashMap metaData) {
- def sunRiseSetInfo = [sunrise:[time:1563800160000],sunset:[time:1563850740000]]
- return sunRiseSetInfo
- }
- /////////////////////////////////////////////////////////////////////
- def httpPostJson(LinkedHashMap metaData, Closure inputData) {
- inputData(metaData)
- }
- /////////////////////////////////////////////////////////////////////
- def runEvery15Minutes(Closure inputData) {
- inputData()
- }
- /////////////////////////////////////////////////////////////////////
- def timeToday(String time, Object timeZone) {
- def timeOfDay = new Date()
- def _inputTime = time.split(':')
- def inputTime = Integer.parseInt(_inputTime[0])*3600+Integer.parseInt(_inputTime[1])*60+1564191100415
- timeOfDay.time = inputTime
- return timeOfDay
- }
- /////////////////////////////////////////////////////////////////////
- def sendNotification(String text, LinkedHashMap metaData) {
- println("Sending \""+text+"\" to "+metaData.phone.toString())
- }
- /////////////////////////////////////////////////////////////////////
- def canSchedule() {
- return true
- }
- /////////////////////////////////////////////////////////////////////
- def createAccessToken() {
- state.accessToken = "accessToken"
- return state.accessToken
- }
- /////////////////////////////////////////////////////////////////////
- def runOnce(Date date, Closure methodToCall) {
- methodTocall()
- }
-
- def installed() {
- log.debug "Installed with settings: ${settings}"
-
- initialize()
- }
-
- def updated() {
- log.debug "Updated with settings: ${settings}"
-
- unsubscribe()
-
- initialize()
- }
-
- def initialize() {
-
- // will stop LED notification incase it was set by med reminder
- subscribe(deviceContactSensor, "contact", contactHandler)
-
- // how many minutes to look in the past from the reminder time, for an open draw
- state.minutesToCheckOpenDraw = 60
-
- // is true when LED notification is set after exceeding 10 minutes past reminder time
- state.ledNotificationTriggered = false
-
- // Set a timer to run once a day to notify if draw wasn't opened yet
- schedule(reminderTime, checkOpenDrawInPast)
-
- }
-
- // Should turn off any LED notification on OPEN state
- def contactHandler(evt){
- if (evt.value == "open") {
- // if LED notification triggered, reset it.
- log.debug "Cabinet opened"
- if (state.ledNotificationTriggered) {
- resetLEDNotification()
- }
- }
- }
-
- // If the draw was NOT opened within 60 minutes of the timer send notification out.
- def checkOpenDrawInPast(){
- log.debug "Checking past 60 minutes of activity from $reminderTime"
-
- // check activity of sensor for past 60 minutes for any OPENED status
- def cabinetOpened = isOpened(state.minutesToCheckOpenDraw)
- log.debug "Cabinet found opened: $cabinetOpened"
-
- // if it's opened, then do nothing and assume they took their meds
- if (!cabinetOpened) {
- sendNotification("Hi, please remember to take your meds in the cabinet")
-
- // if no open activity, send out notification and set new reminder
- def reminderTimePlus10 = new Date(now() + (10 * 60000))
-
- // needs to be scheduled if draw wasn't already opened
- runOnce(reminderTimePlus10, checkOpenDrawAfterReminder)
- }
- }
-
- // If the draw was NOT opened after 10 minutes past reminder, use LED notification
- def checkOpenDrawAfterReminder(){
- log.debug "Checking additional 10 minutes of activity from $reminderTime"
-
- // check activity of sensor for past 10 minutes for any OPENED status
- def cabinetOpened = isOpened(10)
-
- log.debug "Cabinet found opened: $cabinetOpened"
-
- // if no open activity, blink lights
- if (!cabinetOpened) {
- log.debug "Set LED to Notification color"
- setLEDNotification()
- }
-
- }
-
- // Helper function for sending out an app notification
- def sendNotification(msg){
- log.debug "Message Sent: $msg"
- sendPush(msg)
- }
-
- // Check if the sensor has been opened since the minutes entered
- // Return true if opened found, else false.
- def isOpened(minutes){
- // query last X minutes of activity log
- def previousDateTime = new Date(now() - (minutes * 60000))
-
- // capture all events recorded
- def evts = deviceContactSensor.eventsSince(previousDateTime)
- def cabinetOpened = false
- if (evts.size() > 0) {
- evts.each{
- if(it.value == "open") {
- cabinetOpened = true
- }
- }
- }
-
- return cabinetOpened
- }
-
- // Saves current color and sets the light to RED
- def setLEDNotification(){
-
- state.ledNotificationTriggered = true
-
- // turn light back off when reset is called if it was originally off
- state.ledState = deviceLight.currentValue("switch")
-
- // set light to RED and store original color until stopped
- state.origColor = deviceLight.currentValue("hue")
- deviceLight.on()
- deviceLight.setHue(100)
-
- log.debug "LED set to RED. Original color stored: $state.origColor"
-
- }
-
- // Sets the color back to the original saved color
- def resetLEDNotification(){
-
- state.ledNotificationTriggered = false
-
- // return color to original
- log.debug "Reset LED color to: $state.origColor"
- if (state.origColor != null) {
- deviceLight.setHue(state.origColor)
- }
-
- // if the light was turned on just for the notification, turn it back off now
- if (state.ledState == "off") {
- deviceLight.off()
- }
-
- }
-}
-
-@Field def app1
-@Field def app2
-
-app1 = new App1(this)
-app2 = new App2(this)
-
-app1.installed()
-app2.installed()
-
-contactObject.setValue([name: "contact", value: "open", deviceId: "contactSensorID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-contactObject.setValue([name: "contact", value: "closed", deviceId: "contactSensorID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-contactObject.setValue([name: "contact", value: "open", deviceId: "contactSensorID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-
-colorControlObject.setValue([name: "hue", value: "32", deviceId: "colorControlID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-colorControlObject.setValue([name: "saturation", value: "32", deviceId: "colorControlID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-colorControlObject.setValue([name: "level", value: "32", deviceId: "colorControlID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-colorControlObject.setValue([name: "switch", value: "on", deviceId: "colorControlID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-colorControlObject.setValue([name: "switch", value: "off", deviceId: "colorControlID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-colorControlObject.setValue([name: "switch", value: "on", deviceId: "colorControlID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-colorControlObject.setValue([name: "colorTemperature", value: "32", deviceId: "colorControlID0", descriptionText: "",
-displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
#!/bin/bash
# Device conflict
-python ModelCheck.py ../jpf-core/ ../logs/ ../smartapps/ appLists/device-interaction/locksAppList
+python ModelCheck.py ../jpf-core/ ../logs/alarms/ ../smartapps/ appLists/device-interaction/alarmsAppList appLists/device-interaction/alarmsAppList2
+#python ModelCheck.py ../jpf-core/ ../logs/locks/ ../smartapps/ appLists/device-interaction/locksAppList appLists/device-interaction/locksAppList2
+#python ModelCheck.py ../jpf-core/ ../logs/musicPlayers/ ../smartapps/ appLists/device-interaction/musicPlayersAppList
+#python ModelCheck.py ../jpf-core/ ../logs/relaySwitch/ ../smartapps/ appLists/device-interaction/relaySwitchesAppList
+#python ModelCheck.py ../jpf-core/ ../logs/cameras/ ../smartapps/ appLists/device-interaction/camerasAppList
# Physical conflict
#python ModelCheck.py ../jpf-core/ ../logs/ ../smartapps/ appLists/physical-interaction/soundsensorAppList appLists/physical-interaction/soundAppList