I've been using the CoCoHue App to intergrate my Hue Hubs with Hubitat. It is all working fine apart from most of the lights have multiple instances of the devices.
I've tried removing the hub and re adding it (this was pain as it mucked up my rules) tried to manually delete devices but it says the device is in use by other rules. Does anyone know how I can tidy this up? If I select the wrong ghost device when creating a rule the rule doesn't work either so it is a real pain.
If the devices are in use by other rules, you need to delete them from those rules first.
Those DNIs--second column from right--are not ones that CoCoHue would have created except for the first instance of "Bedroom 2 Lights" that starts with "CCH/". If you imported rules and didn't re-select a device (the "real" device) when matching devices during the import, Rule Machine will create new virtual devices for you, so that is likely what happened here (unless you manually created virtual devices yourself for some reason; they weren't created by the CoCoHue app, in any case). You can avoid this by being sure to select your existing, real device when importing rules when asked to match devices. (This is not CoCoHue-specific, just how import works.)
But as mentioned above, the only way you can clean this up is to remove any references in apps/rules to all but the "real" device. You can go into each rule and swap the virtual device out for the 'real" one (you may want to rename either that one or the others to make it easier to identify, at least temporarily). Or if these were imported rules (so easy to re-create), you may find it easier to simply delete those rules, delete the virtual devices it made (which should now no longer be in use), then re-import and select the existing device to match this time.
PS - This is not the conventional meaning of "ghost device," which in the context of Z-Wave means a node ID the radio thinks exists but doesn't exist on the network (on the C-7, this is often the result of a failed pairing). I'm not aware of any conventional usage for this term outside of this context. Here, you appear to just have a bunch of virtual devices with the same name (they appear to be duplicates, but there's nothing else really special about them), likely the result of the above import process I mentioned.
Thank you so much. You are absolutely right about the importing of Rules creating the virtual devices. It is in a right mess, going to take ages to sort out but at least I now know how to.