FAQ: Getting Started with the new Rules API

From the docs:

the execute api can be used to trigger your rule instead of waiting for an event to trigger the rule automatically

https://smartthings.developer.samsung.com/docs/rules/overview.html

Does the api support creating a trigger on ā€œbutton #2 heldā€ (Say for the 2 button lightify dimmer switch)? It isnā€™t clear if or how this could be described in the device operand.

Thanks, @TonyFleisher, but I donā€™t think I follow exactly. Can you give an example?

It looks like the Rules API can only control lighting at this time. For example, I can use it to turn on a switch at 9am. When I try to set the thermostat temperature at 9am, the API returns a ā€œ422 Unprocessable Entityā€ error. Am I missing something? Or will the temperature control be added in at a future release of the Rules API? Thanks.

It can do more than switches. The examples on their github have switches, location mode, and door locks. But no example with a thermostat :confused:

Hi Developers,

Couple quick updates:

  • Now you can use Rules API with time based events - such as turning a light on 30 minutes before sunset. We released additional JSON Rules examples into the sample Rules API repository.

  • We released a sample Rule builder app on Glitch to show how you can integrate Rules API into your app.

Feel free to fork/remix and try them out for yourself!

3 Likes

The Glitch sample rule builder is almost impossible to use if you have multiples of the same type of device. The device list is using the Name field for each device which is very generic . So if you have multiple of the same device, like a multisensor, you just see the entry ā€œMultipurpose sensorā€ several times and canā€™t tell which one it is. It would make more sense to show the device Label, which is what is set by the user and displayed in the SmartThings app.

3 Likes

Hello, @Automated_House

Your suggestion was really good, thank you for sharing. Please give it a try as weā€™ve updated the Rule builder app.

Help! I created a couple of test automations with the Rule builder app. I thought they would show up under automations in the SmartTings app but they are not htere. How do I find these automations and delete them?

Hi @1mike4many, the Rules API is currently focused on developers. You can use this sample app to manage your Rules.
You can follow this steps to delete your rule:
1.- Authorize you samsung account to use the manager (If itā€™s not requested when entering, press log out)
2.- List the rules of the location you want your rules to be deleted.
3.- Copy the ID located at the bottom of the JSON for each Rule you want to delete.
4.- Go to Delete Rule and paste the ID retrieved in step 3, and select the same location.

After this you can retrieve once more time the rules to check the delete was successful

I hope this helps! Let me know if you have any trouble!

Gisele:

Thank You for your prompt reply.

I I have been through that sample app before but coding isnā€™t one of my strong points and couldnā€™t figure it out.

I will follow the steps you outlined tonight and let you know how it goes.

Thank you again

Mike

Gisele:

After following the steps outlined, they were very easy to follow by the way, I did not find any rules listed. The following code was all there was in the JSON Response field

{
ā€œitemsā€:
}

I assume the rules have been deleted and something else is triggering the device. I will continue to investigate the issue.

which glitch app did you use to create the automation? smartthings-automations or smartthings rules manager? As I understand it, you can only delete them using the authentication token that created them. I believe smartthings-automations glitch app installs an app under settings>connected services in the new app. You can try deleting that and see if it stops the automation.

Gisele:

After following the steps outlined, they were very easy to follow by the way, I did not find any rules listed. The following code was all there was in the JSON Response field

{
ā€œitemsā€:

Another user suggested removing the trigger (temperature/humidity sensor) then adding it again. That seems to have kept the automation from occurring as I have not had the issue since.

Thank You again for your help.

Mike

1 Like

I used the smart-things automations app. ST Automations does show up under connected services. As you can tell I was able stop the automation from running by removing the trigger, but I will also go ahead and delete ST Automations from the connected services.

1 Like

I havenā€™t tried new Rules in Glitch yet; can anyone summarize how this is coming along compared to WebCoRE feature set? I am still plugging along with WebCoRE but wish it could be updated to support a couple of the new/changed features (STHM vs SHM & Automations vs Routines).

Hi all,

Few months in to my SmartThings journey I have written a few Smartapps and Webcore rules but now I am seeing this will all be replaced.

I want to write a few more Webcore rules but donā€™t want to do so if they will become void in a couple of months due to the RulesAPIā€¦
My issue is that the RulesAPI does not do what I need it to including the below:

  1. Variables - for example an integer which increment

  2. Capture state of devices to return later

  3. Push notifications which can add variables within them.

Will the above ever be possible and when is this planned for release. At the minute I feel stuck in limbo so want to see what route I should take.

Thanks in advance

Webcore announced plans at the SmartThings Developer Conference last year to be modified to USE rules API.

Im pretty sure they havent made the upgrade yet for the very same reasons you stated. And a few more.

1 Like

Thanks @nathancu,

I have watched the conference, which is where I originally heard about the changes but it has been 6 months since then and as far as I can see, no real progress has been made.

I keep track of all the communities and developer document pages, but cannot see anything that relates to change logs or progress reports.

Also it seems in future we will only be able to develop SmartApps if we have a server, which is a bit of a downgrade.

I appreciate your input, hopefully we will hear something soon from Samsung themselves.