Recent Posts

Pages: 1 ... 7 8 [9] 10
81
Developers / Re: Device Template using SOAP
« Last post by bherbie on September 05, 2014, 02:50:20 am »
Quote
Have you seen this thread on Sony SOAP commands?  Might be helpful...

http://www.remotecentral.com/cgi-bin/mboard/rs232-ip/thread.cgi?171,3

Yes, I have seen this and my code is based on a hybrid of that and yours.  It works flawlessly from the command line using php cURL but I must be doing something incorrect when translating it to ruby.  The logfile shows the command being sent and it looks correct but the response looks like this:

Code: [Select]
04-09-2014  18:43:44  HTTP/1.1 400 Bad Request
Connection: close
Date: Fri, 05 Sep 2014 00:43:44 GMT
Server: Linux/2.6
04-09-2014  18:43:44  UPnP/1.0 Sony-BDP/2.0

-herb
82
Installation issues / [SOLVED] 12.04 Aeon Z-stick (Zwave) is not detected by PnP
« Last post by davegravy on September 05, 2014, 02:31:39 am »
Anyone experienced this?

I've tried unplugging and replugging the usb dongle.

dmesg sees it:

Code: [Select]
[ 1668.440102] usb 1-1.4.1: new full-speed USB device number 25 using ehci_hcd
[ 1668.552648] cp210x 1-1.4.1:1.0: cp210x converter detected
[ 1668.644276] usb 1-1.4.1: reset full-speed USB device number 25 using ehci_hcd
[ 1668.753372] usb 1-1.4.1: cp210x converter now attached to ttyUSB0

And it works fine on my 10.04 install.

I created a ticket here:http://svn.linuxmce.org/trac/ticket/2207
83
Developers / Re: Device Template using SOAP
« Last post by mkbrown69 on September 04, 2014, 11:47:15 pm »
Hi bherbie!

Have you seen this thread on Sony SOAP commands?  Might be helpful...

http://www.remotecentral.com/cgi-bin/mboard/rs232-ip/thread.cgi?171,3

Cheers!

/Mike
84
Developers / Re: Device Template using SOAP
« Last post by bherbie on September 04, 2014, 03:39:21 pm »
Thanks Mike!

This is exactly what I was looking for - I read your post about it when you were developing it but didn't see a device template for it.  I tried out your code and I am getting back a `bad request` error which in my experience has been a malformed SOAP request so I am still working with it to see if I can iron out the issues but I am by no means a ruby expert.

Again, thanks for the nudge in the right direction!
-herb
85
Developers / Re: Device Template using SOAP
« Last post by mkbrown69 on September 04, 2014, 04:26:52 am »
Hi bherbie!

I'm the author of the ISY994i template (device #2276) which has some SOAP calls.  I only play at being a programmer (more of a SysAdmin/integrator type) so take anything I write with a grain of salt...

My device driver uses GSD.  I have a function to "subscribe" to an events channel, to receive a stream of status events from the ISY controller.  As part of the function, it does a base64 encoding of the Username and password as part of the call (parameters 114 & 115). It looks like this...

Code: [Select]
def subscribeToISY()
# Prepare to send a subscription SOAP request to the device.
# Subscription is a one-way stream of events from the ISY to
# LMCE using the LMCE GSD conn_ method.
$port = device_.devdata_[69].to_s
auth_s=Base64.encode64(device_.devdata_[114]+":"+device_.devdata_[115])
soapBody ='<s:Envelope><s:Body><u:Subscribe xmlns:u="urn:udi-com:service:X_Insteon_Lighting_Service:1"><reportURL>REUSE_SOCKET</reportURL><duration>infinite</duration></u:Subscribe></s:Body></s:Envelope>'
s = "POST /services HTTP/1.1 \x0D\x0A"
s+= "Host: "+$host+":"+$port+" \x0D\x0A"
s+= "Content-Length: "+soapBody.length.to_s+" \x0D\x0A"
s+= "Content-Type: text/xml; charset=\"utf-8\" \x0D\x0A"
s+= "Authorization: Basic "+auth_s+" \x0D\x0A"
s+= "NT:upnp:event \x0D\x0A"
s+= "SOAPACTION:\"urn:udi-com:service:X_Insteon_Lighting_Service:1#Subscribe\" \x0D\x0A\x0D\x0A"
s+= soapBody.to_s
log("Attempting to Subscribe to ISY Events")
debuglog(s.to_s)
# Attempt to subscribe and retrieve data from the ISY
subscribe = conn_.Send(s.to_s)
log(subscribe)
end

I send commands back to the ISY asynchronously using it's REST interface, like so:
Code: [Select]
def sendISYcommand(command)
# This function sends commands to the ISY using it's REST interface.
# Does not use the subscription channel conn_ method.
# Commands are sent asynchronously, and success/fail is returned using
# this function.  Device feedback is received via the subscription.
#
# $username=device_.devdata_[114].to_s
# $password=device_.devdata_[115].to_s
$port = device_.devdata_[69].to_s
res = Net::HTTP.start($host) {|http|
req = Net::HTTP::Get.new(command)
req.basic_auth device_.devdata_[114].to_s, device_.devdata_[115].to_s
response = http.request(req)
xml_data = (response.body)
debuglog($yellow + "====== / sendISYcommand response body ======" + $grey)
debuglog(xml_data)
debuglog($yellow + "====== sendISYcommand response body / ======" + $grey)
doc = REXML::Document.new(xml_data)
s = ""
s = REXML::XPath.first(doc, "RestResponse/status")
if s != nil then
if s.text != "200" then
# Didn't get the HTTP OK :-(  return error code
return s.text
end
end
p = ""
p = REXML::XPath.first(doc, "properties/property")
if p != nil then
return p.text
end
return doc.to_s
}
end

Feel free to peruse the code in the template if this looks like something useful for you.  The interesting stuff is in "355 Process Initialize" and "373 Private Method Listing".

The Basic flow of the device start-up is:

355 Process Initialize (all the set-up stuff, calls functions in 373 Private Method Listing).
350 Process Incoming Data (basically, loops processing data coming in from the subscription channel).  Calls functions in 373 Private Method Listing.

Events from LMCE heading outbound to the ISY are serviced by 384 Process Receive for Child, which parses the LMCE commands, formulates the appropriate REST URL , and then calls my function sendISYcommand(command), where command is the URI encoded REST URL.  That code looks like this:

Code: [Select]
cmdId           = cmd.id_                                   # Command ID: ON, OFF, SET LEVEL
cmdTo           = cmd.devidto_                              # Device ID in LinuxMCE
devPort         = device_.childdevices_[cmdTo].devdata_[12] # 12 contains a port/channel
childType       = device_.childdevices_[cmdTo].devtemplid_  # Template ID to know type of device: switch or dimmer


case cmdId
      when 192 #192 is ON                     
           command = "/rest/nodes/#{URI.encode(devPort)}/cmd/DON"
      when 193 #193 is OFF                       
           command = "/rest/nodes/#{URI.encode(devPort)}/cmd/DOF"
      when 184 #184 is Level of dimmer
      dim_level = percenttodecihex(cmd.params_[76])
log("------dce--- Dim Level:" + dim_level.to_s)
           command = "/rest/nodes/#{URI.encode(devPort)}/cmd/DON/#{dim_level}"
else

end
log(command)
response = ""
response = sendISYcommand(command)
log(response)

You can find the commands you'll be interested in via the LMCE web GUI, under Advanced -> DCE -> Commands.  Look for the media commands.  Hopefully this provides some food for thought...

Good luck with your device driver!

/Mike
87
Developers / [SOLVED] Device Template using SOAP
« Last post by bherbie on September 03, 2014, 08:17:40 pm »
Recently I had to retire my OPPO Blu Ray Player with its RS232 interface and went looking for something new.  Of all the Blu Ray choices out there, I settled on a Sony for its cost and features - one of which is its ability to accept network commands via SOAP.  I have been able to send commands to my Sony using command line and have fleshed out exactly what it can and cannot do and now I wish to create a device template to integrate this into my LMCE system and I have a few questions...

First of all, I have looked in the GSD source code and cannot quite figure out if it is possible to send headers to use SOAP in Ruby.  In my testing (using cURL) there is a header that needs sent in order for this to work - if it is not present, the player disregards the message and returns a 404.  So my question is - can I send a header to make this work and if so - how?

I have seen other posts about using SOAP in a device template but I do not see where it has been successful and I do not see any templates that currently use SOAP...

thanks in advance,
-herb
88
Marketplace / Re: Dianemo S from CHT - Ubuntu 12.04LTS Release Now Shipping World Wide!
« Last post by posde on September 03, 2014, 06:55:20 pm »
Good luck with it.
89
Developers / Open Source Dianemo
« Last post by totallymaxed on September 03, 2014, 03:34:36 pm »
We've launched a Kickstarter Campaign today to fund the development of Open Source Dianemo;

http://forum.linuxmce.org/index.php?topic=8880.msg100040#msg100040
Pages: 1 ... 7 8 [9] 10