FAQ: Getting Started with the new Rules API

Im pretty sure theyre in limbo just as you are. Theres absolutely zero way WebCoRE would work without access to variables afterall, so I wouldn’t expect anything until that happens.

1 Like

We are looking at the feature gap needed to allow webcore to use native rules, and as @nathancu said there are requirements missing to reach parity. We will be working to close that gap but having parity goes beyond variables and expressions and that means it won’t be a short term fix. That said we will continue to release features that bring rules closer in parity to what webcore currently offers. Work on rules is ongoing I expect we will have some things to announce about this soon :tm: .

2 Likes

Thanks @nathancu & @jody.albritton,

It’s great to hear progress is being made on the RulesAPI and I eagerly await the progress update.

I completely understand the restriction lies withing the RulesAPI and the JSON structure so very little that WebCore to do at this point.

I also understand that the end goal is for the better using more modern technologies which in turn will reduce cost and open more doors to intigration… I guess I’m just eager to unleash the Power of a customised smart home :slight_smile:
Thanks again both

Rules API PUT 500 error.

I’m following the guide here using postman to create a rule: https://smartthings.developer.samsung.com/docs/rules/overview.html

Once the rule is created, I’m then trying to update it using the REST API PUT method - but getting a 500 error:

{

"requestId": "521C79A2-84C6-4C7C-9108-3BB4C8BE9A40",

"error": {

    "code": "UnexpectedError",

    "target": null,

    "message": "A non-recoverable error condition occurred.",

    "details": []

}

}

The request contains the full rule in json within the body to the endpoint:

https://api.smartthings.com/v1/rules/686cf2c3-2584-4021-adee-8c4f02c09e04?locationId={guid removed}

Hello @Jamie_D,

We haven’t been able to replicate the issue. Can you please share with us the structure of the rule you are trying to update? This way, we can point you in the right direction to correct the issue.

Hi,

Thanks for coming back. The body of the rule looks like this:

{

    "name": "updated 2nd Control lights when location mode changes.",

    "actions": [{

        "if": {

            "equals": {

                "left": {

                    "location": {

                        "attribute": "Mode"

                    }

                },

                "right": {

                    "string": "a89a6ad7-929f-4f64-b0ce-8bdf83026982"

                }

            },

            "then": [{

                "command": {

                    "devices": [

                        "{guid removed}"

                    ],

                    "commands": [{

                        "component": "main",

                        "capability": "switch",

                        "command": "off"

                    }]

                }

            }],

            "else": [{

                "command": {

                    "devices": [

                        "{guid removed}"

                    ],

                    "commands": [{

                        "component": "main",

                        "capability": "switch",

                        "command": "on"

                    }]

                }

            }]

        }

    }]

}

Hello @Jamie_D,

The JSON structure is correct, this issue is now being taken care of by the development team, so I will keep updating you about the progress.
For now, the workaround is to delete the rule and create it again, please share with us if you had any issues with this process.
In the Rules API documentation you can see the other conditions available for rules.
Also, here are some posts with examples:

1 Like

Could someone explain what the current and future difference is between Rules API, Automation, and Smart Lighting App is?

I Thought they would have moved the Rules that are created into the Automations and vice versa but i tried creating a Automation and it did not turn up as a Rule in the API as i first thought it would, seem to me there is no way to visualize the Rules at the moment.

Will the Automations we create be automatically migrated over at some point or is it intended as something completely new?

Rules API is deep guts of the platform, futuretech now and Its shiny penny new. While its still missing some things (variables, local processing) you can do stuff here (like manipulate the scheduler) you cant do with any other supported methods…

Automations have no link to RulesApi at this moment.

SmartLighting is the old groovy smartapp but at the moment if you need local processing its the best way to get it because parts of it live in your hub.

RulesAPI will apparently provide the plumbing to eventually replace the local process capability SL provides now abd looks like it will be the plumbing underneath WebCoRE v.Next at some future point (reading between the lines of the publicly available info)

How’d I do @jody.albritton? :sunglasses:

Right i see that the Rules/REST is they way forward and being handled by some internal handler at the back-end but do we know if there are any plans for automatically migrating the Automations and Smart Lighting to the new Rules API at some point?

Still looking where its best to spend my time, hate to spend 200 hours on a part of the application that needs to be abended down the line, that’s all.

1 Like

They haven’t said anything public about future for either of those and we’re probably at least 6 mo away from getting comment from them. Although heres where I would speculate.

stuff below is pure wild speculation
Considering Smartlighting is groovy and does have to go away at some point brfore the IDE is retired AND its taking up space in firmware AND we know for a fact RulesAPI is both an adequate functionality replacement (not UI) for SL AND RulesAPI has a publicly announced future direction for local execution. I’d say that one is a safe bet. Id put money on a Smartlighting v.next coming at some point in the future which is a UI of RulesAPI.

Automation UI and associated objects, thats another bag. Theres a lot of investment in the existing code and I dont know what is backing it. Iy may very well be an internal only UI for Rules, and if so…

Appreciate that, guess i will keep things simple by using basic Automations until we get more information about the migration process and how they plan to actually integrate all these three parts in some form of updated UI.

While we are speculating I find it hard to believe they will shutdown Automations due to the large amount of users actually using it but how they plan on integrating or migrating them into one platform without merge conflicts between devices and rules will be interesting. don’t imagine a new platform Should have multiple UI for basically the same thing which is where we are at right now.

I thought it was intended that the Rules API would be migrated as Smart Lighting Rules but once I saw that my Rules was empty understood i was wrong and wanted to double check. Might be some technical design problem I’m cant see that stopped them from integrating the two, who knows, I´ll leave it be until next year…

It will be interesting to see where Automations go. I’d like to see them as simple Rules that only ever activate Scenes (which could be created on the fly in the editor). I find it baffling that Automations can currently run actions that Scenes can’t. I just don’t see why they need to be a thing in their own right.

I do note that, currently, capability presentations include definitions for how they should appear in automation conditions and actions, but whether that represents the future, or a repurposed recent past, isn’t clear.

1 Like

Couldent agree more, surely in the long term they would consilidate much of it into one UI. Just hope its not to spread out already making it impossible.

1 Like

That’s why I’m holding tight on WebCoRE for now. At least it has a publicly announced intent to use RulesAPI and Ady has a history of doing great things. (And I’m lazy and don’t feel like learning yet another interface at the moment.) I’ll give them a few months to get out of the current churn, see what gets announced and then make a decision when it’s more clear.

2 Likes

Not sure if this is the place to ask Rules API questions so please let me know if I should post somewhere else. I’m trying to create a rule with nested If statements and the behavior is not what I was expecting. Here is what I’m trying to create:

If
----{Button 3 on Controller Device equals pressed}
Then
----If
--------{Light Switch A equals On}
----Then
--------Do Something
----Else
--------Do Something Else
Else
----Do Nothing

The code is triggered as expected when I press Button 3 on my Controller Device. However the code in the second If statement is also getting triggered whenever the Light Switch is turned on. It is as if the code has subscribed to both the Controller Button 3 events as well as the Light Switch On events. Is there some way I can prevent the second If statement from subscribing to the Light Switch On events. I’m using DeviceOperand comparisons in both If statements.

I’ve watched Vlad’s “Create IoT Automation Using SmartThings New Rules API - Vlad Shtibin” video several times and can’t figure out what I’m doing wrong. His demo of the nested if starts at 31:40 into the video.

Take a look at this

I got really frustrated with all the changes last year (announced WebCore shutdown, EchoSpeaks shutdown, IFTTT pay service, to name a few), and haven’t been doing much with my SmartThings smart home. Peeking around the forum today and see that ST is still going away from Groovy and WebCore shutdown is looming.

I was hoping that by now someone would have re-written WebCore or something very similar using the new Rules API. Has this happened? Anyone working on it? @ady624 still out there???

I admit that I haven’t read through this thread in a while… can Rules API do the cool things that WebCore can (access JSON data, provide endpoints for other devices, etc… ). Looking at the Advanced Automations with the Rules API post… using JSON to “code” rules seems like a great way for another software tool to access SmartThings API but it doesn’t seem like a good way for a human to to create rules/scripts/pistons…

1 Like

SmartThings is supposedly developing their own web based complex rule builder

No. Can probably do this with a device and either SmartApp or Edge driver.

That’s exactly the intention

2 Likes