I am replacing two switches and have removed them from all groups, rules, etc. beforehand. However, the device pages still report that they're "in use by" two rules, but they're not being used by those rules. I have double and triple checked. What to do in this situation?
I have the same question. This has happened to me multiple times. I have even tried rebooting the hub to no avail. This issue isn't limited to Rule Machine in my experience.
This is a known issue I'm afraid and if you do a search you will find numerous threads about this.
Cloning rules can cause this as well.
I can't remember reading anything about a fix for it.
At the moment it's just grin and bear it.
If you have removed the device from all triggers, actions and conditions, that is the most you can do to remove the device from the rule. Unfortunately, the only way to get rid of it is to delete the rule and then recreate it. If you look at the rule's properties page, you will see that there are "old" options that still contain the device in question.
Most of the time this can be mitigated in RM by removing the device from all actions before removing the action itself or making other significant changes. Sometimes, as with cloning, it is just "stuck" there in an old, unused setting as mentioned above. In this case, it is harmless, but does make it less appealing to heed the "In use by warning" when removing a device (it is indeed a good idea to go through and remove the device from any apps before you complete the removal, though most will recover well enough on their own) since it may overstate the situation a bit.
Staff are aware of the issue, have indicated that it would be difficult to address, and have suggested what I repeated above as a way to avoid this in many cases. As long as it's not really in use, you won't have a problem (if it is, you will end up with a "broken action" in the current version of RM that you'll have to delete and re-create, or you could end up with an abandoned trigger that shows up with no text, cannot be removed, and whose only sign of life is an extra, orphaned "OR" in the trigger list, which they've indicated they'll change to display "broken trigger" in a future version that will presumably allow you to remove it...point is, remove if it it's actually in use, and there's no need to worry if it isn't really in use).
All they have to do is rewrite/overwrite the properties page completely when updating/saving a rule. Discard the old and overwrite with new.
In addition it wouldn't be hard to do the same within the device property page. They can write a routine that scans rules for the presence/in use of the that device when hitting "save device".
With all the reports of the hub becoming slow after a few days and these leftover traces of devices/rules/null values if you delete a device that is a rule, etc., it seems possible there are some memory leaks what not going on.
I trust the author of Rule Machine to know what's easily possible and worth this time, to say nothing of knowing how it could (or not) be done. Staff are certainly aware of the request. The advice I repeated above is the best I'm aware of to avoid phantom "in use by" references if this is important to you, and it's all we can do at the moment (avoid cloning, avoid swapping "Button Device" triggers, and remove all devices from any actions before deleting or significantly changing them).
They're a so aware of general hub issues for some and have suggested you contact support if you are experiencing problems (especially if you aren't running certain custom code known to be problematic for many) so they can figure out what might be going on.
It's hard to tell without having insight in the actual code. We're not just talking RM here. There are ghost devices, links, etc. in scenes, groups, and other app. All Hubitat apps by the way. I have been a programmer for 30+ years and certainly would be interested to assist if possible. Otherwise, data component organization and making sure it works correctly is a core functionality that, if not addressed, can lead to all kinds of other issues that are hard to trace and debug.
If you look at the properties page for one of your rules, you will see that it is not organized in the way that you are assuming it is. And since this is one of the most posted about issues with RM presently, if there were an easy solution I guarantee, it would have been implemented already. If for no other reason than to get the forum to shut up about it.
That would mean giving you access to Hubitat's code. And they don't do that. It is not an open source project. The software is their product and they have no interest in giving it away to people.
This is one you are just going to have to accept and move on. Or, not accept and move on. We have tried to explain why this will not be addressed anytime soon as best we can. I for one think we have answered you questions as much as possible. If you have other requests or concerns, it would be best to bring those up with Hubitat staff by emailing email@example.com
Me too, constantly. Plus they say it will corrupt the rule if device shows "in use by"
so we can't trust "in use by" so what are we supposed to do???
We all know about this problem. I've complained about it before, in other areas.
As @ryan780 suggested, the answer is:
"Grin and bear it..."
Until Hubitat management consider this issue to be a priority, it's not going to be addressed.