Receiving and parsing POST requests from local LAN devices

Is it possible to have a SmartApp which can receive POST requests from local LAN devices? My scenario is this – I have a hub device (non-ST) which can send a POST request whenever devices it controls change. How would I setup my SmartApp to receive these requests?

So far I have only been successful at receiving the responses from outgoing REST requests. I can use a HubAction to make a GET or a POST to the remote hub device (non-ST) and see the results in my locationHandler.

I have managed to retrieve the local IP and port the hub uses using the hub properties. But sending well formed HTTP POST requests to the that address and port combination do not result in my locationHandler being called.

I’ve been sorting through github samples and forum posts but I haven’t seen anyone who has solved this. Plus most of the posts are over a year old related to this subject which makes them pre-V2. So my question is this – is this possible and if so, any good samples I can use?

Note that this is for a SmartApp, not a DeviceType as the SmartApp will be creating a bunch of child devices out of the information it gets from the hub device (non-ST).

If it’s not possible at least I can know to stop chasing it…

1 Like

The only inbound requests supported are to the cloud, via an oauth endpoint to a smartapp. See http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/tutorial-part1.html

Local LAN is restricted to making outbound requests from the hub.

Your local LAN device should be hitting the cloud endpoint, not the local hub IP directly.

Only way is via a device type as it binds to the dni of the served sending. But just push this data back up to the parent smartapp.

(To make this easier I am going to use STHUB to represent the ST hub and LHUB to represent the remote hub on my LAN I am interacting with and which sends the notifications).

So the setup is I have my SmartApp do the device enumeration and creation of child devices to represent all the devices controlled by the LHUB. I also have the SmartApp create a local child device to represent LHUB. Then the local device representing LHUB does the call to initiate the POST callbacks and it will receive them in it’s parse method. I can then have the local child device representing LHUB call it’s parent SmartApp with state changes and have it relay them to the appropriate child devices.

Is that correct?

Assuming this is correct, two questions:

  • Does the dni of the device representing LHUB need to be a hex representation of the IP address and port? Or standard IP:port? i.e. is “192.168.1.0:3925” correct for that? Or “C0A80100:F55”?
  • I’m assuming the dni is set with the address of LHUB, not the address of STHUB?

Thank you for the help. I’ve wasted hours trying to make this work the other way.

1 Like