├── README.md ├── devicetypes └── pstuart │ └── generic-video-camera.src │ └── generic-video-camera.groovy └── smartapps └── pstuart ├── generic-video-camera-child.src └── generic-video-camera-child.groovy └── generic-video-camera-connect.src └── generic-video-camera-connect.groovy /README.md: -------------------------------------------------------------------------------- 1 | # Generic-Video-Camera 2 | I no longer support ST or any of the code I have written for that platform. Check out https://hubitat.com for my latest project and team I'm working on that is better than ST and is all local. 3 | -------------------------------------------------------------------------------- /devicetypes/pstuart/generic-video-camera.src/generic-video-camera.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Generic Video Camera 3 | * 4 | * Copyright 2016 Patrick Stuart 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 | metadata { 17 | definition (name: "Generic Video Camera", namespace: "pstuart", author: "Patrick Stuart") { 18 | capability "Configuration" 19 | capability "Video Camera" 20 | capability "Video Capture" 21 | capability "Refresh" 22 | capability "Switch" 23 | 24 | // custom commands 25 | command "start" 26 | } 27 | 28 | simulator { 29 | // TODO: define status and reply messages here 30 | } 31 | 32 | tiles(scale: 2) { 33 | multiAttributeTile(name: "videoPlayer", type: "videoPlayer", width: 6, height: 4) { 34 | tileAttribute("device.switch", key: "CAMERA_STATUS") { 35 | attributeState("on", label: "Active", icon: "st.camera.dlink-indoor", action: "switch.off", backgroundColor: "#79b821", defaultState: true) 36 | attributeState("off", label: "Inactive", icon: "st.camera.dlink-indoor", action: "switch.on", backgroundColor: "#ffffff") 37 | attributeState("restarting", label: "Connecting", icon: "st.camera.dlink-indoor", backgroundColor: "#53a7c0") 38 | attributeState("unavailable", label: "Unavailable", icon: "st.camera.dlink-indoor", action: "refresh.refresh", backgroundColor: "#F22000") 39 | } 40 | 41 | tileAttribute("device.errorMessage", key: "CAMERA_ERROR_MESSAGE") { 42 | attributeState("errorMessage", label: "", value: "", defaultState: true) 43 | } 44 | 45 | tileAttribute("device.camera", key: "PRIMARY_CONTROL") { 46 | attributeState("on", label: "Active", icon: "st.camera.dlink-indoor", backgroundColor: "#79b821", defaultState: true) 47 | attributeState("off", label: "Inactive", icon: "st.camera.dlink-indoor", backgroundColor: "#ffffff") 48 | attributeState("restarting", label: "Connecting", icon: "st.camera.dlink-indoor", backgroundColor: "#53a7c0") 49 | attributeState("unavailable", label: "Unavailable", icon: "st.camera.dlink-indoor", backgroundColor: "#F22000") 50 | } 51 | 52 | tileAttribute("device.startLive", key: "START_LIVE") { 53 | attributeState("live", action: "start", defaultState: true) 54 | } 55 | 56 | tileAttribute("device.stream", key: "STREAM_URL") { 57 | attributeState("activeURL", defaultState: true) 58 | } 59 | /* 60 | tileAttribute("device.profile", key: "STREAM_QUALITY") { 61 | attributeState("1", label: "720p", action: "setProfileHD", defaultState: true) 62 | attributeState("2", label: "h360p", action: "setProfileSDH", defaultState: true) 63 | attributeState("3", label: "l360p", action: "setProfileSDL", defaultState: true) 64 | } */ 65 | } 66 | 67 | 68 | main("videoPlayer") 69 | details(["videoPlayer"]) 70 | } 71 | } 72 | 73 | mappings { 74 | path("/getInHomeURL") { 75 | action: 76 | [GET: "getInHomeURL"] 77 | } 78 | } 79 | 80 | 81 | def installed() { 82 | configure() 83 | } 84 | 85 | def updated() { 86 | configure() 87 | } 88 | // parse events into attributes 89 | def parse(String description) { 90 | log.debug "Parsing '${description}'" 91 | 92 | } 93 | 94 | // handle commands 95 | def configure() { 96 | log.debug "Executing 'configure'" 97 | sendEvent(name:"switch", value: "on") 98 | } 99 | 100 | def start() { 101 | log.trace "start()" 102 | def dataLiveVideo = [ 103 | OutHomeURL : parent.state.CameraStreamPath, 104 | InHomeURL : parent.state.CameraStreamPath, 105 | ThumbnailURL: "http://cdn.device-icons.smartthings.com/camera/dlink-indoor@2x.png", 106 | cookie : [key: "key", value: "value"] 107 | ] 108 | 109 | def event = [ 110 | name : "stream", 111 | value : groovy.json.JsonOutput.toJson(dataLiveVideo).toString(), 112 | data : groovy.json.JsonOutput.toJson(dataLiveVideo), 113 | descriptionText: "Starting the livestream", 114 | eventType : "VIDEO", 115 | displayed : false, 116 | isStateChange : true 117 | ] 118 | sendEvent(event) 119 | } 120 | 121 | def getInHomeURL() { 122 | [InHomeURL: parent.state.CameraStreamPath] 123 | } -------------------------------------------------------------------------------- /smartapps/pstuart/generic-video-camera-child.src/generic-video-camera-child.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Generic Video Camera Child 3 | * 4 | * Copyright 2016 Patrick Stuart 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: "Generic Video Camera Child", 18 | namespace: "pstuart", 19 | author: "Patrick Stuart", 20 | description: "Child Video Camera SmartApp", 21 | category: "Safety & Security", 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 | page(name: "mainPage", title: "Install Video Camera", install: true, uninstall:true) { 29 | section("Camera Name") { 30 | label(name: "label", title: "Name This Camera", required: true, multiple: false, submitOnChange: true) 31 | } 32 | section("Add a Camera") { 33 | input("CameraStreamPathList","enum", title: "Camera Stream Path", description: "Please enter your camera's streaming path", required:false, submitOnChange: true, 34 | options: [ //add your camera urls here 35 | ["rtsp://user:password@[ipaddress]/Streaming/Channels/1":"Name of Camera"], //hikvision 36 | ["http://[ipaddress]:[port]/mjpeg.cgi?user=user&password=password&channel=1.mjpeg":"Name of Camera"], //dlink 932l 37 | ["http://user:password@[ipaddress]/nphMotionJpeg?Resolution=640x480&Quality=Standard":"Name of Camera"] //panasonic bl-140c 38 | ], displayDuringSetup: true) 39 | 40 | 41 | input("CameraStreamPathCustom","string", title: "Camera Stream Path", description: "Please enter your camera's streaming path", defaultValue: settings?.CameraStreamPathList, required:false, displayDuringSetup: true) 42 | 43 | } 44 | } 45 | 46 | } 47 | 48 | def installed() { 49 | log.debug "Installed" 50 | 51 | initialize() 52 | } 53 | 54 | def updated() { 55 | log.debug "Updated" 56 | 57 | unsubscribe() 58 | initialize() 59 | } 60 | 61 | def initialize() { 62 | log.debug "CameraStreamPathList is $CameraStreamPathList" 63 | log.debug "CameraStreamPathCustom is $CameraStreamPathCustom" 64 | if(CameraStreamPathList) { state.CameraStreamPath = CameraStreamPathList } 65 | if(CameraStreamPathCustom) { state.CameraStreamPath = CameraStreamPathCustom } 66 | try { 67 | def DNI = (Math.abs(new Random().nextInt()) % 99999 + 1).toString() 68 | def cameras = getChildDevices() 69 | if (cameras) { 70 | removeChildDevices(getChildDevices()) 71 | } 72 | def childDevice = addChildDevice("pstuart", "Generic Video Camera", DNI, null, [name: app.label, label: app.label, completedSetup: true]) 73 | } catch (e) { 74 | log.error "Error creating device: ${e}" 75 | } 76 | } 77 | 78 | private removeChildDevices(delete) { 79 | delete.each { 80 | deleteChildDevice(it.deviceNetworkId) 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /smartapps/pstuart/generic-video-camera-connect.src/generic-video-camera-connect.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Generic Video Camera Connect 3 | * 4 | * Copyright 2016 Patrick Stuart 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: "Generic Video Camera Connect", 18 | namespace: "pstuart", 19 | author: "Patrick Stuart", 20 | description: "This smartapp installs the Generic Video Camera Connect App so you can add multiple child video cameras", 21 | category: "Safety & Security", 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 | singleInstance: true) 26 | 27 | 28 | preferences { 29 | page(name: "mainPage", title: "Existing Camera", install: true, uninstall: true) { 30 | if(state?.installed) { 31 | section("Add a New Camera") { 32 | app "Generic Video Camera Child", "pstuart", "Generic Video Camera Child", title: "New Camera", page: "mainPage", multiple: true, install: true 33 | } 34 | } else { 35 | section("Initial Install") { 36 | 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." 37 | } 38 | } 39 | } 40 | } 41 | 42 | def installed() { 43 | log.debug "Installed with settings: ${settings}" 44 | 45 | initialize() 46 | } 47 | 48 | def updated() { 49 | log.debug "Updated with settings: ${settings}" 50 | 51 | unsubscribe() 52 | initialize() 53 | } 54 | 55 | def initialize() { 56 | state.installed = true 57 | } 58 | --------------------------------------------------------------------------------