/**
- Take a Snapshot When There’s Motion
-
- Author: Eric Miller (with much help from many others)
*/
// Automatically generated. Make future change here.
definition(
name: “Motion Triggers ispy to take Snapshot”,
namespace: “”,
author: “my e-mail address”,
description: “Using SmartThings Motion to trigger ip security cameras run by ispyconnect sending http command from local SmartThings hub”,
category: “My Apps”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png”)
preferences {
section(“When there’s movement…”){
input “motion1”, “capability.motionSensor”, title: “Where?”
}
section(“Take a snapshot of…”){
input “camera1”, “camera”, title: “Camera number?”
// Camera number must be the ispy camera number shown on the ispy console
}
}
def installed()
{
// log.debug “Installed with settings: ${settings}”
subscribe(motion1, "motion.active", motionActiveHandler)
}
def updated()
{
// log.debug “Updated with settings: ${settings}”
unsubscribe()
subscribe(motion1, "motion.active", motionActiveHandler)
}
def motionActiveHandler(evt) {
// log.trace “$evt.value: $evt, $settings”
// log.debug “$motion1 detected motion, initiating snapshot on $camera1”
// Put this in for debug purposes to make sure it was firing and had the correct parameters
def deviceNetworkId = "C0A80112:1F90" // "192.168.1.18:8080"
// The deviceNetworkId is the hex encoded IP and port of the PC running ispy in the home
def ip = "192.168.1.18:8080"
// This is the ip of the PC running the ispy application in the home
sendHubCommand(new physicalgraph.device.HubAction("""GET /snapshot?ot=2&oid=$camera1 HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))
// Snapshot is an ispy command so the syntax is driven by ispy
// log.debug location.hubs*.firmwareVersionString.findAll { it }
}
def locationHandler(evt) {
def description = evt.description
def hub = evt?.hubId
// log.debug "cp desc: " + description
//log.debug description
}