How to reveal a *Broken Action*? Anybody else have a "source code" archiving solution for RM?

I have a rule that was written a couple of years ago but had been disabled for awhile since the sensor that it interacted was in the process of being replaced. Once I finally got around to fixing that sensor, the rule that uses it didn't seem to be running correctly.

Looking at the rule I saw a red **Broken Action** that indicated a problem that was probably the cause of the incorrect behavior. But the actual Action that I needed to fix was obscured by what was essentially an error message!

Since I wrote it a couple of years ago I'd totally forgotten what action might have been represented by this **Broken Action** and my memory isn't that great anymore - and I wasn't looking forward to reverse-engineering my own code to try and figure it out.

So I went thru the process of rolling back OS versions for my C7 as far as I could, to V 2.3.4.115, and also reloaded a database backup from 2022 when I knew the rule was still working. By doing these reversions on my live system, I was finally able to see the rule that had broken - and, inexplicably, fix it by simply re-entering the action from scratch. :roll_eyes:

If I'd had an archive, backup or other human-readable snapshot of all my rules at the "source code" level, the fix would have been much easier to identify and implement than the nerve-wracking and time-consuming process of OS and database reversion and then subsequent re-updating.

Is there some other technique I could have used to see my RM rules in the form of "source code"? In this case the error presentation in the RM editor interface obscured what I'd previously written. How do other people document their RM code in a more robust and persistent form? Should I be saving screenshots of all my rules?

A few points:

  • Rule Machine doesn't create "source code." It's just like any other app and performs whatever actions it needs to according to the configuration you've made in the interface. It just happens to summarize your actions in what might be described as pseudo-code.

  • If you want some "back up" of an individual rule, consider exporting it. See: App Status Page | Hubitat Documentation

  • As an alternative or addition to the above, I'd guess many users know what their rules are are supposed to do and could guess what the missing action might be--at least for small rules. :slight_smile: But with any rule, you can use the "Notes" field to type whatever you need to help yourself remember.

  • You can generally avoid this problem in the first place by heeding the warnings you get when removing a device (noting what apps are using it and recommending removing from or swapping out in all apps first).

4 Likes

Thanks for the tip about the rule Import/Export/Clone options - that's a feature I was unaware of!

1 Like

I think Bruce even added a comment tool as an action type a while back. Apperantly a handful of users wanted to annotate their "code" in the body of the rule. That was probably in RM4... not sure if made it into version 5. Bruce added it somewhat reluctantly, IIRC.

A couple of days ago I was playing around with my Tuya devices (Cloud based) with the Tuya IoT Platform (Cloud) driver where you need to create an account on iot.tuya.com site.

I was adding a new device I just bought to know the level of water in my house deposit.

Looks great but that is another story, besides it will not work on HE.

In my playing around, my Tuya devices (around 8) resetted to like just added into HE, so the system behaved like if they were deleted and then re-added.

All my Tuya devices rules were broken, (around 10 rules), so I had to reconfigure each one of them.

It was fairly easy by using the option on the Rule Machine menu, Find broken rules, besides the fact that I had used the Comments option on many of them, so I knew what device I was configuring.

1 Like