Logic Machine Forum
Write a code from LM3, to send HTTP commands to a device to control it - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Write a code from LM3, to send HTTP commands to a device to control it (/showthread.php?tid=76)



Write a code from LM3, to send HTTP commands to a device to control it - phongvucba - 17.09.2015

Hi everybody! Please help me...please.!
I tried with it, but all failed...
Sad
I have a line:
http://100.100.100.9/send.htm?remote=samsungtv&command=power
And I need to write a script  used LM3, to send HTTP commands to a device to control it
That is Irtrans. Big Grin
Please help me.  Heart Heart  Thank you very much...All


RE: Write a code from LM3, to send HTTP commands to a device to control it - admin - 18.09.2015

This should do it. You will see the result of this request in "Logs" tab.

Code:
require('socket.http')
url = 'http://100.100.100.9/send.htm?remote=samsungtv&command=power'
res, err = socket.http.request(url)
log(res, err)



RE: Write a code from LM3, to send HTTP commands to a device to control it - phongvucba - 21.09.2015

(18.09.2015, 06:11)admin Wrote: This should do it. You will see the result of this request in "Logs" tab.

Code:
require('socket.http')
url = 'http://100.100.100.9/send.htm?remote=samsungtv&command=power'
res, err = socket.http.request(url)
log(res, err)

Thank admin. But I did try and error:  Sad
* arg: 1
 * nil
* arg: 2
 * string: No route to host


So why do it?..although, I typed in the address bar of Chorme still works
'http://100.100.100.9/send.htm?remote=samsungtv&command=power'
Please help me...Sad thank all  Heart


RE: Write a code from LM3, to send HTTP commands to a device to control it - admin - 21.09.2015

Check network settings in System Config -> Network -> Interfaces -> eth0. You have to set Gateway IP to your router IP, otherwise LogicMachine will only have access to devices in the same local network, but not outside.


RE: Write a code from LM3, to send HTTP commands to a device to control it - phongvucba - 22.09.2015

Blush Heart ! Thank Admin and everyone. 
I 've done . I succeeded!
Thank all!


RE: Write a code from LM3, to send HTTP commands to a device to control it - Hoang189 - 28.09.2015

(22.09.2015, 12:03)phongvucba Wrote: Blush Heart ! Thank Admin and everyone. 
I 've done . I succeeded!
Thank all!





sr. ai đấy nhỉ?


RE: Write a code from LM3, to send HTTP commands to a device to control it - phongvucba - 30.09.2015

(28.09.2015, 09:14)Hoang189 Wrote:
(22.09.2015, 12:03)phongvucba Wrote: Blush Heart ! Thank Admin and everyone. 
I 've done . I succeeded!
Thank all!

Anh Phương mà!



sr. ai đấy nhỉ?