Devices status

Hi,

I am making a customized app to have an overview of all my devices. kind of dashboard.

I have read the documentation at https://smartthings.developer.samsung.com/ and checked the API reference https://smartthings.developer.samsung.com/

I see that the device’s API endpoint doesn’t come with online/offline status. Meaning that I am currently interating with devices and status api endpoints, which in the end makes things slow.

So my question is whether there would be a different method that could speed up things.

I see that the https://graph-eu01-euwest1.api.smartthings.com/location/devices/ is quite good doing this job.

Did you come across the Health API? It doesn’t seem to make the API reference. No idea if it works, I just came across it in the maze that is the Developer docs.

Hi,

Thanks. That’s exactly what I am using now. I call device endpoint and then iterate with the health api endpoint for each deviceId. Although this works for 10 or 20 devices setup, it becomes very slow for 200. Besides, I guess I would have problems with rate limits.

Hi, @cpinho

A workaround that I’d suggest you is developing a SmartApp Automation (no device selector needed) to get your devices list through the SmartThings API and then create Subscriptions for your devices.

This approach will help you to receive real-time Device Events if a device goes offline instead of scheduling health requests.

See the next example using the SmartApp NodeJS SDK to get the list of devices:

const SmartApp = require('@smartthings/smartapp');

const exampleDeviceMonitor = new SmartApp('Example Monitoring SmartApp')
    .enableEventLogging(2)
    .disableCustomDisplayName(true)
    .appId('Example Monitoring SmartApp')
    .permissions(['r:devices:*'])
    .updated(async (context, updateData) => {
        // Clear previous subscriptions to avoid API errors.
        context.api.subscriptions.unsubscribeAll()

        // List of devices
        const myDevices = await context.api.devices.listAll()

        // Here you can create subscriptions recursively 
        // following the Subscriptions documentation.
    })  

Note: SmartApp Automations are only available for self-publish.

Best regards,
Erick.

Thanks for this. Although I guess that I am unable to use this, since I am unable to do the registration of my app. I am using Outsystems. Any idea?