HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: trunkx on July 25, 2015, 05:54:12 AM

Title: Call URL with parameters from home genie ?
Post by: trunkx on July 25, 2015, 05:54:12 AM
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 (http://192.168.0.23:8081/?relay1on)
How can i send a url call like this from hg ?

Any ideas ?
 :)
Title: Re: Call URL with parameters from home genie ?
Post by: KaZe on July 25, 2015, 09:32:44 AM
http://www.homegenie.it/forum/index.php?topic=983.0 (http://www.homegenie.it/forum/index.php?topic=983.0)
 ;)
Title: Re: Call URL with parameters from home genie ?
Post by: nolio on July 25, 2015, 09:37:22 AM
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
Title: Re: Call URL with parameters from home genie ?
Post by: trunkx on July 25, 2015, 01:57:14 PM
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

Title: Re: Call URL with parameters from home genie ?
Post by: enterprised on July 25, 2015, 05:57:10 PM
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 (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();

Title: Re: Call URL with parameters from home genie ?
Post by: trunkx on July 26, 2015, 04:14:23 AM
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 ?


 
Title: Re: Call URL with parameters from home genie ?
Post by: trunkx on July 29, 2015, 01:35:13 AM
@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