Swapping devices in apps (offshoot of: "Add RM to In Use By")

FWIW, the culprit behind this problem has been fixed in build 145, released yesterday.

This isn't specific to Hue, and there are no plans to change it, at lesat at the moment. The underlying issue is that these are child devices (of a parent app or parent device, app in this case), and swapping a child device out from under a parent that is likely to have specific expectations about that device's properties is ripe to cause problems (and did with some devices in internal testing). This is is the expected, as-designed, and documented behavior: Swap Device | Hubitat Documentation

I see what you're saying, but the Rule Machine app Cloning process already allows a form of "Swap Device" when we select the devices to be used in place of the old devices. Whatever that Cloning process is, should be enabled as a choice across all the rules without having to actually Clone each rule and manually select each device to be swapped. So this can't be a platform limitation, but an implementation limitation.

Same for Dashboards, let their be an option to swap the Device across all dashboards.

No need to "Swap Device" for the Hue Integration itself, just where the devices are being used in non-hue activities.

Of course without this existing limitation, we wouldn't have asked for and @thebearmay actaully created this very useful App, but none the less, that capability to swap across the Rules and the Dashboards should be implemented.

2 Likes

Right, that is an entirely different process that just replaces the value of one setting (or multiple) in that app with another value, the values being the selected devices.

"Swap Device" is a platform-wide feature that works at a fairly extreme level, essentially swapping the hub-assigned device IDs of two devices in the database. This has an effect across all apps, drivers (if a parent/child), etc., and it can cause the problems above in some cases. The app-specific swaps you'll see with clones or imports don't, though some apps may still need reconfiguration after the fact if they depended on specific device details (e.g., that hub-assigned device ID) or other things that would have been changed with such a swap.

This isn't a "Rule Machine cloning" process, by the way; it's a platform-level feature available to all apps (except a select few that are excluded from this feature if it doesn't make sense). Some apps did originally have an in-app clone that worked differently to produce a similar outcome, including RM, but those have all been removed since the introduction of the platform feature, which seems to have grown out of this request.

A clone or export/import will do this, at least for legacy Dashboards. I tested this process when it was new, Dashboard has special tricks that prevent even my scenario above from being a problem here. I'm not sure this works on Easy Dashboard, the app likely being little more than a frontend for lots of this functionality that is just baked into deeper parts of the hub, so it may be an interesting request for that.

It doesn’t matter, from the users perspective. What matters is a failed Kasa being replaced with a Leviton or a Lutron switch being changed to an Inovelli 2-in-1 and not having to expend considerable effort fixing everything because of some technical reason. But this is going off topic so I’ll stop here.

The other thing this new app highlights is how it would be useful to have refcounting of rules and have the cloning process take those references into account as well as devices.

1 Like

I'm rather confused by your and @Automatican 's comments and @bertabcd1234 's replies.

This thread (and @thebearmay 's amazing effort) has been all about figuring out which RULES reference which other RULES.

In your last comment, you were talking about DEVICES--a wholly unrelated matter.

And, as others have mentioned, there are different things going on with swapping devices. When pairing/creating a new device, there are some "replace device" options. Then, totally separately, when cloning, etc. a rule, you can swap devices within the new rule.

When adding a new device, you can't do the swap, afaik, if either device has parent/children--which makes some sense, because there are some internal things that will get all hosed up if you rip a child out from underneath a parent.

However, when it comes to replacing Devices, there are some decent tools for manually doing that. Specifically, the list of places where the device is being used in the device information itself:

If you need to swap out a device that's in a parent/child relationship, I'd recommend:

  1. Add the new device as a new device
  2. Open the OLD devices (parent and children). Go into the "In Use By" page, open up all of the listed rules, then manually change the old devices to the new ones.

It's a bit of a PITA, but that should do the trick.

The issue in this thread, with what RULES are "in use by" what RULES--is there has never been anything even close to this before. So, if you are (say) needing to replace a RM4 ("legacy") rule with an RM5 rule to take advantage of some new feature, it was insanely difficult to do--you literally had to open each rule, each app, etc. and read each line to see if anything referenced the old rule, then you had to change it.

If you missed something, you'd have "broken" rules that could fail unexpectedly.

1 Like

Oops, you're right--I got the @ reference mixed up (and corrected).

It was, however, your last comment about switching devices out that I was commenting on. Along with a couple other replies about device swapping (which I tried to clarify also). Thanks!

The rest of this reply is off topic from the App that was created by @thebearmaym in helping to solve one of the problems identified by the original post. The new App created does a great job of helping figure out what rules are being manipulated by other rules, and this type of identification isn't generally available in any other way than looking into each rule for what rules an individual rule may reference. So this App created by @thebearmaym is a great help in general!!!

However, this thread is on-topic from the original post as the original post was opining that it would be great if there were a way to "Swap Device" for hue devices. The absence of which results in additional work when replacing hue devices in general, and the need for additional useful tools to help with that work when a hue device needs to be replaced...(this can be moved to a new topic if appropriate)

So the rest of this comment is only in relation to the need for the ability to have a "Swap Device" type feature for hue devices:

It makes sense to me that there can be situations where "Swap Device" across the whole platform for a child device such as the hue linked devices runs into issues. However, I don't think this type of sweeping "Swap Device" functionality, with all of its issues, is necessary for a situation where one is just trying to replace the referenced hue device across multiple Rules and multiple Dashboards, which I'd guess is the vast majority of hue device use cases (at least it is for me).

It would be great to implement a limited version of something like the "Swap Device" for Rule Machine by itself, and again for Dashboards by itself. Then a Hue Device could quickly be replaced in all rules, and then again in all Dashboards, without having to clone and re-select all the new devices in the cloned/copied rules and dashboards. I'd guess that this solves the majority of the "Swap Device" needs for hue device users, and doesn't run into the situations where "Swap Device" across the whole platform creates issues.

How about implementing a Rule Machine and Dashboard specific "Swap Device" functionality that works with Hue Devices, and continue to exclude the hue devices from the overall platform "Swap Device" functionality?

Since there are clearly two distinct issues ("rules in use by", which @thebearmay has done an amazing job with in this thread) and the more complex matter of swapping devices (which is, in large part, a limitation based on complexity of doing it--something I believe they tried, but it ended up breaking things)....

Perhaps @bertabcd1234 can split the "swap device" portion of this into a new thread (since the title of this one is about rule in use by)??

2 Likes

Thanks for this reference, I hadn't seen that the Legacy Dashboard had a Clone process. This makes changing a device in Dashboards a little easier, as the all the devices can we swapped out A:B at once during a single dashboard clone process.

Similar to Rules, this isn't quite as good as allowing the device to be swapped across all Dashboards at once, but it's less work than swapping a device within the GUI Dashboard interface itself.