No Joy From My First SmartApp


(Convinced ST will never be unbroken…) #1

Hey all,

Seems pretty simple, but when I install it, and then tap “Configure SmartApp”, the SmartThings app immediately crashes (Nexus 7 / Android 4.4.2). Any ideas what I may have done wrong:

definition(
    name: "Server Command Button",
    namespace: "smrtthings",
    author: "Scottin Pollock",
    description: "Send a server command when app is touched or activated",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png"
)


preferences {
	section("When I touch the app, Send to server...") {
		input "server", "string", title: "Server IP", description: "Your HTTP Server IP", required: true
		input "command", "string", title: "Parameters", description: "Command to Send", required: true
	}
}

def installed()
{
	subscribe(app, appTouch)
}

def updated()
{
	unsubscribe()
	subscribe(app, appTouch)
}


def appTouch(evt) {
	log.debug "appTouch: $evt"
	sendHttp()
}

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}"))
}

Problem with Crashing
(Ben Edwards) #2

@Dianoga, @bflorian, @rappleg, @juano2310, @imbrian, @megapixel, @wackware any of you guys have some advice for a first time SmartApp author, here?


(Brian Steere) #3

Unfortunately, I haven’t done anything with hub commands. Sorry.


(Ronny Carr) #4

Looks like you need to make deviceNetworkId equal the IP address of the device, and i think HOST needs to be the Hub IP.


(Andrew Urman) #5

try changing the input type from string to text


(Convinced ST will never be unbroken…) #6

Andrew…

Thank you for this! I would have never discovered this on my own.


(Andrew Urman) #7

@scottinpollock I’m just more surprised I was right :horse: