In case this helps someone else, I put together a smartapp that will move your foscam camera to different presets based on motion sensors or contact/acceleration sensors. For me if a motion sensor is tripped in the front of the house the camera automatically pans to preset1 to view that location, and goes to another preset for the motion sensor and multi sensor in the back of the house. Now that my camera is pointed to the correct position, my foscam’s built-in motion sensor takes over. Here’s the code:
/**
* Foscam Smart Preset
*
* Copyright 2014 Jake Rorrer
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
definition(
name: "Foscam Smart Preset",
namespace: "",
author: "Jake Rorrer",
description: "Moves Foscam cameras to a preset based on activity detected by motion or multi-sensors. That way your Foscam will be properly positioned and ready to snap a photo when a burglar comes into frame.",
category: "Safety & Security",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences {
section("When there's movement or a door opens...") {
input "motion", "capability.motionSensor", title: "Motion Here", required: false, multiple: true
input "contact", "capability.contactSensor", title: "Contact Opens", required: false, multiple: true
input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false, multiple: true
}
section("Move to this preset...") {
input "newPreset", "enum", metadata:[values:[1, 2, 3]], required: false
}
section("For these Foscam cameras...") {
input "foscams", "capability.imageCapture", multiple: true, required: false
}
}
def installed()
{
subscribeToEvents()
}
def updated()
{
unsubscribe()
subscribeToEvents()
}
def subscribeToEvents() {
subscribe(contact, "contact.open", motionActiveHandler)
subscribe(acceleration, "acceleration.active", motionActiveHandler)
subscribe(motion, "motion.active", motionActiveHandler)
}
def motionActiveHandler(evt) {
log.trace "$evt.value: $evt, $settings"
log.debug "Detected movement or door opening, moving Foscam to preset $newPreset position"
if(newPreset) {
def preset = new Integer(newPreset)
log.info("Preset: ${preset}")
foscams?.preset(preset)
}
}