Rules API vs. Routines

I have been exploring the Rules API for my new home automation. I want to lean that way because I’ve seen that there is a finite limit to routines. So I hope (naïvely?) that the limits are higher and maybe the respones are even faster than routines. I’ve been a coder most of my life (since CP/M. I actually enjoyed programming in assembler when the need arose.) so the thought of writing JSON for rules doesn’t scare me. Perhaps it should. I just want simple things to happen and have a NIH mindset. I am going full steam ahead with my Z-wave devices as I also plan to make the aluminum wiring in my new house safe.

I am setting up a development environment to facilitate my rules generation and then I hope to plunge in this coming weekend. That is, unless someone takes pity on me and gives me a good reason not to go this route.

Anyway, thank you for reading this. I hope I’ve made myself clear enough with my intentions. I realize I didn’t really ask a question but I was hoping to spark a conversation with some community members who have gone before me.

Peter

5 Likes

I too am in the process of learning the Rules API and converting over routines and making more complicated rules. I look forward to see what you come up with.

1 Like

It is quite likely there is one for Rules too. Unfortunately the Guardrails and Rate Limits document isn’t particularly user friendly and the figures that are there don’t seem to match reality. The 200 limit for Routines doesn’t match any number in there, for example, and the limit of 10 Locations per user isn’t in there either (it seems to say 50).

For Rules it suggests an install limit of 100 for ‘User’ and 50 for ‘ISA’. Beats me what they are on about but I seem to remember another user hitting limits.

I haven’t hit any limit yet because I only do a minimal amount of automation in a small property, and also because not all the existing Rules have made it up to the public API or been documented if they have. So I would perhaps be flirting with 100 if they had been. I consider 500 to be the minimum that would be realistic but I am not sure that a single limit makes sense if they spread across multiple hubs and the cloud.

That’s great. It’s good to have someone to bounce stuff off of. Or brag about how clever you feel you’ve been (when it really wasn’t being clever, just solving a problem that was kicking you in the rear end). I will try to start on that in earnest (I have a paying job I must go in to that get’s in my way for the IMPORTANT things :grin:).

Peter

I have worked this weekend on learning the Rules API using Postman. I can see why few people have gone down this road. However, I view this as an opportunity to craft some crude tools to ease the development and maintenance of Rules, at least until SmartThings devices its own method. I am trying to make up my mind which language or platform I want to use. I’m familiar with NodeJS but I haven’t delved into any web page designs. I’m not particular gifted in artistry (and I think web layout can be more an art than a science). I did something similar about twenty-five years ago in C++, but, UGH I haven’t looked at modern C++ since then. Lastly there’s VB but the same thing applies there. But I need SOMETHING if I go down this route. (What I really need is to retire so I can work on this hobby full time, but that doesn’t pay well at this time).

I just wanted to update you on what I’ve accomplished. There’s been a lot of learning and little to show for it. I’m to the point that I can get a 200 response when I create a rule, but I can’t seem to see that rule so I’m missing something somewhere.

I will dabble with it some more this week when I’m home and jump on it a bit more next weekend.

Be blessed and have a great rest of the weekend.

Bear in mind that if you use an authtoken from an “installed app” when creating the rules, only that installed app can see the Rules. Similarly if you used PAT route, you’ll only see the Rules when using a PAT.

I’m in the process of converting many if not all of my routines into Rules, in part out of curiosity, but also because I would prefer to have those rules available to me outside of ST should the worst happen.

Looking at the rules that remain for me to work on, I’ve been trying to figure out how to use systemSecurity in conditions and commands, create notifications, and access the same weather data (temperature, primarily) that the routines do. So far, I found only limited information systemSecurity, and nothing at all on notifications or weather. If anyone is aware of any links to documentation or examples (json or yaml) for those tasks, I’d really appreciate the help.

FAQ: Getting Started with the new Rules API - #112 by orangebucket shows the Security Mode handling in YAML. I’m trying to remember if I’ve used the securitySystem capability directly in Rules. Possibly not as I only use it to expose the Security Mode.

I’ve had absolutely no luck with notifications, not even basic ones. I’m not convinced they are even available outside of Routines at the moment and it infuriates me. I don’t want to have any Routines or Scenes as they get messed with and I want my code to be left alone.

I don’t think I’ve played much with the weather stuff but I might be able to figure it out.

Okay, that helps. Based on the documentation, I would have never come up with that.

That’s strange. I suppose I could use webrequestor to get a Pushover or Hubitat notification, but one would think there has to be an something to allow notifications within rules. @nayelyz ?

My assumption has been that it was another “location” capability like mode or security, but without the proper documentation, it’s frustrating to constantly have to guess.

That is correct. The Location attributes are:

  • FineDust
  • FineDustIndex
  • Humidity
  • Mode
  • Security
  • Temperature
  • TemperatureC
  • TemperatureF
  • UltraFineDust
  • UltraFineDustIndex
  • Weather
  • WeatherAlertSeverity

However you rather need to know the possible values when it comes to the Weather. I have a suspicion that it could be as basic as:

  • Rainy
  • Snowy
  • Cloudy
  • Clear

Is that all documented somewhere? I’ve looked more than once, but never found it.

It is in the API reference. You have to pick an API call that takes a Rule as input or returns one or more Rules as the 200 response (so create, update, get, or list) and start drilling down. So you start with the actions, then an if, then pick anything that does a comparison e.g. equals, then choose either left or right, and then you choose location. So actually the same information is in the API reference many, many times.

1 Like

Thanks, I’ll have to take a look, although I admit I hadn’t yet got around to looking for weather yet, just security, scenes and notifications. And on those subjects, I either didn’t find what I was looking for, or in the case of security thought what I did find was misleading. But, I’ll dig again just to be sure I’m looking at the documentation the right way.

Hi, sorry for the delay. I asked the team about this but I haven’t gotten a response yet.

1 Like