HomeGenie Forum

General Category => Troubleshooting and Support => Topic started by: petediscrete on January 05, 2016, 12:18:25 PM

Title: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: petediscrete on January 05, 2016, 12:18:25 PM
I've finally managed to get my RPI running MotionPie up and running in HG.What I want to do now is have working as a motion sensor/Motion detect in the Alarm System so it will trigger an alarm and send me an email notification with an image attached.

I've assigned the MotionPie RPI to the IpCamera 1 widget. The widget is configured as follows:

Name:...........................Motion Pie Camera
select type:.................. Sensor
Features/Options:.......Generic IP Camera
Camera image API URL (see your camera docs)............ :http://192.168.1.6/picture/1/current
username:....................admin

I saved all this and added the widget to the Dashboard. Everything is working fine and I can now see the image from the MotionPie widget on the Dashboard.

What I need to know now is what else do I need to configure to have the motion detection from the MotionPie RPI send me an email notification with an image attached via HG when the Alarm System is triggered.
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: kevin1 on January 05, 2016, 03:58:55 PM
MotionPi will need to call HG webapi to notify HG of the motion detected.  I have Win7 program called yawcam call this I think:  http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected (http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected)

Testing in browser should give this result: { 'ResponseValue' : 'OK' }

This successfully triggers the HG security alarm and identifies as motion from camera.  The HG security alarm can already send you email/text.  You can tweak it to attach an image from camera and attach it to email from HG:

Code: [Select]
byte[] img = Net.WebService("http://cdn.abclocal.go.com/three/wls/webcam/Loopscape.jpg").GetBytes();
Net.AddAttachment( "", img )
   .SendMessage(  "[email protected]", "", "HG: Motion Detected" );
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: petediscrete on January 05, 2016, 04:37:43 PM
Thanks Kevin.

I'm using HG on one RPI and MotionPie on another. MotionPie is streaming fine to HG so I have that sorted out. You are saying that I have to do the configuring in MotionPie to send a message to HG that there is motion detected and at that point HG triggers the Alarm system and HG sends the alarm notification email. Obviously MotionPie sends a motion detected email along with an image. I was just trying to get HG to do the same.

Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: petediscrete on January 05, 2016, 05:02:51 PM
MotionPi will need to call HG webapi to notify HG of the motion detected.  I have Win7 program called yawcam call this I think:  [url]http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected[/url] ([url]http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected[/url])

Testing in browser should give this result: { 'ResponseValue' : 'OK' }

This successfully triggers the HG security alarm and identifies as motion from camera.  The HG security alarm can already send you email/text.  You can tweak it to attach an image from camera and attach it to email from HG



Code: [Select]
byte[] img = Net.WebService("[url]http://cdn.abclocal.go.com/three/wls/webcam/Loopscape.jpg[/url]").GetBytes();
Net.AddAttachment( "", img )
   .SendMessage(  "[email protected]", "", "HG: Motion Detected" );


Thanks Kevin1.

I got the  { 'ResponseValue' : 'OK' } in the web browser as suggested. Is the rest of your code particular to you or can I use for my purposes
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: kevin1 on January 05, 2016, 05:16:02 PM
Yawcam is a windows application.  I successfully use it with webcam for motion sensor. 

The attachment example I have just been experimenting with.  I am working on something new and have a problem/question posted here: http://www.homegenie.it/forum/index.php?topic=1345.msg8589#msg8589 (http://www.homegenie.it/forum/index.php?topic=1345.msg8589#msg8589)  Once/if I get through that, I may post it as a customizable alternative to the existing HG Security Alarm email notification. 

Otherwise you can do as I have so far, just modify the existing HG Security program so it sends the attachment or other info you want.  I just lose my tweaks every time I update HG and it replaces my security alarm program with the default.
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: petediscrete on January 05, 2016, 06:02:25 PM
Could you post your Alarm System tweaks. I can't get past the { 'ResponseValue' : 'OK' } part of your post.

I wonder if it would be possible to get MotionPie to send HG a message directly when a motion was detected which in turn could activate the HG Alarm System and forward that message to my email. I'm drowning a little here. I thought it be easier to achieve what I was trying to achieve when I started out configuring the IP camera
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: kevin1 on January 05, 2016, 06:36:13 PM
Do you have email configured?  Does security system email you when you trigger alarm by another mechanism?

The example above is basically what I was experimenting with.  If you have the email & security email  working then try this:

-on your ipcamera widget, click the gear, under feature options find and select "use as security sensor", click update
-back to dashboard, arm the alarm system
-in another browser tab go to  http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected (http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected)

That should cause the alarm to trigger and then send you email.
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: petediscrete on January 05, 2016, 06:56:58 PM
Yes I have HG sending me an email notification when my MS13 movement sensor triggers movement. I'll try what you suggest and report back with the results.

Thanks for all your help.
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: petediscrete on January 05, 2016, 08:25:44 PM
Do you have email configured?  Does security system email you when you trigger alarm by another mechanism?

The example above is basically what I was experimenting with.  If you have the email & security email  working then try this:

-on your ipcamera widget, click the gear, under feature options find and select "use as security sensor", click update
-back to dashboard, arm the alarm system
-in another browser tab go to  [url]http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected[/url] ([url]http://192.168.1.100/api/Media.IpCamera/1/Camera.MotionDetected[/url])

That should cause the alarm to trigger and then send you email.


I went to the IpCamera widget under Features/Options selected Security Alarm System, ticked Use as a Security Sensor. I saved the changes but it keeps defaulting back to Generic IP Camera. Any ideas what is happening here.
Title: Re: How do I setup IpCamera 1 to detect motion and trigger the Alarm system
Post by: petediscrete on January 05, 2016, 09:56:04 PM
Tried everything you suggested and a bit more Kevin1. No luck and the system became unstable so I uninstalled it, reinstalled it and restored it from the last known working configuration.Thats the good thing about HG.Again thanks for all your help.

As stated previously, I can get HG to send an alarm notification email to me as a result of an alarm activation from the MS13 movement sensor so I can't understand why I can't set it up using IpCamera as a sensor for alarm activation.