Advanced Automations with the Rules API

Thanks for the information. That seems very illogical to have something that does exactly the same thing but two separate instances / backends with no overlap or integration.

So I am guessing its also not possible to programmatically control ST App Automations via the API, but you can list devices via the API?

1 Like

Correct. The automation creator in the app existed before the rules api did. Hopefully at some point In the future the automation creator becomes a UI for the Rules API. But I think the rules api Is still missing some functionality that the automation creator supports.

2 Likes

I have question in “equals” statement in Rules API.

In your example above, there are two “equals” statements in the json.

Logically, It seems that, first “equals” is trigger, and second “equals” seems to be condition.
How does Rules engine differentiate ‘trigger’ and ‘condition’ in “equals” statement?

We have created a simple rule browser that shows how different rules would be structured. You can find it here:

1 Like

I know there has been promises of extending the Rules API to support variables and expressions in years past. However, I have not been able to locate any new information or examples using these new capabilities. Have any of these enhancements been implemented and are they available?

For example, I want to sync of the state of two devices - one is a virtual dimmer, and the other has the capabilities of a physical dimmer that can be controlled by a REST API call. The virtual dimmer is known to Smartthings, but the other device is not. I would like to build a rule that says when the virtual dimmer switchLevel is changed, so send an API call the other device with the switchLevel.

I have virtual dimmer added as a Edge device, and am using the Web Requester driver to send local HTTP requests. I built a simple POC rule that works for a specific value (ie, virtual dimmer at 100 changes other device to 100), so everything is wired up correctly. However, I dont want to have to build 100 rules (one for each possible value of switchLevel). I could build a rule using the between operation, but there could be a lot of possible options there as well. I was thinking an expression similar to getCurrentValue of the virtual dimmer would address the issue.

1 Like

Although I’ve never had to do it, you should be able to use the device operand (i.e. the one you’d use on the left or right of an equals operation) as the value of an argument in a command. The problem is having a command that takes that argument.

What you could do with is a variation on the @TAustin web requestor that works with a single URL with ‘printf’ style placeholders and lets you supply arguments.

Well OK what you need is to be able to build string expressions in the Rules but I suspect we are a way off that yet. There are all sorts of glue type things SmartThings know might be useful but I would imagine we are a lot closer to the beginning of the development cycle than the end. I am hoping for solutions that aren’t Rules specific.

1 Like

how about
if the door is left open for 30 seconds
wait and check in 30 seconds .

it’s very different scenario