Rational for the Rules API language syntax

The Rules API seems to be a cross between a traditional language and the JSON data format. Basically wrapping data and language elements inside JSON brackets. I’m wondering what the rationale behind this is? How does this help other than making the code very long and hard to read? Has Smartthings talked about why they chose this approach?

2 Likes

paging @vlad

1 Like

JSON is the data format used by the SmartThings API so I can’t see why the Rules API would be any different. JSON is pretty unreadable whatever you do with it and yet it is ubiquitous.

It is actually a lot easier to read Rules if you use YAML instead, though YAML is a lot less forgiving over formatting (probably a good thing).

I’d also advise caution in using the words ‘traditional language’ in any way in connection with Rules. I find the less you think of it like a script the better.

I get worried when it is compared with webCoRE. It always seems more like Smart Lighting in approach to me.

If the Rules API was just accepting data I would agree that JSON would make sense. However, the Rules API is inputting logic which I am not sure makes sense to use in a data format. (Just so you know my background is in computer science.) It seems to me that this may be a case of just because something is popular it’s being used for a case where it might not make sense? If you have a hammer everything looks like a nail…

Its expresses rules of logic, aka an algorithm. What is what a computer language expresses. I see nothing wrong with this comparison.

1 Like

I would say ask Adrian Caramaliu for an explanation since he was one of the devs working on it, but it looks like he isn’t at SmartThings anymore as of November and he no longer has an account on this forum😕

1 Like

Oh, wow, this looks to be gone: Profile - ady624 - SmartThings Community

Sounds like a purge is happening… Blake Arnold, Adrian and there was another long timer about a month ago or so

Probably not specific to SmartThings would be my guess. With the Great Resignation going on, many people are changing jobs (myself included). What is concerning is the ones I know of were leading or championing cool things like Edge, Rules API, etc. so hopefully those projects don’t lose momentum.

1 Like

It’s more annoying for them to disable/delete the community accounts for these people. It means you can no longer search for webCoRE postings by ady642, since you can’t search on that username anymore.

1 Like

Writing an automation code with yaml(or json) is definitely not easy.

I think it’s made of json, because yaml(or json) formatted code is much easier for ST servers to import, because they don’t need to be parsed with lexical analyzer like regular programming languages.

HomeAssistant uses similar yaml automations like Rules api.

I don’t know anyone who is using this API besides basic examples .

I still hope ST team will allow to run LUA for local automations, because now the border between device handler and rule is blurry. And developers add capabilities (like circadian lights, wake up dimming and other) into the driver code via simple copy-paste.

1 Like