more G-Labs products

Author Topic: Noob questions - Virtual Sensor inside Alarm System  (Read 2653 times)

September 26, 2014, 08:06:36 PM
Read 2653 times

joaoasilva

  • *
  • Information
  • Newbie
  • Posts: 6
Hi all,

I'm trying to figure out how HG works and I already have some things working but were all modules already inside HG.
Now I'm using a raspberry pi and webcam with motion saving jpg's and with lighthttp opening the images from Ip Camera module and works perfectly. Motion have the ability to send commands if detects movement and I would like to build a python script to send an API call to HG saying that movement was detected and insert that into the Security Alarm System module. Is there a way to create a Virtual Sensor that I could say that is inside Security Alarm System module and I could just call http://HGIP/api/Camera/1/Control.On to trigger the sensor and the Alarm System?

Thanks in advance.

Best regards,
Joao Silva

September 26, 2014, 09:33:33 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
If you're using the generic IP camera widget then you can raise the motiondetect event on that camera with this api call:

http://<homegenie_address>/api/Media.IpCamera/<cam_number>/Camera.MotionDetected

You can then flag the camera as a Security Sensor from the module options, so it will trigger the Security Alarm System module.

Cheers,
g.

September 26, 2014, 09:44:11 PM
Reply #2

joaoasilva

  • *
  • Information
  • Newbie
  • Posts: 6
Sorry, didn't notice the event Camera.MotionDetected :/
Can you tell me if I can graphically add more events? I noticed that we can delete them, but can we add them?
I don't have the flag to use it as Security Sensor, am I missing something? Please see attached.

Thanks!

September 26, 2014, 11:59:21 PM
Reply #3

joaoasilva

  • *
  • Information
  • Newbie
  • Posts: 6
No worries, a factory reset fixed everything :)

Thanks for all!

September 27, 2014, 12:39:33 AM
Reply #4

joaoasilva

  • *
  • Information
  • Newbie
  • Posts: 6
Ok, now I have the flag to select as Security Sensor but when I call /api/Media.IpCamera/1/Camera.MotionDetected/ I see the alert on the web interface but nothing happens, on the log it just changes the value of MotionDetect from 255 and then immediately to 0...

Please advise.

Thanks

September 27, 2014, 01:12:57 AM
Reply #5

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer

September 27, 2014, 01:27:11 AM
Reply #6

joaoasilva

  • *
  • Information
  • Newbie
  • Posts: 6
Yes, it helped... that was the tutorial I followed...
The problem is that the system gets armed, I defined an email to send the alert but none is sent.
I've already tested a script with Net.SendMessage("[email protected]", "Test message", "Hello World!"); and it works perfectly...

Thanks!

September 27, 2014, 01:42:53 AM
Reply #7

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
So, if you can make a program that actually sends the email, you can also tell the security alarm system to launch that program when alarmed.
See security program configuration options.

g.

September 27, 2014, 01:48:14 AM
Reply #8

joaoasilva

  • *
  • Information
  • Newbie
  • Posts: 6
I've inserted the email in the text box labeled "Comma separated list of recipients e-mails for alarm notifications" but when I trigger the alarm, it doesn't send...
I just made a test program to check if it was a bad configuration on the email program like smtp and ssl, etc or the alarm system. Seems to be the alarm system because the test program worked fine.

I noticed that the code is wrapped inside Program.RunAsyncTask, is there anything I need to do to run AsyncTasks? or it should just work?

Edit: Just tested and without the async task it works... the system hangs for some seconds though... :(
« Last Edit: September 27, 2014, 02:00:47 AM by joaoasilva »

May 21, 2015, 06:07:41 PM
Reply #9

Bitcraze

  • ***
  • Information
  • Full Member
  • Posts: 73
Hi, all

In ALARM: "Program to run when disarmed"


What can I enter there, to use?

I have been trying to send an e-mail, by using:

Net.SendMessage("[email protected]", "Test message", "Hello World!");

No luck!

May 21, 2015, 11:31:00 PM
Reply #10

dani

  • *****
  • Information
  • Global Moderator
  • Posts: 535
I think you have to put the number or the name of the program to run.

May 22, 2015, 05:29:39 PM
Reply #11

kevin1

  • *****
  • Information
  • Hero Member
  • Posts: 330
If you're using the generic IP camera widget then you can raise the motiondetect event on that camera with this api call:

How does HG know that motion was detected?  Is it running a motion detection algorithm, if so are there settings for sensitivity?  Thanks, HG is so fun to learn/use  :-)