Thanks Andrew,
There are indeed examples for the devices you mention, but I am not much of a java head so they weren’t all that help (mostly overkill I imagine).
But now that I have a modicum of experience (and have had the hardware for a couple of days), I’d like to revisit this. With an example from @bmayer01 I have half of it working very well (sending http requests to a local server)…
def sendHttp() {
def ip = "${settings.server}:8080"
def deviceNetworkId = "100012"
sendHubCommand(new physicalgraph.device.HubAction("""GET /?${settings.command} HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))
}
So now all that’s left is being able to send commands from the server to the hub. I don’t even know if I need a device-type for that either. I discovered I could use the Endpoint Access Authorization to directly control switches and locks connected to the hub, but that is a far cry from being able to simply send a command locally to the hub, and parse its params within a single handler to decide what to do. This is what I am after. I don’t know if I can do anything more with endpoints as it seems any link I have been able to dig up regarding a tutorial leads to a 404, but it was here once upon a time.
The pieces and bits I have looked at regarding a device-type seem to invoke some kind of discovery process using upnp. If I was going to have to discover my server I’d need multicast (which the current docs say is not implemented yet). But I know the IP address of my server so I wouldn’t think any discovery is necessary.
Another thing I take away from the Lan device-type section is that local communication to the hub seems to only be supported in the way of a response to a hub originated command via registering for a callback. I have no need for this. I simply need to send a dumb event with a param or two to the hub from a Mac.
I wanted to touch on one more thing while you are being kind enough to shine a light on some of this… and that is the code snippet above:
Is sendHubCommand capable of sending a simple string via tcp to a similar local host? For example:
sendir,1:3,1,36000,3,1,128,63,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,48,16,48,16,48,16,48,16,48,16,16,16,16,16,48,16,48,16,48,16,48,16,48,16,48,16,16,16,48,16,2712\r
The above is an example of a CG iTach IR command/code. Currently I am sending these codes from my server using python with something like this:
import socket
HOST2 = '10.0.0.41'
PORT2 = 4998
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST2, PORT2))
s.sendall("sendir,1:3,1,39000,3,1,95,23,48,23,48,23,48,23,48,23,23,23,48,23,23,23,23,23,48,23,23,23,48,23,48,23,23,23,48,23,23,23,23,23,23,23,48,23,48,23,48,512\r")
response = s.recv(24)
print "Response from send(SonyBR Off):", response
Note that the response is not necessary; it was just left in from when I started putting this stuff together.
So this is all that I am struggling with… everything else has gone “reasonably” well since I learned you don’t use “string” to define input types. (c;
Thanks for looking it over,
Scott in Pollock