more G-Labs products

Author Topic: Virtual Sensor WebGet with Bannana PI.  (Read 1364 times)

March 26, 2016, 12:43:25 AM
Read 1364 times

jcid

  • *
  • Information
  • Newbie
  • Posts: 21
Hello All,

I have a PI that when you hit http://IP/status.php it gives a 1 for open or 0 for closed. I'm looking for a sample script for a virtual sensor that will poll this every 30 seconds and tell me if the door is "open" or "closed" based on the 1 or 0.

Can anyone help?? Been trying code for weeks with no real luck :(

Thanks!!!

March 26, 2016, 05:19:54 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
This should be a really simple script, but I'm not available to knock something up right now.  If you haven't gotten any help by Monday, I can try to put something together.  In the mean time, I highly recommend checking out the code in the submitions thread as you should be able to steal some snippets to cobble what you need together.

March 26, 2016, 07:45:43 PM
Reply #2

jcid

  • *
  • Information
  • Newbie
  • Posts: 21
Hey,

Thanks for the reply!

Yes I've been through the forums like white on rice looking at all the code for days. I found one that was for activating switches that i tried to change to reading sensors essentially but it didn't work or even attempt to. I'm normally a php and bash programmer but it really don't matter what coding you do if you don't know how to integrate it with HG calls. lol.

I have no problem waiting till Monday if you can assist! Once I get that push and see it in action so to speak I think I will be good going forward and be able to replicate it!. There is plenty of code on here for things I'm NOT doing so I think ill be good there. lol.


Cheers!
Jay

March 29, 2016, 12:15:20 AM
Reply #3

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
My stuck modules code does a bit more than what you are looking for, but it should act as a good guide to strip down.  If you want to be notified of the state, you can use either Program.Notify(...) or email notification.  I use email notification in a few of my codes, so you can look at one of them (UPS events is a good one).

This is where the most recent update was posted for my codes:
http://www.homegenie.it/forum/index.php?topic=241.msg2393#msg2393

I don't know if I uploaded my UPS event code, so this is the pertinent part:
Code: [Select]
Net.SendMessage( "[email protected]", "subject", "message");

March 29, 2016, 12:43:10 AM
Reply #4

jcid

  • *
  • Information
  • Newbie
  • Posts: 21
Hey,

Thanks. Don't seem that will work as there is not even a webget call in there like I'm trying to do lol.

Thanks anyway tho.

March 29, 2016, 07:51:03 PM
Reply #5

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Why do you need to do a web API call if you are running the script from HG?  You really only need to do an API call if you are running remotely.  Perhaps I don't understand your goal.