RM 4.0 Rule Questions and Optimizations

Iā€™m curious how youā€™re using those switches in other rules. It appears that all of the switches will be turned on at the current illumination levels. Is that your intent?

I'm in the same boat as you...when I first saw RM 4.0 I was a little pissed off actually. I'd spent all this time learning RM and now it has completely change?!? I'll have to learn all this sh*t over again?!? But after diving in a little deeper, it is actually a LOT more similar to WebCoRE now. I just had to dust off all my old WebCoRE logic and it all just fit. Anyone coming over from ST that is used to WebCoRE will find RM 4.0 a LOT easier than RM 3.0. The concept of Events and if-then-else statements rather than true-false is a lot more aligned with how WebCoRE functions. Plus, I find it much easier to do things all in one rule rather than have 5. That way, if i want to make a change to something, it's all right in front of me and I don't have to remember to go change 2 other rules too.

1 Like

Everytime the Lux level changes the rule is evaluated. If the Lux level is less than 30 then all the virtual switches that I want on will be on and will remain on. All the switches that I want on if Lux is below 30 will be off. This screenshot was taken when the Lux level was 0 so they would all be on.
As an example I want my bathroom lights to turn on when Lux is below 65 as the window has no obstructions for natural light. My EN Suite has a tree close by so is normally a bit darker so I turn these lights on when Lux is below 80. I use 8 different levels through the house. As said above if my Lux Sensor dies I only have to change one rule not 10.
Also if I want to test a rule using one of these virtual switches I can manually turn it off and on without having to play with the rule.

Anyone?

Is it possible to set dimmer level to a value of a global variable?

yes. use %globalvariablename% for the dimmer value. That, of course, assumes the global variable is the right variable type (aka not a string).

Thanks, is there a way to perform some simple calculations on a variable? I could do something like this in WC:

image

Certainly you can do min, max, and a number of other comparitors with IF comparison. In terms of manipulating a number (say, subtract 15 from it... or multiply it by 10...), I don't know. I always use custom user apps for that stuff instead of RM.

Sure, that's what I used WC for :slight_smile: However, apparently, it's scoffed at around the hubitat community, so i am trying to be a good citizen and migrate as much as possible to RM, and keep running into these small things that were really easy with WC and takes at least some thought with RM.

There are many that like Webcore on here. HOWEVER, there were many issues early on in Hubitat running Webcore on the hub causing many issues, lockups, etc. so most people chose to go other routes rather than take the chance of hub inistability.

WC on HE may be better now, I haven't tried it in ages, as I find it just as easy to write a 10 line groovy app as I did to do it in webcore.

any pointers on how to start with writing groovy apps for hubitat?

There are some good examples on these forums. And the SmartThings user app creation documentation is 95+% applicable to HE groovy apps. That is where I started.

Hubitat also has a few example apps on their github that can be a nice reference when starting out.

All that said, there may be a way to do variable math in RM, too. I just haven't tried.

I still use webcore for some very pointed things that HE can't do natively (I don't know groovy either). But I've got it paired down to only one piston now. Here are some tips for webcore:

  1. Don't use ANY global variables inside WebCoRE. NONE. If you do, every time a global variable changes, every piston that has any global variable in it will be called the number of times that a global variable appears in that piston. I saw once, when i first migrated, 30 piston executions in a second and a half. That hosed my hub but good.
  2. Don't trigger other pistons. Keep everything contained within one piston at a time.
  3. Do it in RM if you can. The fewer pistons you have the better. Only use it like a scalpel, not a bludgeon.
  4. Watch out for loops. ST could handle small loops in your pistons without a problem. HE cannot. At all. Any recursive looping will lock up your hub quickly.

If you stick to those rules, WebCoRE will run without a problem. I haven't had a hub lockup from webcore in almost a year.

thanks, that's very helpful. I do have a few global vars and do call other pistons, since I migrated those from ST. However I don't have a problem with the hub locking up. My pet peeve with WC is that its dashboard is still webbased, and today, for example, I had a weird issue with my internet, so WC appeared to be hosed.
Thus I am looking to migrate as much as possible to the RM, however there should be better ways of doing some simple stuff, like maybe local vars, or math calculation on vars, etc, which RM either lacks or I can't find any pointers how to do that.

You can also set up the editor to run on a local web sever. I'm running mine on a Raspberry Pi.

hm I have synology that runs 24/7, is it docker'able?

Is there any way to reorder/rearrange stuff in the actions section of a RM4.0 rule?
If not i would really like to request this functionality.

//BR and thx for an awesome application

Yes, there are math operators available. Look in the action called Set Global Variable.

Also allows math with constants, in addition to variables.

2 Likes

You can delete individual actions and you can insert actions into the list. There is no way to move an action from one place in the list to another. Our app UI framework doesn't lend itself to drag and drop type actions, so it's a bit limited due to that.

Okey, guess i need to jolt down my rules prior to making them in RM :wink: so i dont need to redo them.

Thanks for your quick answer.