[Solved] How to use port 39501 with GET?

Unfortunaly my hardware allows only defining URLs where to send it's information.

I know that generally I can intercept messages to port 39501 by using parse in my driver code - when the MAC is correct.

Can I include the MAC in the URL (or as parameter)?
Is there an other way to use port 39501 and parse?

BTW: I know I could misuse the Maker API for such cases, but then I would have to add every such hardware to the list of Maker API's devices.

You can implement actual HTTP request handlers. The catch is that you have to do it in an app rather than a driver.

It may or may not be better than the Maker API idea that you mentioned. You would still have to select the devices in the app configuration. Or just create them as children of the app.

1 Like

Yes, you can use the IP address (in hex with no separators, if I recall) instead of the MAC as the device's DNI. Otherwise, the exact problem isn't clear to me: if your other device can send to a URL, that is exactly what you want, and either of these methods should work equally well as long as you're able to also specify this port.

Or something like the above, which as stated would have to be done in an app, does give you more flexibility. That specific example demonstrates how to host content on Hubitat (responding to a GET), which you might want to use to fetch data from Hubitat on the other device, but either adding parameters to that or using another HTTP method (depending on what your other device is able to do...and if you have any preferences for when you use different HTTP methods) should be able to give you the ability to receive, too. But it's not clear to me if you'd actually need to do that.

The hardware shall send measured values to Hubitat, only using HTTP GET.
Where/how exactly can I include the hardware's IP Address (which in my case is static and known) in the URL?

E.g. given an URL like this:
http://[Hubitat-IP]:39501/?x=22&y=33&z=44

BTW: I cannot set the request header.

You don't need to. If the device's DNI is either the MAC or IP address (in hex, with no separators) of the "sending" device, the platform will automatically handle routing traffic on port 39501 to the correct device--or log a warning if it receives such traffic and none exists.

1 Like

Oh. My. God!
I havn't noticed the small edit link right above the DNI input box... :roll_eyes:

Therein I put the hex'ed IP address, right?

YES, now it works like a charm (using UPPERCASE letters), thank you very much! :+1: :beer:

3 Likes

Hi, sorry to intercede on an old thread but I'm trying to do exactly the same thing.
in your example (http://[Hubitat-IP]:39501/?x=22&y=33&z=44) how are you extracting the values for X,Y and Z.

Any help appreciated.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.