SmartThings Rest API using Tasker

Nice, if you need any more help feel free to tag me a d I will do my best to help.

1 Like

Thanks for getting this built out! A lot of cool possibilities.

Is there a way to have the built in tasker notify action display longer or scrollable notifications?

Iā€™m trying to use the battery level and offline device examples above to pull temperatures from all my temperature sensors. But the notification is cutting off at 10ish sensors. I had it pop a dialogue up, so I know the rest is in the string but just not displaying in the notification.

The options in the action setup werenā€™t obvious, and I havenā€™t found an answer via google.

The expanded size of a notification is fixed to approximately 256dp depending on the os version. So there is no way to get more lines, you could add more data per line.

Temp sensor1 : 65 | Temps Sensor2 : 66
Etcā€¦

Have you thought about filtering the data and only show battery percentage below a threshold?

Also there is a ticker Web screen thatā€™s available with the AutoTool plugin for tasker. It works ok but it would be my go-to method.

1 Like

Got it thanks. Iā€™ll probably try to shorten it as you suggested or just do on demand in the app. Whatā€™s your preferred way of getting notifications out of tasker? The list dialogues disappears which isnā€™t so helpful for me at least when scheduling runs once a day or what have you.

Thanks again for getting the building blocks developed here! Think next Iā€™m going to replicate an HVAC change webcore piston I had (albeit without the device subscription, but should be good enough). Iā€™m away often so I like to know if this changes with weather etc, and hadnā€™t found a way until this.

How To Get Events From ST To Tasker

You will be using:

Using sharptools we will be making a rule to trigger based on the events then using pushover to send them to your android device. Since pushover supports tasker you can react to these notifications (yes, you can silence the notification so you donā€™t see them and it will still work) and then import the information from the notification.

A use case for this is to have widget(s) on your home screen that will mirror your devices status.

Hereā€™s how I set this up.
Pushover Setup
Follow the instructions that @joshua_lyon wrote out here. On how to get Pushover to work with Sharptools.

Sharptools Setup

Send Switch State Rule


Code for pushover body

{"thing":"{{$context.event.deviceName}}","switch":"{{$context.event.value}}"}

Send Lock State


Code for pushover body

{"thing":"{{$context.event.deviceName}}","attribute":"{{$context.event.attribute}}","state":"{{$context.event.value}}","method":"{{$context.event.data.method}}","codename":"{{$context.event.data.codeName}}","codeid":"{{$context.event.data.codeId}}"}

We are sending it as a JSON because tasker can parse it easily.

TASKER Setup
Here is a project with 2 VERY basic profiles.

  • My Switch State will flash Device name and itā€™s state(on or off)
  • My Lock State will flash Device Name, State, method, codename, codeid.

Results
Switch

Lock

FINALLY
Lets mute the Pushover notifications.

Open the the apps info for Pushover and set notifications to Blocked.

That should now give you basic events for switch on and off and lock and unlock more can be done like button pushes events and camera events. As always I will be happy to help out how ever I can.

I would like to give a very special thanks to @joshua_lyon and the sharptools team without them this wouldnā€™t be possible.

5 Likes

This is great, anyone who has Tasker /Tasker widgets and a SharpTools account, this is a must have.

It doesnā€™t matter which app (Alexa for example) changes the state in SmartThings, if you have it linked to SharpTools, SharpTools then sends the Pushover message to tasker

After only ten minutes after seeing Jakeā€™s examples, I now have all my tasker widgets change state to mirror SmartThings/SharpTools

Another cool use case I set up, I have set tasker to say if a certain Door/Window/Gate ect is opened, which is very handy, when in the garden or washing the car, as long as you have you phone in your pocket you will know which Door/Window/Gate has opened or anything you monitor with sensorā€™s

This is a must for me (Never again will I get caught messing with my fishing tackle in the garden shed, when Iā€™m supposed to be doing stuff on the house before the wife gets home):grin:

3 Likes

Not sure what happened, but after my Samsung Tab A7 Lite updated to OneUI 5.1 with the latest security patch, now Tasker isnā€™t using the %HTTPD built-in variable, so I had to use the %http_data built-in variable instead. I also had to use the variable convert from HTML to text to get the %http_data to post on SmartThings API. Strangeā€¦

Iā€™ve nevered used the %HTTPD with the http request. Iā€™ve always used the %http_data. I donā€™t think anything with a security patch would have altered that. Tasker is the one that assigns the data to the variables.

Where/How do I run the Build Database task?

You open the task then click the play button.

Thanks for getting back with me. When I click on the Tasks tab, there is nothing to run. I have not done something right, just not sure what it is.

You must import the tasks. Go to the first post and click the link Tasker SmartThings Rest API.

Is it possible to use the API to enable or disable a smartthings routine?

Thanks

It can certainly be done today, yes, but not using the public version of the API so there isnā€™t any guarantee it can be done tomorrow. I also have my suspicions over the efficacy of enabling and disabling rules, so I personally would only do it as an alternative to using the Client Apps and not on the fly.

Thanks Graham

I wanted to place a toggle on my android home screen but Iā€™ll just continue to use the app to disable / enable manually.

I just found this and Iā€™m trying to set up when I scan an NFC tag it will cause a device to do something. Currently though the tasks I see bring up a device select list and command select. Iā€™m new to Tasker but is it possible for a profile to send these values to the task without the list showing?

Screenshot of what your talking about please.

If I understand you correctly, I have something similar. The only difference is that my trigger is not a reading of NFC tag.
For your case, the Profile should be:

NFC Tag ā†’ ID = ID_OF_YOUR_TAG

For the, task.
In my case I made an HTTP Request with the command I needed.

URL: https://api.smartthings.com/v1/devices/{ID_OF_YOUR_DEVICE}/commands
Headers: Authorization: Bearer YOUR_BEARER_TOKEN
Body: THE_COMMAND_YOU_WANT_TO_EXECUTE

In my case, the Body is:

[{ā€œcomponentā€:ā€œmainā€,ā€œcapabilityā€:ā€œswitchā€,ā€œcommandā€:ā€œonā€}]

To switch ON a virtual Device

I have some NFC tags to, byt my problem is, when the phone reads the TAG, one of 2 things happen:

1 - It show a Popup asking for what app should be used and it shows ā€œTaskerā€ and ā€œNFC Serviceā€
2 - It just opens ā€œNFC Serviceā€ app

Anyone knows how to disable this ā€œNFC Serviceā€ app on a MIUI device?? Or to force Tasker to be the one who opens NFC tags???

I ended up just making the task do the action as you said. For the NFC bringing up a popup in Tasker it prompted me to write to the tag and that solved it.

1 Like

Hi! Iā€™m a Tasker n00b and despite being somewhat tech-savvy I find it a little overwhelming. Iā€™m hoping someone (@Jake_Mohl ?) can help me set up the following:

I want Tasker to control my lamp to simulate sunrise based on when my Android phoneā€™s next alarm is. This is what Iā€™m imagining:

  • Detect next phone alarm (I believe this is possible with ā€œTest Next Alarmā€)
  • Detect if home (so that if Iā€™m traveling the trigger doesnā€™t happen)
  • 90 (or 100, if thatā€™s easier for dimming percentages) minutes before next alarmā€¦
    • Set color temperature on my bedside lamp (an IKEA Zigbee dimmable with temperature/color changes) to 2200k
    • Set dimmer on my bedside lamp to 1%
    • Increase to 100% between start and next alarm
    • Change color temperature from 2200k to 4000k over same time
  • 10 minutes after alarm is dismissed, change color temperature to 2700k

I think I have two options for this:

  1. Google Home/Assistant and the ā€œGentle Wakeā€ command, since GH is linked by cloud. I donā€™t love this approach because A) it might make noise, and B) itā€™s a little opaque in how it operates, and C) itā€™s limited to 60 minutes, I think.
  2. Smartthings device commands.

Things I would also like to avoid:

  • An initial flash of 100% brightness on the lamp
  • An initial color shift from whatever the color was last set to (e.g. if the lamp was last turned off at 2700k, I donā€™t want it to turn on to 2700k before the initial color shift to 2200k)

I think those things can be avoided, because the lamp will accept dimming and color-change commands while off. The catch is that giving those commands while it is off will turn on the lamp, so itā€™s possible only one can be avoided. If thatā€™s the case, ideally the one to avoid is the 100% initial flash.

Also, I realize that this can mostly be accomplished with the built-in Smartthings Lab app, but it has the following limitations:

  • No color control
  • Maximum 60 minutes lead time
  • Doesnā€™t vary based on alarm time
  • Unavailable in some regions

So far, I have been able to successfully generate an API token, import the Tasks, Build Database, and download and install AutoTools.

Thanks to anyone who might be able to help me set this up! :slight_smile: