Whenever I delete a device (a ZigBee device, in my case), nymea deletes all magic which refers to that device. I certainly understand the reasoning behind that design decision. However, deleting devices and adding the same devices again to the network has become something of a daily routine for me, alas. Other activities normal to the maintenance will also provoke the same behavior, such as re-flashing the ZigBee coordinator.
Rewriting all that magic whenever I had to renew the binding of a device is becoming quite a chore. Also, it requires me to do keep book about which magic mentions which devices, and I have to keep screenshots of each magic so that I can rewrite it from scratch whenever I lost it.
I think that instead of simply and silently discarding all magic that mentions a deleted device, there should be provisions to conserve the magic with enough information to restore it once the devices needed are back in operation.
There are several ways to do that.
One very simple way would be to just let the magic stand and to handle missing devices at runtime for each magic. That’s not very elegant and might be a bit error prone, but it’s simple.
Another way would be to replace each mention of a deleted device with an object of a class which represents deleted devices. The proxy object presumably would store at least the unique ID of the deleted object, preferably also its type and the properties and values associated with the operation.
The system then could search all magic or all instances of proxy devices whenever a device is freshly bound and restore the magic to its state prior to deleting the device.
A bit more involved: the GUI which supports the building of the magic could prompt the user for a replacement for the dropped device; but this is certainly much more complex and the specifications need some clarification before implementation. The first variant certainly would cover most cases when I have to delete devices and bind them again.
While we’re at it: I would much appreciate if there was another way of documenting my magic other than taking a screenshot of the builder GUI. A text representation of the same content would already be much more useful. It also would be handy for discussing magic here in the forum. I’r rather not use an external OCR software to decode what’s shown in the GUI.