httpGet for local IP

Hi All,
Very new to groovy here. I know this topic has been covered before but trying the solutions I’ve found just don’t seem to be working for me. I’m trying to port an app I have working on Hubitat but getting stuck.

I recognize that an httpGet command is sent from the cloud so it won’t work with local IP addresses and instead sendHubCommand should be used. My issue is that I’m continually getting a groovy.lang.MissingMethodException: No signature of method error.

Here is the Hubitat code I’m using:

def getClientsJSON() {
    def jsonDevices = [:]
    def paramsg = [
		uri: "http://${settings.embyServerIP}:${settings.embyServerPort}/emby/Devices?&api_key=${settings.embyApiKey}",
        contentType: 'application/json',
	httpGet(paramsg) { resp ->
        log.debug "Parsing Emby Devices"
        def devices =
    devices.each { thing ->  

I’ve tried using:

def paramsg = new physicalgraph.device.HubAction(
	method: "GET",
	path: "/emby/Devices?&api_key=${settings.embyApiKey}",
	headers: [
    	HOST: "${settings.embyServerIP}:${settings.embyServerPort}"
	log.debug paramsg

But getting the error above. Any help for a complete newbie would be greatly appreciated!

I successfully do a local HTTP GET in the below device driver:

Look at the method sendGetCmd.

You have to check if the IP and port values your settings return are encoded properly.

Go to your device and see if you have

settings.embyServerIP like 192.168.x.y or something like C0A80131

Same for the port.

To work properly your DTH should have as a device network id the encoded value of your ip:port as below example:
Device Network Id C0A80131:0050.

to see how to encode, the smartthings documentation has examples

Thank you. I’ve been playing with this for a few days in my spare time and just not wrapping my head around a solution.

Using getDataValue to get the IP in hex is giving the same MissingMethodException error. I notice the link is for building a device type and the example is for a device driver.

Could my issue be because I’m trying to do this in an app? I know on hubitat initially sendHubCommand was only available to apps and not drivers so I’m wondering if ST has some similar limitations?

You might want to check this post where the folk did it in smartapp at that time. Http Post to local lan using sendHubCommand in SmartApp?

1 Like

Thank you very much! That’s exactly the direction I needed. I’ve got this portion working perfectly now

def getClientsJSON() {
	def result = new physicalgraph.device.HubAction(
        method: "GET",
        path: "/emby/Devices?&api_key=${settings.embyApiKey}",
        headers: [
                "HOST" : "${settings.embyServerIP}:${settings.embyServerPort}",
                "Content-Type": "application/json"],
                [callback: parse]
    //log.debug result.toString()
def parse(physicalgraph.device.HubResponse resp) {
    def jsonDevices = [:]
    //log.debug "Response json: ${resp.json}"
    def devices = resp.json.Items
    devices.each { thing ->  
1 Like

Maybe you could help me through one more sticking point.

I’ve got Emby sending a webhook on playback events and can confirm the Emby server is sending them through the server logs. I also have it send a duplicate webhook to my hubitat system which is being received.
2020-03-18 15:11:39.457 Info HttpServer: HTTP POST

This is how I’m generating the address which looks to be creating the proper address

For now I’ve commented out my hubitat code for embyWebHookHandler since it wasn’t doing anything and just trying to get a simple log entry.

mappings {
  path("/ewh") 						{ action: [POST: "embyWebHookHandler"] }
def embyWebHookHandler(){
	log.debug "Webhook Received"
	def event = request.JSON
    log.debug event

When the server sends the webhook it does absolutely nothing. No error message, no log entry. Nothing.

If I punch that address into a web browser it gives me a 405 error (method not allowed)

it’s difficult for me to advise as I I don’t know all the tenets of your setup but I would try to mimic the setup with something you totally master like taking a raspberry and a http server that act like the json generator.

if it works then you can isolate something like your query being wrong in the header or the port or whatever wrong.

if it doesn’t work, debug should consist in NetworkID check (very often the case when for instance the parse method is not triggered while you have the pi sending the right answer), IP and port check (again) to match the NetworkID, verifying that your device is installed in the right instance. I had once the case of my device installed and visible in the IDE but it was not under the right Location. So in case you don’t know it, always click the location upon entering the IDE. Another one is that you have “zombie” devices (UUID) and the device sending the message is not the one receiving the answer.

Not sure that helps much but without seeing you entire code, I don’t have good ideas

Thanks for the insight.
I’ve reached out to the Emby dev team on this as well.

I can punch in the same webhook address into Plex and the webhook is received by the app. However when I put that address into Emby, there is no activity in the ST logs and the Emby logs are showing a 500 error.

I wonder if it may be because the Emby webhook is not encrypted and the ST cloud is rejecting it for that reason, therefore it doesn’t reach the app

Maybe using wireshark to spy the traffic between your working case and your non working case will help you further but you’ll need some traffic forwarding capabilities in your network/router,

Good idea! I’ve got a new ISP coming in on Sunday so I’ll have the ability to do that. My current ISP’s router is very locked down.

1 Like