Feature Request: Add Rule Machine "In Use By" List

Can an "In Use By" list be added to a Rule's details? This would be a list of other rules that are somehow taking an action on the rule being viewed. Could be in the rule information page or at the bottom of the main rule page, doesn't really matter.

For example, if "Rule B" has a command to Pause or Resume "Rule A", then "Rule A" would have "Rule B" in it's "In Use By" list.

Rule A Details:
In Use By:
Rule B

This would be very useful to keep the continuity of how things work when a rule needs to be replaced, just like when replacing a device. When the new rule is written, before deleting the one it replaced, you check whether other rules are using the existing one, and if so, go to those rules and change the reference to the new rule before deleting the existing rule.

How does this come up:
I just updated to platform version 2.4.0.144 from 2.3.9.200. Somehow in the process, the existing Hue Bridge Integration App refused to load after throwing an error every time it was clicked. I was able to fix the issue by creating a new Hue Bridge Integration. The new integration detected and loaded all the Hue devices just fine. However, this results in 2 sets of all the Hue devices (I have 35 of them). I then needed to change the references to all those Hue devices in all the rules and dashboards. This would be easy if the Hubitat "Swap Device" application would allow a systematic change of a Hue linked device, but it doesn't. So the quickest way to not have to go into each rule and select up to 35 alternate devices in each action inside of each rule is to Clone the rules rule that reference any Hue device. Cloning allows every reference to a Hue device in a rule to be systematically replaced, albeit rule by rule. While this is painful, it's better than having to select the replacements action by action within each rule.

This results in a new cloned rule that uses the new correct Hue devices, but now any other rule that controlled the original version of this rule still references the original rule with the old incorrect hue devices. I happen to have lots of other rules that pause and resuse these rules. So now I will need to go into each other rule to see which of them might be taking an action on the old rule and change the reference to the new cloned rule...All of this is hours of re-work...

So simply having a list of all the "In Use By" rules would make this a little less painful.

Another thing that would make this a lot less painful would be to allow the Hubitat "Swap Device" application to select Hue devices for a swap. Then there would be no messing within the references to the devices in the rules or the dashboards etc. at all...

2 Likes

Forget who I wrote this app for, but it may be useful in this situation:

Edit: Found the original thread Rule table available?

Thanks for the suggestion!

The linked app seems to be showing the devices associated with each rule, which is a nice convenience to know in one place, and could be useful sometime, and I will keep that, thanks!

However, I'm looking to have something like this that shows what other rules are referencing / controlling a specific rule.

I looked in the details page of what would be "Rule B" in my example above that is pausing and resuming "Rule A", and it seems that the details page does list the rules that are being paused and resumed. The page looks like this:

Settings:

Name					Type		Status
...
pR.20					bool			true
pauseRule.20			enum		["601","600","598","597","596","595"]
pauseRule.3				enum		["601","600","598","597","596","595"]
pauseRuleType.20		enum		Rule Machine
pauseRuleType.3			enum		Rule Machine
...

Where 601, and 600 in that list are the id's of the Rule Machine Rules that "Rule B" is controlling.

Any way to contort the code you wrote to list all the Rules that are referencing "Rule A". So for example here, show the name of rule 600, then all the names of the rules that reference rule 600. This would be the nicest as it aggregates all the rules referencing a specific rule.

However, if that's difficult, a table like the one you created for devices, where each rule is listed in a column, and then in the next column, a list of all the rules it controls would be more helpful than the method of searching through each rule that we have today.

Thanks for the help!!

Iā€™ll look to see if that is captured within the app states. If it is I may be able to pull it out.

Edit: Have identified the pattern and think that I can use that to build your table.

3 Likes

One more app to see out 2024!

3 Likes

That's Great!!

Let me know if I can test anything.

1 Like

@Automatican this should be close:

https://raw.githubusercontent.com/thebearmay/hubitat/refs/heads/main/apps/ruleRruleList.groovy

1 Like

I tried it--and got:

I know what that is ā€¦

2 Likes

v0.0.2 is up

3 Likes

Is it HPM yet? :rofl:

2 Likes

Not yet, LOL

1 Like

That fixed the error! Thanks!

It doesn't seem to be finding all the usages, tho. I haven't dug into things much tho.

Thanks!

If you find one that it misses if you could send me the output of

http:\\<Hub IP Address>/installedapp/statusJson/<app ID>

in a PM Iā€™ll see if I can find what breaks the pattern

1 Like

Thanks for the work on this!!

I installed and ran it. It produces a nice table of all the rules with the output pattern indicated below. For each rule in a row, it does pick up some of the rules being adjusted by that rule, but not all.

For example, for a rule number 583 that I have, it produces the following output in a row:

Rule Name:
{RULE NAME}(583)

Rules Run:
570, 587, 589

Related Rules:
{RULE NAME}(603), {RULE NAME}(749), {RULE NAME}(751), {RULE NAME}(625), {RULE NAME}(722), {RULE NAME}(720), {RULE NAME}(624), {RULE NAME}(718), {RULE NAME}(623), {RULE NAME}(716), {RULE NAME}(622), {RULE NAME}(621), {RULE NAME}(620), {RULE NAME}(608), {RULE NAME}(606), {RULE NAME}(604), {RULE NAME}(758), {RULE NAME}(732), {RULE NAME}(601), {RULE NAME}(697), {RULE NAME}(600), {RULE NAME}(699), {RULE NAME}(599), {RULE NAME}(598), {RULE NAME}(701), {RULE NAME}(597), {RULE NAME}(703), {RULE NAME}(595), {RULE NAME}(705), {RULE NAME}(443), {RULE NAME}(444), {RULE NAME}(445), {RULE NAME}(446), {RULE NAME}(447), {RULE NAME}(442), {RULE NAME}(448), {RULE NAME}(449), {RULE NAME}(453), {RULE NAME}(581), {RULE NAME}(660), {RULE NAME}(450), {RULE NAME}(451), {RULE NAME}(760), {RULE NAME}(639), {RULE NAME}(729), {RULE NAME}(579), {RULE NAME}(733), {RULE NAME}(504), {RULE NAME}(578), {RULE NAME}(596), {RULE NAME}(587), {RULE NAME}(589), {RULE NAME}(571), {RULE NAME}(725), {RULE NAME}(569), {RULE NAME}(568), {RULE NAME}(570), {RULE NAME}(572), {RULE NAME}(573), {RULE NAME}(631), {RULE NAME}(582), {RULE NAME}(584), {RULE NAME}(590), {RULE NAME}(591), {RULE NAME}(592), {RULE NAME}(594), {RULE NAME}(441), {RULE NAME}(609), {RULE NAME}(610), {RULE NAME}(611), Set Thermostat Heat/Cool Mode 1st Floor(574), {RULE NAME}(577), {RULE NAME}(479), Set Thermostat Scheduler for Leave Temps(483), {RULE NAME}(475), {RULE NAME}(477), {RULE NAME}(693), {RULE NAME}(644), {RULE NAME}(654), {RULE NAME}(602), {RULE NAME}(640), {RULE NAME}(652), {RULE NAME}(503), {RULE NAME}(665)

The Related Rules column seems to be a listing of all the rules I have, and most of them aren't actually related to rule 583.

The Rules Run column is picking up 3 of the rules being adjusted by rule 583, but not all 4.

The Settings screen for rule 583 has these items in it:

Name Type Value
... ... ...
pR.3 bool true
pauseRule.3 enum [587,589,570,584]
pauseRule.8 enum [589,587,584]
pauseRuleType.3 enum Rule Machine
pauseRuleType.8 enum Rule Machine
rCapab_3 enum Switch
rCapab_7 enum Switch
rDev_3 capability.switch [Virtual Switch Name]
rDev_7 capability.switch [Virtual Switch Name]
ruleAct.14 enum [587]
ruleAct.19 enum [589]
ruleAct.6 enum [570]
runRuleType.14 enum Rule Machine
runRuleType.19 enum Rule Machine
runRuleType.6 enum Rule Machine
state_3 enum on
state_7 enum off
... ... ...

Rule 583, depending on the If /Then conditions, Pauses 3 rules. Resumes 4 rules, and runs the actions of 3 rules, as can be seen in the table from the settings page pasted above.

Any idea, what it might be doing?

New pattern! v0.0.4 is up to catch, also eliminates the third column.

3 Likes

I'm super excited about this....

This appears to list the rule appids (on the right) that are called by the rule on the left column.

Any chance of being able to flip that around? Specifically--list all the rules on the left, then list all the rules calling that rule on the right? My big use case is along the lines of "So, I need to move this v4 Rule to a v5.1 Rule and need to know everything that's calling it"??

Thx!!

A little more work to do it that way due to the way the data is stored, but certainly doable. Probably gonna be a few days before I can get back to it though.

3 Likes

That isn't a problem at all... I'm super appreciative that you took a look at this!!!

Happy New Year!!!

1 Like

Had some quiet time while everyone is catching up on their sleep, v0.0.5 is up with both tables.

4 Likes