Is there a way to use a Maker API referring to the device label rather then it's ID?
Recently I moved a dimmer from one place (living room) to another (stairs), then added another dimmer (living room).
I had to rename the old one (living room -> stairs), then renamed the new one to the old name (living room).
I had some Maker API's and, of course, these referred to the device by it's device ID, or number (like 34.) I had created shortcuts on my desktop (Windows), and after the move, they didn't work.
After doing a "get all devices" I found the device ID had changed.
I changed the device ID in my shortcuts, and it works now.
I can envision more changes in my life, and I'd rather not have to change the shortcuts on my 3 computers every time I move a device.
This is unlikely to happen because device labels do not have to be unique, unlike device IDs.
No, not through Maker API. Although, to be fair to Maker/HE, it sounds like your original LR device's ID didn't so much change, as the newly added one simply got its own, different deviceID.
For future reference check out the "Swap Device" utility which should be able to accommodate such swaps as you continue building out your system:
Although not in this instance. Because @CoolJavelin creates MakerAPI URL shortcuts on his Windows desktop, which can presumably be double-clicked to get specific device commands executed.
"Swap Apps Device" will not change the device ID in the pre-existing shortcuts on @CoolJavelin's desktop.
A better solution for them may be to use the built-in Dashboards app, or one of the several community Dashboard integrations.
I thought that the Swap Apps feature actually did “swap” the two device IDs of the actual devices. I don’t believe it touches any of the references to devices in all of the Apps.
But a URL saved on your desktop will include the old device's ID and wouldn't get updated by HE.
Ahh - then I misunderstood how it works.
Here is a nice explanation
"Swap Apps Devices" works by swapping one device's hub/database-assigned ID with that of another. (By this, I mean the number you see in the URL but not really anywhere in the UI; thisis is distinct from the Device Network ID.) There's nothing a specific app should need to do when this happens, nor would most apps really need to know or care (except as below), whether rules or other apps. If you think you notice something, I suggest reporting it so it can be investigated. But I don't see any iss…
This is correct, so for the Maker API use case above, it should work (if I'm interpreting the desired outcome correctly).
What some may be confusing this with is clone or import, where it offers the ability to swap or substitute devices.
That does "reach in" to the app and swap out actual device references, so in apps that depend on the internal ID, like Maker API, using this feature would indeed result in differences with regard to how you'd need to use the external endpoints that are dependent on these (though I guess at that point your app ID would also be different, so you'd need to check all the URLs anyway).