Note: I have no idea how to integrate feed from the cameras, but made virtual devices that are turned on whenever a camera detects motion.
This in turn can for example be used for light-control "turn on light in livingroom when motion detected in stairs" as a control when you're on vacation for example.
To do this, you need to install swatch and cURL on the NVR, monitoring the motion-log and triggers a cURL whenever detected. sending JSON to homeseer.
First off (after installing curl and swatch / swatchdog): create a service /etc/init.d/swatchd that you can run at boot; containing the following code:
then create a configfile in /etc/swatch that checks the log file for names/aliases of the cameras, then executes a command called "motion" if triggered
example of /etc/swatch/motion.conf:
finally make the excecutable /etc/swatch/motion that sends JSON commands to homeseer based on above triggers.
(remember to "chmod +x /etc/swatch/motion" to make it excecutable)
In homeseer, this sets the virutal device matching your referenceID to value 100 (ON), whenever a motion is detected.
I finally have an event that states for example: "if virtual device "motion_in_garden" changes an becomes ON, wait 1 minute then turn it off"
Personally I combine this with pushover, so whenever there is motion in the house when I'm gone, I get a push alert on my phone, allerting me "Motion in livingroom". then I can simply use the UniFi app to check the camera recording (and see that it's the just darn cat again :-)
extra: How to track phones in a building with UniFi Access Points
(linking as it is UniFi related, and contains same type of approach)
This in turn can for example be used for light-control "turn on light in livingroom when motion detected in stairs" as a control when you're on vacation for example.
To do this, you need to install swatch and cURL on the NVR, monitoring the motion-log and triggers a cURL whenever detected. sending JSON to homeseer.
First off (after installing curl and swatch / swatchdog): create a service /etc/init.d/swatchd that you can run at boot; containing the following code:
Code:
start() { /usr/bin/swatchdog [COLOR=#FF0000]--config-file=/etc/swatch/motion.conf[/COLOR] --tail-file=/var/log/unifi-video/motion.log --pid-file=/var/run/swatch/swatch-motion.pid --daemon > /dev/null >&1 } stop() { [COLOR=#FF00FF]PID[/COLOR]=`cat /var/run/swatch/swatch-motion.pid` kill [COLOR=#FF00FF]$PID[/COLOR] } case [COLOR=#FF00FF]$1[/COLOR] in start) start exit 0 ;; stop) stop exit 0 ;; restart) stop start exit 0 ;; *) echo "Usage: [COLOR=#FF00FF]$0[/COLOR] { start | stop | restart }" exit 1 ;; esac
example of /etc/swatch/motion.conf:
Code:
[COLOR=#339966]#Note: [/COLOR][COLOR=#FF0000]nameofCameraHere[/COLOR][COLOR=#339966] must match your camera alias in unifi NVR![/COLOR] perlcode my [COLOR=#FF00FF]$timer [/COLOR]= '[COLOR=#FF0000]240[COLOR=#000000]'; wa[/COLOR][/COLOR]tchfor /[COLOR=#FF0000]nameofCameraHere[/COLOR]/ exec [COLOR=#FF0000]/etc/swatch/motion <cameraname>[/COLOR] threshold type=limit, seconds=[COLOR=#FF00FF]$timer[/COLOR] watchfor /[COLOR=#FF0000]Cinema[/COLOR]/ exec /etc/swatch/[COLOR=#FF0000]motion cinema[/COLOR] threshold type=limit, seconds=[COLOR=#FF00FF]$timer[/COLOR] watchfor /[COLOR=#FF0000]Tesla[/COLOR]/ exec /etc/swatch/[COLOR=#FF0000]motion garage[/COLOR] threshold type=limit, seconds=[COLOR=#FF00FF]$timer[/COLOR] watchfor /[COLOR=#FF0000]Twizy[/COLOR]/ exec /etc/swatch/[COLOR=#FF0000]motion garage[/COLOR] threshold type=limit, seconds=[COLOR=#FF00FF]$timer[/COLOR] watchfor /[COLOR=#FF0000]Driveway[/COLOR]/ exec /etc/swatch/[COLOR=#FF0000]motion driveway[/COLOR] threshold type=limit, seconds=[COLOR=#FF00FF]$timer[/COLOR] watchfor /[COLOR=#FF0000]Garden[/COLOR]/ exec /etc/swatch/[COLOR=#FF0000]motion garden[/COLOR] threshold type=limit, seconds=[COLOR=#FF00FF]$timer[/COLOR] watchfor /[COLOR=#FF0000]Stairs[/COLOR]/ exec /etc/swatch/[COLOR=#FF0000]motion stairs[/COLOR] threshold type=limit, seconds=[COLOR=#FF00FF]$timer[/COLOR] [COLOR=#339966]#...etc etc..[/COLOR]
(remember to "chmod +x /etc/swatch/motion" to make it excecutable)
Code:
[COLOR=#339966]#!/bin/bash[/COLOR] [COLOR=#339966]#useage: /etc/swatch/motion <cameraname>[/COLOR] [COLOR=#339966]#ref=[/COLOR][COLOR=#FF0000]xxx[/COLOR][COLOR=#339966] replace with the ID of your virtual trigger in homeseer[/COLOR] case "[COLOR=#FF00FF]$1[/COLOR]" in "[COLOR=#FF0000]cinema[/COLOR]") [COLOR=#FF00FF]ref[/COLOR]="[COLOR=#ff0000]111[/COLOR]" ;; "[COLOR=#FF0000]garden[/COLOR]") [COLOR=#FF00FF]ref[/COLOR]="[COLOR=#ff0000]222[/COLOR]" ;; "[COLOR=#FF0000]driveway[/COLOR]") [COLOR=#FF00FF]ref[/COLOR]="[COLOR=#FF0000]333[/COLOR]" ;; "[COLOR=#FF0000]stairs[/COLOR]") [COLOR=#FF00FF]ref[/COLOR]="[COLOR=#FF0000]444[/COLOR]" ;; "[COLOR=#FF0000]garage[/COLOR]") [COLOR=#FF00FF]ref[/COLOR]="[COLOR=#FF0000]555[/COLOR]" ;; esac curl "http://[COLOR=#FF0000]YourHomeseerIPAddress[/COLOR]/JSON?request=controldevicebyvalue&ref=[COLOR=#FF00FF]$ref[/COLOR]&value=100"
I finally have an event that states for example: "if virtual device "motion_in_garden" changes an becomes ON, wait 1 minute then turn it off"
Personally I combine this with pushover, so whenever there is motion in the house when I'm gone, I get a push alert on my phone, allerting me "Motion in livingroom". then I can simply use the UniFi app to check the camera recording (and see that it's the just darn cat again :-)
extra: How to track phones in a building with UniFi Access Points
(linking as it is UniFi related, and contains same type of approach)
Comment