Virtual Button to send out http to Eventghost

Can anyone share this code?

What exactly are you looking to send? (get, post, put, etc.)

Hi Scott thank you for getting back to me. Sorry Iā€™m still trying to understand the commands not sure if it is get or post. I want to be able to send an http packet from Smarthings to Eventghost. I have a macro I want to trigger with a packet in eventghost. I donā€™t know how to put the code together like you did with ham bridge where you can input the ip address and port from within the app. Ultimately, I would like to make several virtual buttons sending out different packets like (on) or (off) etc etc. I donā€™t necessary need feedback from Eventghost that would be a bonus.

Packet is not the right word here. When making a GET call over HTTP, the data is sent in one or more ā€˜parametersā€™ passed in the url. The following will send an http get from a SmartApp:

def HTTP(theCOM) {
	def ip = "serversIP:serversPort"
	sendHubCommand(new physicalgraph.device.HubAction("""GET /?$theCOM HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN))
}

Where ā€˜theCOMā€™ is the parameter you want to send (ā€˜onā€™, ā€˜offā€™, whatever).

I have no experience with eventGhost, but am assuming it is running on a computer that resides on your LAN.

Perfect thatā€™s exactly what I needed I knew you had the answer! :smile:
I added my ip address and port. What else do I need to modify on the code to get to get to work?
Thank you for all your help. Iā€™m very new to all this.

Here is a scaled down version of a SmartApp I use to send server commands from some non-load controlling switches I have installed. Just point it to your virtual switch and enter your server info.

1 Like

It worked! How do I get the virtual button to show up in ios? It worked on the website.

All working. Thanks again Scott.

@scottinpollock The link is dead but I found your smart things code on the HAM Bridge examples (http://solutionsetcetera.com/stuff/STApps/HAMBridgeCommandWhen.groovy)

Iā€™m using it to try and run scenes on a vera on the LAN. Via OS X cli (quotes required) I can use curl http://10.0.1.153:3480/ā€œdata_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=44ā€

Via My sensor Tags tag manager private URL calling I can use http://10.0.1.153:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=44

So in the prefs for the app I set the IP and port and then for the command to send Iā€™ve tried different iterations of ā€œdata_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=44ā€

Simulator logs show:
8:30:07 PM PST: debug Executing GET /?ā€œdata_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=44ā€ HTTP/1.1
HOST: 10.0.1.153:3480

on Home via sendHubCommand

Unfortunately the scene is not running and Iā€™m sure Iā€™m missing something obvious in my syntax. Do you have any suggestions on what Iā€™m doing wrong?