HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started 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 ?
:)
-
http://www.homegenie.it/forum/index.php?topic=983.0 (http://www.homegenie.it/forum/index.php?topic=983.0)
;)
-
Hello,
In a CSharp program like this :
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
-
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
-
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();
-
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 ?
-
@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