SmartThings Rest API using Tasker

Ran the test manually and received same error. Went ahead and replaced the HTTP request and got the same error again?

Went ahead and deleted both tasks (Tasker SmartThings Rest API and device check) and reinstalled fresh new ones and received the same error.


Your bearer Token is still in the variable?

Is %DeviceDB.deviceId(%lcv) working OK? Just wondered if you needed to use %DeviceDB[deviceId](%lcv) because of the upper case letter in deviceId or if it didn’t matter when there are already uppercase letters. I’ve not used Tasker for a while.

They using a task I made and it works on my end and was previously working for them.

Yes sir Bearer is still in the variable.

Sounds like a ‘yes’ then.

Did not change anything, still getting error.

Re-Run the Build Database to verify the DB is populated with all current information and intact.

Then run the Get DeviceId. Select a device preferably something you know is active.

Make a new task.

Copy the HTTP Request action from the Get Devices Offline Status to the new task.

Replace the URL with this.

https://api.smartthings.com/v1/devices/%deviceId/health

Next add a flash
Use this variable in the flash.

%http_response_code

Run the task and see what code is flashed.

Re-Run the Build Database… DB did populate.

Ran the Get DeviceId… picked Bar light and task found device ID and it copied it to the %deviceID variable.

Ran task and see what code is flashed… 200

Ok that’s all good. Try running the Get Devices Offline Status now.

Now we are only getting the error in the variable search replace field.

Add a flash before action 6 with %offlinearray() as the variable. Let’s make sure something is in the array. If it’s empty that would cause the error

Looks like it is empty…

iMarkup_20220925_153657

Okay change the flash to %offlinearray(#). If that comes up as zero or nothing at all. I’m guess it’s not finding anything that’s offline and we need to add in some error checking.

I did confirm through the Smartthings app that there are no devices currently offline. Screenshot is showing zero.

Here’s the fix.
Replace action 6 (the flash) with a “IF”
Inside the IF you will want

%offlinearray(#) > (Maths: Greater than) 0.

tasker will ask you if you want to add the end of or and else and end of. Just hit the back button.

Finally you will want to add a “End if” action at the bottom of the task. This will close the if statement.

With this addition it should now handle the condition if no devices are Offline.

Please keep in mind your Pushbullet action needs to be inside the IF statement.

We’re assuming that if nothing pops up through the pushbullet/list dialog/flash, then there is no devices offline? If so, looks like this task works and is not reported any errors.

Jack thank you very much for taking the time to help on this task.

What it is doing is looking at the array we build looking for Offline devices. If no devices were added to the %offlinearray. We skip the formating part and the Pushbullet part because there is nothing to report.

The if %offlinearray(#) > 0 is simple looking to see if there is anything in the array. If yes then we formate it and push the list using Pushbullet. :smiley:

1 Like

I have updated the Tasker Profile
“Every Hour Check Device Health”
It now handles if an error that would occur if no devices werw offline. You can reimport the profile from the link in Post 3.

1 Like