Foscam Activation Smartapp throwing an error on V2 hub

Hey y’all, I’m running into a snag when trying to re-use an old smartapp from my V1 hub to control when my Foscam clone camera turns on and off based on away/home settings. Basically, I can see the camera fine, and manually enabling it and getting images from it etc. works fine, but when I try to use the attached code to activate it automatically it give me issues. Oddly, from the desktop IDE it installs without issue and seems to work, but if I try to install the smartapp or view it from the phone it gives me the error message “Sorry, but there was an unexpected error” and shows a blank screen with only “Remove” on it, but the Remove option also does nothing. What’s puzzling me is that it worked fine on the V1 but once I migrated I have no success. Thanks!

Here’s the code for the smartapp (I’d fully pulled it from a pre-existing smartapp found on this community, hope that’s ok…):


  • Secure My Foscam
  • Author:
  • Date: 9/25/13
  • Simply turns on the alarm for any Foscam custome device. This is intended
  • to be used with the Foscam custom device type with a camera set up for FTP
  • or email uploading based on motion detection.

// Automatically generated. Make future change here.
name: “Peaches Foscam”,
namespace: " ",
author: “[removed for posting]”,
description: “foscam activator”,
iconUrl: “”,
iconX2Url: “”,
iconX3Url: “”)

preferences {
section(“When the house is in this mode…”) {
input “newSTMode”, “mode”, Title: “Mode?”

section(“Change to this mode to…”) {
input “newMode”, “enum”, metadata:[values:[“Alarm On”, “Alarm Off”]]

section(“Move to this preset…”) {
input “newPreset”, “enum”, metadata:[values:([1, 2, 3])], required: false

section(“Change these Foscam modes…”) {
input “foscams”, “capability.imageCapture”, multiple: true


def installed() {
subscribe(location, changeMode)
subscribe(app, changeMode)

def updated() {
subscribe(location, changeMode)
subscribe(app, changeMode)

def changeMode(evt) {
if(newPreset) {
def preset = new Integer(newPreset)"Preset: ${preset}")


if(newMode == “Alarm On”) {“Alarm: on”)
/** def message = "${app.label} activated the IP Camera because everyone left home"



else {“Alarm: off”)
/** def message = "${app.label} disarmed the IP Camera because someone is home"