HomeGenie Forum
General Category => Troubleshooting and Support => Topic started by: jcid on March 26, 2016, 12:43:25 AM
-
Hello All,
I have a PI that when you hit http://IP/status.php (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!!!
-
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.
-
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
-
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 (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:
Net.SendMessage( "[email protected]", "subject", "message");
-
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.
-
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.