more G-Labs products

Author Topic: Call URL with parameters from home genie ?  (Read 1954 times)

July 25, 2015, 05:54:12 AM
Read 1954 times

trunkx

  • *
  • Information
  • Newbie
  • Posts: 4
Hello,

I have a Arduino where i can control a 8 channel relay via url calls.

the link to activate the relays looks like this: http://192.168.0.23:8081/?relay1on
How can i send a url call like this from hg ?

Any ideas ?
 :)

July 25, 2015, 09:32:44 AM
Reply #1

KaZe

  • ****
  • Information
  • Sr. Member
  • Posts: 219

July 25, 2015, 09:37:22 AM
Reply #2

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
Hello,
In a CSharp program like this :
Code: [Select]
Net.WebService("http://192.168.0.23:8081/?relay1on").Call();You want to activate in which case ? Perhaps, you can add a program with a "virtual switch" ...
Bye

July 25, 2015, 01:57:14 PM
Reply #3

trunkx

  • *
  • Information
  • Newbie
  • Posts: 4
thx for the help buddys.
I tried to add a CSharp Script to my new added group relays in hg.

I did paste your code there.  It saves correctly but i get a RunTime.Error = TC: hg is not defined, when i try to execute.
But i think its not a problem of this code. I have got this error with every Code i tried.

I want to Switch the Relay1 via time so i have added a  time event in the scheudler with names: lamp 1 ON, lamp 1 OFF

how can i set lamp 1 ON to the script ?

thank you


July 25, 2015, 05:57:10 PM
Reply #4

enterprised

  • ****
  • Information
  • Sr. Member
  • Posts: 101
  • Things are only impossible until they are not
Use this:

Net.WebService("192.168.0.23:8081/?relay1on").GetData();

If you create virtual switches to control the relays as per my other post (http://www.homegenie.it/forum/index.php?topic=983.0) then you can use the HG scheduler for timing events.

Or on the most basic code, a simple program just addressing a single relay, no switch in GUI, all running in the background:

if (Scheduler.IsScheduling("15 19 * * *") //19:15 lights on
  {
    Net.WebService("192.168.0.23:8081/?relay1on").GetData();
  }

if (Scheduler.IsScheduling("45 23 * * *") //23:45 lights off
  {
    Net.WebService("192.168.0.23:8081/?relay1off").GetData();
  }
Pause(30);
Program.GoBackground();

« Last Edit: July 25, 2015, 07:51:12 PM by enterprised »
4a 75 73 74 20 61 20 70 65 72 73 6f 6e 20 68 61 76 69 6e 67 20 66 75 6e 20 77 69 74 68 20 68 6f 6d 65 20 61 75 74 6f 6d 61 74 69 6f 6e
enterprised == guytpetj

July 26, 2015, 04:14:23 AM
Reply #5

trunkx

  • *
  • Information
  • Newbie
  • Posts: 4
thank you guys for the nice help  ;)

i have tried your code but didn't get it to work.
@ enterprised:
 I think you have forgot the second  ).
if (Scheduler.IsScheduling("15 19 * * *")
if (Scheduler.IsScheduling("45 23 * * *")
after correcting that i was able to compile the code.

The Relay Switch on my Arduino works well when i enter 192.168.0.23:8081/?relay1on in my browser.

i have tried  with:
Net.WebService("192.168.0.23:8081/?relay1on").GetData();

and then with the if block including. nothing happens...

my raspi is on the same subnet and pingable.

one more question:
when i press the yellow/green/red button infront of a programm in hg, will the code get executed or not ?


 

July 29, 2015, 01:35:13 AM
Reply #6

trunkx

  • *
  • Information
  • Newbie
  • Posts: 4
@enterprised
omg...im sorry...i have found the hgx file from your zip file.
I didn't looked into it because my arduino was set up correctly allready and i thougt there is only a .ino file in it.

Problem solved, love u =)

Thx for help buddys