RMUtils.getRuleList('5.0') issue

RMUtils.getRuleList('5.0') seems to have stopped working for me since same on

null is getting returned for each rule. It was working fine.

Any ideas @bravenel ???


Nothing has changed with this recently. Put in a log.debug to show the list being returned from getRuleList. Post a screenshot of that here.

I use this API in my GCal Search app to run RM rules based on Google items found. This API is working fine on all the latest releases for me.

Must be something with your hub.

Partial Code is....
def executeRM(displayName, onoroff) {
def rules50 = RMUtils.getRuleList('5.0')
log.debug "In executeRM for $displayName --> $rules50.each"


This looks more like a problem with this line of code. If you just want to print the collection, Groovy will convert it to a string just fine on its own with $rules50. If you want to do something with each, then you'd be looking more for something like this instead:

rules50.each {
  log.debug "--> $it"
1 Like

That log.debug was just to display what the RMUtils.getRuleList('5.0') was getting.

Yes, in my real code I test each rule using it similar to what you show.

My app was running perfectly until

Interesting, but like @ritchierich, this is still working for me in one of my custom apps. Are you able to write a compete but minimal app that reproduces the problem? For example, this one:

import hubitat.helper.RMUtils

    name: "Demo - RM API",
    namespace: "Test",
    author: "Test",
    description: "Demonstrates RM/Rule 5.x API",
    category: "Convenience",
    iconUrl: "",
    iconX2Url: ""

preferences {
    page name: "mainPage"

def mainPage() {
    dynamicPage(name: "mainPage", title: "Main Page", install: true, uninstall: true) {
        def rules50 = RMUtils.getRuleList('5.0')
        log.debug "$rules50"
        section("Rule List") {
            paragraph "Rule 5.x rules: $rules50"

def installed() {
    log.trace "installed()"

def updated() {
    log.trace "updated()"

def uninstalled() {}

If not, something else must be going on in your code.


Thank you, that helped me solve the issue.

log.debug "$rules50" showed all the rules, whereas "$rules50.each" gave me nulls.

My issue was in comparing strings after retrieving the rules. In my comparison I have the word "on" and the word "off" - I changed these to "On" and "Off" (capitalizing the first character). Prior to the comparison was working even thought "on <> On". Something must have changed to tighten up things!!!!

Again, many thanks, my app is working now as before. -Simon


FWIW I have always put ${} around variables in string statements. I have seen issues and other community members report issues if they don't so it has become a habit now.
log.debug "$rules50" becomes log.debug "${rules50}"
log.debug "--> $it" becomes log.debug "--> ${it}"

Yes, this is why I suggested the two specific alternatives that did.

Yeah, this never hurts; there are rules for how interpolation works if there would otherwise be ambiguity, and...I don't remember what they are. :slight_smile: So, I always use them if the expression uses dots or anything complicated, but a single expression like $it should always be OK. Of course, their omission is optional, and it's not a bad habit to just use them anyway!