SmartThings Rest API using Tasker

I went out of town for a family emergency last week and my system went offline multiple times while I was gone because the WiFi went out for a second and didn’t re-set. I kept thinking that I could somehow set something up that would turn the WiFi power off for a few seconds and then back on if the Hub went offline. However, if the Hub goes offline, then I can’t communicate with it to tell it to turn some plug off and then back on. Ha! So, I was thinking about the same situation somewhat as DieselDaisey. By the way, I had my neighbor get in the house and restart it, so problem solved (at least for these multiple times it went down) :grin: I also thought that if the Hub had an Edge driver for the plug, and the Routine ran locally, that I could turn on that Routine if I go out of town and have it turn WiFi off/on once or twice a day at off times. That might work…

Something like that might work. Unfortunately the tasker calls won’t work locally with them using the API. In theory you are correct, a power outlet that is running a driver “SHOULD” be able to be controlled by a in app routine maybe a rule and should be able to power cycle the wifi router. Key word, “SHOULD”. The only thing I see being an issues is the Time part of the if statement as it doesn’t seems to allow to be ran locally, at least in my quick tests.

Hi, I think I explained wrongly, what I am trying to do is - when your task finds a device offline as well as the pop up notification I want it run another task which turns on a totally separate device, i.e a lamp, so if I do not see the notification on the screen I will see by the lamp being on that other devices have gone offline

Hi, I am not sure if you can still buy them, but many years ago I had a similar setup and you could buy a adaptor for your telephone line and when you called home and Pressed a certain number on your phone a relay switch toggled on or off (which the router was connected too), you basically spliced the router power cable into the relay, i think I bought it of ebay

Are you looking for any device that is offline or a specific one? I can build you a task to help you out. I will just need some more information. If you will DM me we can continue this conversation there.

Thanks for the idea. I’ll check it out.

I might have to set it up without the IF and just turn it on when I’m out of town to cycle the power to the WiFi router periodically just to ensure it’s on. Things will go offline for a bit but better than everything being offline too long.

Any updates on the battery status task/profile?

Almost done. You will need to use a new Build DeviceDB task first. It adds battery info for devices with batteries. The main reason for this is speed, meaning we look through a local DB and see what devices have battery capability and only query those devices instead of every device on your account.

Also some device with batteries can show null so that’s an option. Inside the task you will set a minimum threshold for battery level.

Example if you set it to 30 it will show everything below 30% and null devices.

3 Likes

UPDATE - BATTERY STATUS

Build new DeviceDb TASK you will need to run this first. It will back up the old %DeviceDB to %DeviceDBbak. The reason for this is to include what device are battery operated in the local DB so that we only poll the devices with batteries. Which will increase the speed in which the task works.

Battery check Profile

You can edit action 1 in the “Get devices battery level” task to set you minimum battery threshold.

3 Likes

@Jake_Mohl

Jake, what would I need to change in the following Tasker “Bodies” to make them work with a virtual Presence Sensor that does NOT include a switch?

{
“commands”:
[
{
“component”: “main”,
“capability”: “switch”,
“command”: “on”,
“arguments”:
}
]
}

{
“commands”:
[
{
“component”: “main”,
“capability”: “switch”,
“command”: “off”,
“arguments”:
}
]
}

What driver or device handler are you using? And is there an issue with using a present sensor that has the switch included?

I am using @lmullineux new virtual devices for locations without a hub. At my cabin (2nd) location I don’t have a hub, and this is the only new architecture, virtual presence sensor that I know of for a location with out a hub

Screen shot of details.

@Paul_Oliver I’m looking into this for you, at first glance the capability presenceSensor doesn’t accept commands, however I’m hoping the driver has a custom capability. I will let you know as soon as I know something.

1 Like

I’d like to use Tasker HTTP Request on Android to set the text field of @Mariano_Colmenarejo new-release-edge-driver-virtual-appliances-mc-virtual-switch-mirror-virtual-calendar-and-virtual-switch-board virtual driver. Do you know what the API command format would be to set some external text into the text field of this virtual driver?

Componet
Capability
Command
Arguments

UPDATE!
Nevermind, I was able to figure it out. WOW!

Issued the ‘smartthings devices:command [ID]’ and saw the capabilities and commands for the device. Then I setup the HTTP Request action and walla, Tasker posted the “%HTTPD” external text to the virtual text device. And I thought figuring it out myself would be outside my ability. So now I can set the text field of the virtual text device to the HTTP Get from ‘checkip.amazonaws.com’.

1 Like

@DaWeav will you please share your task? I will add it to the code snippet post so others can use it if the need to.

1 Like

The ‘NNNNN’ of the legendabsoluteNNNNN is a 5 digit number which I’m guessing might be different for everyone and maybe even different for each virtual text device. And since the virtual text device has five different text fields that can be set, the textFieldOne and the setTextFieldOne can be any of the …One through …Five fields apparently.

Tasker Task
HTTP Request
Get
URL checkip.amazonaws.com

HTTP Request
Post
Body

{
“commands”:
[
{
“component”: “main”,
“capability”: “legendabsoluteNNNNN.textFieldOne”,
“command”: “setTextFieldOne”,
“arguments”:
[
“%HTTPD”
]
}
]
}

This is just a backup for DynamicDNS.

The ‘legendabsoluteNNNNN’ is an automagically generated string that is unique to the developer’s user account. As users we first encountered it in the context you see it here which is as the namespace for a custom capability.

If you have the CLI and run ‘smartthings organizations’ you’ll probably see your own variation as your ‘default user organization’ but organizations in this context haven’t been introduced to us yet.

1 Like

When using the Get Device Status task, how can I pass a value to a variable?

In particular, I would like to check if my Garage Door is open or closed before proceeding in my task.

Running the Get Device Status task for my Garage Door returns:

{“components”:{“main”:{“doorControl”:{“door”:{“value”:“closed”,“timestamp”:“2022-10-24T03:09:12.228Z”}},“refresh”:{}}}}

How do I pass the “closed” value to a variable?