First rule attempt simple Q: Postman or CLI?

Hello, new to Rules and not really a coder although I’ve successfully modified edge drivers and uploaded w/CLI…

My question is - to get one “simple” rule working (described below), am I better off figuring out Postman basics, or should I instead focus on CLI as the tool (presumably using Visual Studio to edit/generate the JSON file)?

I started with the intro docs here (… and got stuck at the initial Postman phases (Obtain Device IDs, Location ID and location Mode IDs for use in Rules) - since I’m new to Postman and find I’m guessing how to do these simple steps without much initial success. Simple stuff like… do I select “new API”, where is that “authorization window”… Most of the instructions here I found so far assume some basic working knowledge of Postman that I lack.

Add’l Background: Rule description - The rule I want to create will monitor two physical devices (power meters) for a change in power/energy values, and on a change add the the two physical meter’s values together and write that value to a 3rd virtual meter. (I currently do this via Sharptools and would like to migrate that function to a Rule if its fairly straightforward for me to do so.)

Hey George,

I feel your pain. It took me hours of trying to follow the github instructions to get started with postman before i realised that i actually had to replace the Location ID in the link to my actual Location ID. I’ve been playing with it for a bit now and seem to have it down pat and i have no coding experience at all so it can be done.

My work flow is like this

  1. open postman and select the workspace drop down (top left) and select a workspace

  2. select new in the workspace area (top left again) and choose HTTP

  3. Generate a token here. copy and paste to a document

  4. Visit this API browser. here you’ll find all the ID’s as well as all the capabilities etc of all the devices you have. you can also view and manage rules that you post from this browser

  5. paste LOCATION ID HERE into the browser bar next to the send button. if this is the first time posting the code to ST, change the drop down to the left of this bar to POST

  6. under the browser bar there is a heading named AUTHORIZATION, click this and then click on the drop box next to the type heading. here you can select bearer token. paste your token int the token field.

  7. select the heading named BODY (to the right of the AUTHORIZATION heading) then select RAW and then JSON from the drop down box that will appear to the right of the headings.

  8. below the headings is a split screen. the top area is where you enter the code and the bottom is the response are. once you’ve entered the code, hit send and if everything is good it will say 200 OK in the response screen and post the rule to your ST hub

sorry I can’t post pics and the description isn’t the best. if I can be of any help just let me know.

oh also, you’ll need to enter your token into the API browser as well

There is probably a lot to be said for learning to use Postman but I never have. It holds my personal record for sites that I have deleted my account from.

If you are using JSON then another option is to use your own choice of JSON editor if needed and paste into Todd’s API Browser+. That’s what I use if I am away from a laptop. You might want to arrange your own backups though.

I mostly manage my Rules using VS Code as the YAML editor and the CLI to interact with the API, with a bit of help with batch files and a make file. I’m sure I could resurrect my once fluent knowledge of Unix shells and text tools if I really wanted to but as my Rules are years old there isn’t a lot of incentive. I don’t particularly like VS Code and only use its most basic functionality but it does a job.

When using the CLI I strongly recommend using a Personal Access Token for Rules as that means they can be accessed by any member of the Location using any tools authenticated by a PAT. If you use the default authentication in the CLI the Rules have to be managed by the original creator using the CLI. It was not ever thus, but it has been like it for long enough to accept it isn’t going to change.

I’ve yet to explore generating Rules in other languages, again through lack of incentive.


The problem here is that I can’t see the way you will be able to do this. Would love to be proved wrong by someone.

Well that someone won’t be me as I can’t see how you would do it either. If you can do it then I am completely unaware of it.

I was going to say ‘blissfully unaware’ but I remember the last quarter of 2019 and all the talk of developing the Rules API to provide webCoRE levels of functionality, and now I look for the visible signs of that development and I just don’t see it. Refinements of what there was, yes, but not really anything new. Although it would be fair to say that there was zero movement from the webCoRE community when it was proposed they migrate webCoRE to use Rules, there was also zero evidence of there being anything at all for them to migrate it to.

The native ability to do arithmetic and string expressions would seem quite handy, but if it is already there it has escaped my attention…


Would seem the minimum to have as a way of giving more potential to rules, but as you say it’s disappointing that in over 2 years nothing new has shown up. The arguments function doesn’t seem to have anything, apart from being, as far as I know undocumented. I opened a report there but don’t have much hope.
The NumberField utility by @Mariano_Colmenarejo allows writing a compared value and then retrieving later, while @TAustin 's Timer utility has reset options that are useful, but I don’t know of anything else.

I haven’t really looked closely for a while, as even if there is anything new there isn’t any guarantee that it will ever make its way to the public API. There is fundamental stuff that Routines have been using for three or four years that haven’t got that far and it is a kick in the teeth really. It rather looks like there are isEqualAfterInequalityInterval and isEqualForAtLeastInterval conditions I haven’t come across before (they could easily be refinements of remains and was to better fit in with the naming conventions) and various fade actions which I guess might somehow tie in with the synthetic fade and circadian capabilties.

In an attempt to bring this thread back on track, to @georgeh I would say that the advantage of using Rules directly is largely confined to the ability to have multiple nested if-then-else statements and largely arbitrary and-or-not constructs, plus finer control over things like triggering (e.g. you can device whether or not a greaterThan condition triggers the rule whenever it evaluates as true, rather than only when it changes from false to true as happens in Routines). Otherwise you probably won’t find anything in the public Rules that the Routines aren’t already using. Which is a crying shame.

1 Like

Thanks everyone for the all the feedback. Guess I assumed something as “trivial” as addition was possible via a Rule, but it looks like I first need to dig into that more before worrying too much about Postman/CLI.

Ah, for the good ol’ Webcore days. (Yes I’m aware of that option via Hubitat.)