Using HubAction to connect to a URL on the LAN?

I’m having a hard time undertsanding the terminology in ST - it seems strange to me. So I am probably doing something very wrong. I’m trying to turn on a virtual device and have that trigger a GET to a page called ‘moviescene.asp’ on the LAN. Here’s the SmartApp:

definition(
	name: "The Big Switch",
	namespace: "smartthings",
	author: "SmartThings",
	description: "Turns on, off and dim a collection of lights based on the state of a specific switch.",
	category: "Convenience",
	iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png",
	iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png"
)

preferences {
	section("When this switch is turned on, off or dimmed") {
		input "master", "capability.switch", title: "Which device?"
	}
}

def installed()
{   
	subscribe(master, "switch.on", onHandler)
	subscribe(master, "switch.off", offHandler)
	subscribe(master, "level", dimHandler)   
}

def updated()
{
	unsubscribe()
	subscribe(master, "switch.on", onHandler)
	subscribe(master, "switch.off", offHandler)
	subscribe(master, "level", dimHandler)   
}

def logHandler(evt) {
	log.debug evt.value
}

def onHandler(evt) {
	log.debug evt.value
	log.debug onSwitches()
	onSwitches()?.on()
}

def offHandler(evt) {
	log.debug evt.value
	log.debug offSwitches()
	offSwitches()?.off()
}

def dimHandler(evt) {
	log.debug "Dim level: $evt.value"
	dimSwitches?.setLevel(evt.value)
}

private onSwitches() {
	if(switches && onSwitches) { switches + onSwitches }
	else if(switches) { switches }
	else { onSwitches }
}

private offSwitches() {
	if(switches && offSwitches) { switches + offSwitches }
	else if(switches) { switches }
	else { offSwitches }
}

// TODO: do the GET


def hubAction = new physicalgraph.device.HubAction(
        method: "GET",
        path: "/moviescene.asp",
        headers: [HOST:"C0A856C8:22B8"]
    )
    
 log.debug hubAction
    hubAction
    log.debug "This is a test"

The SmartApp has no error messages, and the log file shows it is executing the GET, but the receiving server does not receive the request.

Any help anyone can provide would be much appreciated. Thanks.

I’m going to re-post this question to make it a bit simpler, please ignore. Thanks.

There is a lot of old code hanging around that has bad examples of how to do HubActions like having to use hex represented IP addresses and ports. Here is a more “modern” take using the latest SmartThings documentation. target is the notation “host:port” in normal network order IP form. Callback looks like def nvr_cameraPollCallback( physicalgraph.device.HubResponse hubResponse ) Change the headers (like remove accept) to suit your application.

def hubAction = new physicalgraph.device.HubAction(
    [
        path: "/api/2.0/camera/${state.id}?apiKey=${key}",
        method: "GET",
        HOST: target,
        headers: [
            "Host":"${target}",
            "Accept":"application/json"
        ]        
    ],
    null,
    [
        callback: nvr_cameraPollCallback 
    ]
);

sendHubCommand( hubAction );

Hi, this works well on my applcation, the only part I do not understand is the nvr_cameraPollCallback? I am probably being a bit thick!

What I am trying to do is return the contents of the webpage called in path.

Thanks

Mark