Script help - all devices with battery attribute

Hello @jared.rackliff,

There are different ways to achieve what you want.

  1. Make requests to the Devices Endpoint of the SmartThings API
    You could make a request to the URL https://api.smartthings.com/v1/devices?capability=battery using your Personal Access Token to get the list of all the devices that have the capability “Battery”.
    Once you have all the device IDs, make a request to https://api.smartthings.com/v1/devices/device-id/status replacing the device ID for each one of them, and get the current value of the capability.

  2. Develop a SmartApp
    Using a SmartApp, you could subscribe to the events of the “battery” capability for each device or the capability in general, and every time that an event of this capability is generated, you can compare if the value is 20% or lower and know which device has that level.

The difference between them is that with option 1, you can get all the devices installed in your SmartThings account, and with option 2, you can only get the devices in the location where the SmartApp is installed.

Let me know if you have any doubts or if I can help you with something else.