initial commit from LCF 4/22/16 show

This commit is contained in:
pstuart
2016-04-22 20:50:38 -05:00
commit 03a1306cd2
3 changed files with 262 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
/**
* Generic Video Camera Child
*
* Copyright 2016 Patrick Stuart
*
* 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: "Generic Video Camera Child",
namespace: "pstuart",
author: "Patrick Stuart",
description: "Child Video Camera SmartApp",
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",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences {
page(name: "mainPage", title: "Install Video Camera", install: true, uninstall:true) {
section("Camera Name") {
label(name: "label", title: "Name This Camera", required: true, multiple: false, submitOnChange: true)
}
section("Add a Camera") {
input("CameraStreamPathList","enum", title: "Camera Stream Path", description: "Please enter your camera's streaming path", required:false, submitOnChange: true,
options: [
["rtsp://admin:winter12@192.168.101.185/Streaming/Channels/1":"Hikvision"], //hikvision
["http://192.168.101.248:80/mjpeg.cgi?user=admin&password=winter12&channel=1.mjpeg":"Dlink"], //dlink 932l
["http://pstuart:winter12@192.168.101.251/nphMotionJpeg?Resolution=640x480&Quality=Standard":"Panasonic"] //panasonic bl-140c
], displayDuringSetup: true)
input("CameraStreamPathCustom","string", title: "Camera Stream Path", description: "Please enter your camera's streaming path", defaultValue: settings?.CameraStreamPathList, required:false, displayDuringSetup: true)
}
}
}
def installed() {
log.debug "Installed"
initialize()
}
def updated() {
log.debug "Updated"
unsubscribe()
initialize()
}
def initialize() {
log.debug "CameraStreamPathList is $CameraStreamPathList"
log.debug "CameraStreamPathCustom is $CameraStreamPathCustom"
if(CameraStreamPathList) { state.CameraStreamPath = CameraStreamPathList }
if(CameraStreamPathCustom) { state.CameraStreamPath = CameraStreamPathCustom }
try {
def DNI = (Math.abs(new Random().nextInt()) % 99999 + 1).toString()
def cameras = getChildDevices()
if (cameras) {
removeChildDevices(getChildDevices())
}
def childDevice = addChildDevice("pstuart", "Generic Video Camera", DNI, null, [name: app.label, label: app.label, completedSetup: true])
} catch (e) {
log.error "Error creating device: ${e}"
}
}
private removeChildDevices(delete) {
delete.each {
deleteChildDevice(it.deviceNetworkId)
}
}

View File

@@ -0,0 +1,57 @@
/**
* Generic Video Camera Connect
*
* Copyright 2016 Patrick Stuart
*
* 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: "Generic Video Camera Connect",
namespace: "pstuart",
author: "Patrick Stuart",
description: "This smartapp installs the Generic Video Camera Connect App so you can add multiple child video cameras",
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",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
singleInstance: true)
preferences {
page(name: "mainPage", title: "Existing Camera", install: true, uninstall: true) {
if(state?.installed) {
section("Add a New Camera") {
app "Generic Video Camera Child", "pstuart", "Generic Video Camera Child", title: "New Camera", page: "mainPage", multiple: true, install: true
}
} else {
section("Initial Install") {
paragraph "This smartapp installs the Generic Video Camera Connect App so you can add multiple child video cameras. Click install / done then go to smartapps in the flyout menu and add new cameras or edit existing cameras."
}
}
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
state.installed = true
}