Get external data from IP device with open api

Hi,
Been searching the forum (without luck) for a simple device handler or smartapp which can pull data from an external device which not supported but has an open api.

What need to do is to create a new device in smartthings which present data from an external IP device (which has an open API).

Here is from the API documentation of the device.

request data from: youripadress/api/alldata

your device i will reply in JSON format example:

{"0001":275,"0002":285,"0003":342,"0004":227,"0005":28,"0006":14,"0007":65218,"0008":108,"0009":245,"000A":232,"000B":578,"3104":1000,"0107":267,"0111":510,"0203":235,"2204":1,"2205":27,"0207":10,"1A01":192,"1A02":1,"1A03":1,"1A04":0,"1A05":1,"1A06":1,"1A07":0,"1A20":0}

Highly appreciate if someone could assist with a link or code for this simple request.

Tanks!

Welcome to our Community, @Gustaf!
Just to clarify, please confirm/answer the following:

  • Do you want to send commands to your external device from the ST app or just show the info?
  • All the capabilities your device has, are known by the SmartThings platform? (See the capabilities document)

Hi! Thks reply.
To start with i just want to show the info.
Above is the reply i get with a httpget request. But not sure to set it up in SmartThings. “001” “002” , etc is different ‘sensors/values’. It’s a heatpump which is connected with an ip module which has an open api. RestAPI.

Later on I would also need to be able to send a post request to change some of the values.

Ok, I asked because the ST Schema Connector can help you in this case but you need to consider the following:

  1. The measures and commands accepted by your device:
    a. I guess you know how to parse the JSON received (which value corresponds to which measure), so, is there a standard capability you can use to display each one of them?, so, is there a standard capability you can use to display each of them? eg. Temperature Measurement, Heating Setpoint.
    b. If it has a manufacturer-specific capability or none of the standard ones works as you want, you can create a custom capability.
  2. As the external device is reached through an open API, you would need to create scheduled queries to get its current state (that could be done by a SmartApp or using the Connector’s State callbacks).

Is there any good example for the httpget i can use to build from? not sure if should use device handler or smartapp? all the examples i find is just small parts of an full device handler or smartapp.
The values i know what they corresponds to(different heating values/temperature measurements).

Ok, another alternative is using the SmartApp Connector directly.
A couple of important points:

  1. This uses the SmartApp SDK but is registered in the Developer Workspace as Device Integration > SmartThings Cloud Connector > SmartApp Connector
  2. The SmartApp SDK is based on the Core SDK, so, you can use the commands of the endpoints included. This is where commands like ctx.api.devices.sendEvents(..) come from.

Below you’ll find an example of a switch device, which contains:

  1. Installation callback - Creates the device, initializes the capability, and create the Schedule
  2. Command handler - This receives the commands from the ST mobile app and updates the device state. (This is where you would execute the POST requests later on)
  3. Schedule handler - This is where the HTTP GET request to the open API would be executed. According to my sample, it would be executed every 5 minutes and it’s done using the Axios library.

Let me know if you have more questions. :smiley: