LinuxMCE Forums
May 23, 2013, 02:37:59 am GMT-1 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Rule #1 - Be Patient - Rule #2 - Don't ask when, if you don't contribute - Rule #3 - You have coding skills - LinuxMCE's small brother is available: http://www.agocontrol.com
 
   Home   Help Search Chat Login Register  
Pages: [1] 2
  Print  
Author Topic: Generic IP Device - Configure  (Read 1336 times)
ClaudioLNX
Newbie
*
Posts: 7


View Profile
« on: October 31, 2011, 12:31:47 pm »

Sorry for my question ( i'm newbie) and for my English (i'm italian) ...Smiley ...

I have a simple switch over ethernet that i use for different utilities( light, radio, etc) .... I can switch on or off on browser with command
192.168.1.201/forms.htm?led1=1 ----> turn on
192.168.1.201/forms.htm?led1=0 ----> turn off

how can I create a device that implements this switch? i have to write code or i can use any template?

Thanks a lot
Claudio
Logged
sambuca
Guru
****
Posts: 420


View Profile
« Reply #1 on: October 31, 2011, 12:55:03 pm »

Hi,

You have to write some code. But you can create GSD template, which is simpler than a full c++ template. Search the wiki for GSD to get started.
You should also get an understanding of the device template system before starting.

br,
sambuca
Logged
tschak909
LinuxMCE God
****
Posts: 5101

DOES work for LinuxMCE.


View Profile
« Reply #2 on: October 31, 2011, 01:52:43 pm »

The Panasonic IP camera template is a good example of using GSD to talk over TCP to an HTTP socket.

-Thom
Logged
ClaudioLNX
Newbie
*
Posts: 7


View Profile
« Reply #3 on: November 01, 2011, 12:56:41 pm »

Thanks......i'll try ....

Claudio
Logged
JoakimL
Veteran
***
Posts: 149



View Profile
« Reply #4 on: November 02, 2011, 09:45:22 am »

The wiki is down so i cannot see if there's any more direct HTTP-support in GSD, but take a look at this: http://snippets.dzone.com/posts/show/788
It contains most of what you need to initiate a HTTP POST from Ruby.

/Joakim
Logged
ClaudioLNX
Newbie
*
Posts: 7


View Profile
« Reply #5 on: November 05, 2011, 04:01:51 pm »

thanks.....i have turn on my first light!!!!!  Grin
but i hardcode Embarrassed the path and ip.....infact

.. when i use variable path (device_.devdata_[2]Wink i have the path with ip address.
example
in config: path is only "/forms.htm"
in log if i print variable: path is "192.168.1.201/forms.htm"

i need two  different value: ipaddress and path!
with path i can use a my new data, but with ip? how can i have he value of ip?

thanks again!!!
Logged
JoakimL
Veteran
***
Posts: 149



View Profile
« Reply #6 on: November 05, 2011, 06:11:25 pm »

Just add it to the device template, use the "Device Data" section to add as many as you like.

/Joakim
Logged
ClaudioLNX
Newbie
*
Posts: 7


View Profile
« Reply #7 on: November 06, 2011, 12:04:23 pm »

OK....done... perfect! (the error was because i hadn't restart router)

but if i want know the device data IP in ruby code?
Other data have a number (example #2 for path) .. IP data  no!!! I wish  not replicate IP in other data field.

How i have to do? where i can find the all property of device object?


PS: sorry.....I hope that my behavior is correct, otherwise I apologize

Logged
JoakimL
Veteran
***
Posts: 149



View Profile
« Reply #8 on: November 06, 2011, 06:15:43 pm »

I think your behaviour is not only correct, I think it's exactly as expected. But perhaps this discussion should be in the Developer's forum and not in the Users.

All the device data is stored in the devdata vector. I've looked around, but not found a complete list of the index numbers to use to retrieve the various data. Some I've found:
12 - Child ID
59 - User Code
249 - 3Phase
999 - Serial Number
114 - User name
115 - Password
2 - fix_path

More info http://wiki.linuxmce.org/index.php/Edit_Device_Template

Anyone who knows where there's a complete list of index numbers?


/Joakim
/Joakim
Logged
posde
Administrator
LinuxMCE God
*****
Posts: 2621


Wastes Life On LinuxMCE Since 2007


View Profile WWW
« Reply #9 on: November 06, 2011, 06:18:55 pm »

Joakim,

usually, when I am faced with DeviceData information, I look at mysql pluto_main.DeviceData, but the information in there looks different that one you've laid out
Logged

tschak909
LinuxMCE God
****
Posts: 5101

DOES work for LinuxMCE.


View Profile
« Reply #10 on: November 06, 2011, 10:55:37 pm »

as Possy says, the best way is to look at the data in the database. The Web admin's Advanced->DCE->Device Data page can help here, giving you the device data name, its number, its parameters, and what device templates use this command.

-Thom
Logged
ladekribs
Veteran
***
Posts: 82


View Profile
« Reply #11 on: November 09, 2011, 06:49:34 pm »

Hi ,

I am a bit confused over how to compile the http request, I am comparing with the Panasonic IP Camera but I am not sure of how the 192.168.1.201/forms.htm?led1=1
would fit in.

please advice me.


thanks Stefan
Logged
ClaudioLNX
Newbie
*
Posts: 7


View Profile
« Reply #12 on: November 10, 2011, 03:59:49 pm »

I'm very happy... if i can help u....
but now I do not have access to the code. Tonight I'll copy the code here and I'll explain how to do

Claudio
Logged
ClaudioLNX
Newbie
*
Posts: 7


View Profile
« Reply #13 on: November 10, 2011, 08:56:50 pm »

ok...... look my code......if you have other problem...say me .. i
But because Joakim said: "perhaps this discussion should be in the Developer's forum and not in the Users." ....  Grin ....perhaps we have to open a new topic in Developers!!

Code:
require'net/http'
fix_path=device_.devdata_[2];
fix_path='/'+fix_path if(fix_path[0]!='/'[0]);
h=Net::HTTP.new('192.168.1.201',80)
resp,data=h.get(fix_path+absolute_channel.to_s,nil)
absolute_channel is an input parameter.
fix_path is a device_data "path"

Claudio

PS:last problem (for me) is a IP: i have hardcode the ip ....
« Last Edit: November 11, 2011, 07:19:03 am by ClaudioLNX » Logged
ladekribs
Veteran
***
Posts: 82


View Profile
« Reply #14 on: November 10, 2011, 09:39:55 pm »

Thank you Claudio i will see if I understand.

Best Regards Stefan
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!