SmartThings Rest API using Tasker

That’s pretty much what I was going to make. However I would suggest adding in handling return response. That way your not attempting to turn off a light that never got turned on.

I’m using sonoff temperature sensors that are connected with smarthings.
Can somebody make tasker widget that can display temperature and update itself

1 Like

Hmm. That sounds interesting. Send me. Pm with the information copied to the clipboard from the get device info task, and the device status task.

3 Likes

where to send the info?

So i have some RGB lights I wanted to control, i got the color working by removing “” so it sends int instead of a string, however I can’t get it to control the level/brightness. It doesn’t give a error it just doesn’t change

{ “commands”: [ {
“component”: “main”,
“capability”: “colorControl”,
“command”: “setColor”,
“arguments”: [{
“hue”: %colorHue,
“saturation”: %colorSaturation,
“level”: %colorLevel
}]
} ] }

Get device status returns this:
{“components”:{“main”:{“colorControl”:{“saturation”:{“value”:100,“timestamp”:“2023-01-24T20:28:25.376Z”},“color”:{“value”:null},“hue”:{“value”:50,“timestamp”:“2023-01-24T21:23:41.950Z”}},“healthCheck”:{“checkInterval”:{“value”:60,“unit”:“s”,“data”:{“deviceScheme”:“UNTRACKED”,“protocol”:“cloud”},“timestamp”:“2022-09-06T19:21:09.179Z”},“healthStatus”:{“value”:null},“DeviceWatch-Enroll”:{“value”:null},“DeviceWatch-DeviceStatus”:{“value”:“online”,“data”:{},“timestamp”:“2022-09-06T19:21:10.548Z”}},“switchLevel”:{“level”:{“value”:16,“unit”:“%”,“timestamp”:“2022-09-06T19:21:10.548Z”}},“refresh”:{},“switch”:{“switch”:{“value”:“on”,“timestamp”:“2023-01-24T21:11:06.113Z”}},“colorTemperature”:{“colorTemperature”:{“value”:null}}}}}

You need to send a separate setLevel command. Level isn’t part of the colorControl capability in SmartThings. Use the switchLevel capability.

1 Like

:point_up:This is correct.

Here’s the code for dimmer/brightness.

{"commands": [{"component":"main","capability": "switchLevel","command": "setLevel","arguments": [%DimmerLevel]}]}
1 Like

A little more info on this, the capability colorControl only has attributes for color, hue, and saturation and commands for setColor, setHue and setSaturation.

I tried using the turn on and set level task, turns out there is a typo in that one: %dimmerLevel is the variable used but in the http request it says %DimmerLevel

Thats why I couldn’t figure it out :sweat_smile:

1 Like

If you use devices:commands in the cli it will show you what is accepted for a device…

mikefitzgerald@Mikes-MacBook-Air ~ % smartthings devices:commands 1a9bf31e-97b7-49fc-87e5-09c591c4315c 

Workout

Capabilities:
─────────────────────────────────────────────
 1  switch                                   
 2  button                                   
 3  platemusic11009.zoozLedMode              
 4  platemusic11009.zoozLedColor             
 5  platemusic11009.zoozLedBrightness        
 6  platemusic11009.firmware                 
 7  platemusic11009.basicSetAssociationGroup 
 8  platemusic11009.deviceNetworkId          
 9  refresh                                  
─────────────────────────────────────────────

? Enter capability index or id 3

Commands:
──────────────────────────
 1  setLedMode(value<enum 
      - onWhenOff         
      - onWhenOn          
      - alwaysOff         
      - alwaysOn>)        
──────────────────────────


1 Like

Thanks for finding that. I fixed it, I will republish the main tasks along with some new ones.

In tasker is there a quick way to go from the label to the ID, I’d like to be able to call turn on/off with the label as parameter instead of the dialog option. (To automate things)

Technically you only need the http request action. You can edit out the variables with the deviceid and commands. All my tasks a simply examples. If you could be a bit more specific on exactly what you want it will help me narrow down how to help.

Okay I don’t know how to explain it clearly but I’ll give it another try:
I would like to be able to convert a device label to a device id.
So basically a task that i can feed the ID for example “smartplug_1” as a parameter and it would set %deviceID to the corresponding ID

So you want to use the perform task action in tasker and use the %par1 to supply the deviceId to a generic task. And the %par1 is the device label and the generic task does a lookup in the local db for the deviceId correct?

Here are some new code snippet for use with @philh30 schlage lock driver.

Set Alarm Mode (argument - (off, activity, tamper, forcedwentry))

 {"commands": [ { "component": "settings", "capability": "platinummassive43262.schlageLockAlarm", "command": "setAlarmMode", "arguments": ["{{argumentMode}}"] } ] }

Set Tamper Sensitive (level (1-5))

{ "commands": [ { "component": "settings", "capability": "platinummassive43262.schlageLockAlarm", "command": "setTamperSensitivity", "arguments": [{{level}}] } ] }

Set Activity Sensitivity (level (1-5))

{ "commands": [ { "component": "settings", "capability": "platinummassive43262.schlageLockAlarm", "command": "setActivitySensitivity", "arguments": [{{level}}] } ] }

Set Forced Sensitivity (level (1-5))

{ "commands": [ { "component": "settings", "{ "commands": [ { "component": "settings", "capability": "platinummassive43262.vacationMode", "command": "off", "arguments": [] } ] }capability": "platinummassive43262.schlageLockAlarm", "command": "setForcedSensitivity", "arguments": [{{level}}] } ] }

External Keypad Beep (command -(beep or off))

{ "commands": [ { "component": "settings", "capability": "platinummassive43262.keypadBeep", "command": "{{command}}", "arguments": [] } ] }

Auto Lock (command -(autolock or off))

{ "commands": [ { "component": "settings", "capability": "platinummassive43262.autoLock", "command": "{{command}}", "arguments": [] } ] }

Interior Schlage button (command- (disable or enable))

{ "commands": [ { "component": "settings", "capability": "platinummassive43262.schlageInteriorButton", "command": "{{command}}", "arguments": [] } ] }

Lock and Leave (command (lockandleave or off))

{ "commands": [ { "component": "settings", "capability": "platinummassive43262.lockAndLeave", "command": "{{command}}", "arguments": [] } ] }

Vacation Mode (command -(vacation or off))

{ "commands": [ { "component": "settings", "capability": "platinummassive43262.vacationMode", "command": "{{command}}", "arguments": [] } ] }
3 Likes

I’m trying to create a Toggle task for my wiz light, the idea is for it to check the Switch status and if its off it will turn the light on and vice versa, but when I run the the “status” command it drops a ton of info, is there a way to just get or isolate the switch value ?

thank you!

If you don’t care about whether the light is on or off, you can save the trouble (and delay) of polling the status before sending the command by using a virtual momentary switch.

  1. Create the momentary switch using @TAustin 's virtual device creator.

  2. Create a routine so that when your virtual momentary switch turns on, your (real) light toggles.

  3. Always send an “on” command via tasker to turn on the virtual device, which will toggle your light.

Hope that helps!

Yes you can you just need to request that value. Here is what you need to get just the value of the switch.

%http_data.components.main.switch.switch.value
1 Like

Thanks to Jake’s help I managed to create a toggle on/off action and its faster than expected.
I’m planning on buying more lights for my home so the virtual device will be helpful thank you for your help!

2 Likes