Is there a way to "comment out" a Rule line like "commenting out a line of code" in the old days?

OK, this may seem like a stupid question/request since there's likely some new way to affect this that I don't know about....but, here goes.

In the old days, when you were testing and playing around with coding approaches you could just "comment out" the lines you didn't want to be executed while testing things.

I find myself testing some variations of Rules and not wanting to CUT, EDIT, or DELETE any of them... but rather just IGNORE/DISABLE a couple for the time being until I figure out which variant does exactly what I want the way I want it.

What I am working on right now is trying to get POSTs or GETs to work to an Axis Camera via Rule 4.1. I can change if there's an applicable capability in a newer RM version.

Ironically, I finally got the right construct to make this work and I'm not sure which of the flipping lines (rule constructs) did it as I put EVERYTHING in there some time ago trying to get this to work ...and now it does for some reason. :crazy_face:

Thanks.

Addendum: Ha! To my surprise the initial replies to this are making me feel less stupid.

1 Like

I would love to see an option to comment out (disable) a line or two as well for things that are only valid for a time each year, like holiday lighting automations, but where I still want the rest of the rule to run year round.

1 Like

I have yet to find one (RM 5.0 or RM 5.1). I have wanted this for the ability to troubleshoot a rule. The ability to comment out something, run the rule to see if that line was the issue.

This has been requested many times before. Search for "comment out" and you'll find a few. The answer has always been no. In one of those threads, there is a trick mentioned that functions similarly. I don't recall the specifics, but it was something like send a notification to nothing.

Although the Note field is very useful, I too would like to place a comment right before a particularly complex set of actions to explain why I'm doing it this way. I sometimes look at my complex rules like a dog watching TV.

Actually, actually !!! I had worked on this rule so so long ago and gave up. Getting back in today and seeing my notes in the note/comment field on the overall rule had me really thankful that the Hubitat folks had added this ...and I was going to say something positive (for once :wink:) in that regard !

As an alternative in RM 5.1, you could use the new Cut command which would remove the line while you test. Then you could paste it back in the same spot afterwards. This will however only work when the lines that you cut are next to each other (as far as I know…)

4 Likes

Thanks.

1 Like

@Terk For holiday items, you could clone the rule, and have one with and one without this extra action.

Then in Predicates you could limit each rule to certain dates to run.

2 Likes

I tried that. With some cuts, in If...Then or Repeat..., after the cut I get a Java Error and the rule no longer lets me back in to it to edit it.

I always clone a rule before messing with the original rule. Pause the original rule, and edit the clone. You can do this cloning over and over again deleting or adding things as you go.

5 Likes

Works well to "park" entire rules like summer irrigation and holiday lighting. Maybe this is a KISS opportunity for him to break up a more lengthy rule.

3 Likes

Something to be careful about! If you are able to reproduce, it might be a good idea to provide the specifics to Bruce so that he may fix if possible. Ideal is to create a new rule with only the necessary in it and share a screenshot.

2 Likes

OK, I'm outta luck picking up a RM 4.1 rule and taking it to RM 5.1 right ?

1 Like

I have managed to do it several times with RM5.1 so I will see if I can reproduce it again and gather screenshots/steps for a bug report.

1 Like

They do not transfer.

However, you can still clone a rule 4.1. So unless you need predicates, you can stay with the older rules.

1 Like

Ah ha, never done this. Thanks.

Is the "backup database" warning that pertinent to cloning?

I would always have a recent backup available just in case. But simply cloning a rule shouldn't require backups every single time you clone. I would backup a known good state, and download that backup before futzing around, but otherwise you should be OK.

2 Likes

Make the very last command in your rule EXIT
Then cut & paste each line your want to remove (but keep) after the EXIT line; they will never execute, but remain handy.

2 Likes

In the 2.3.1 release, we will provide a Disable Action feature for Rule 5.1. This will allow any action to be disabled, or re-enabled from a dropdown. Like this:

You can see the first action has been disabled. Selecting it from the dropdown would re-enable it.

21 Likes

That's useful for the case of temporarily "commenting out" an action. But it would be nice if there was simply a way to put a comment within the actions as an explanation of why something that unusual works the way it does. For example

! Power cycle it in case it has dropped off the mesh
Off: WaterCop Valve Power
On: WaterCop Valve Power --> delayed: 0:00:04

1 Like