Versioning whan adding a new capability


What is the best way to add a new capability to an app device when it comes to versioning?

My initial testing shows that adding a capability does not break the current device or flows. But the code with result in an exception trying to set the new capability before the user removes the old device and adds it again.

Are there any best practices when it comes to this? Any way to add a capability without the user having to remove/add the device? Some kind of migration?

Thanks for any advice or examples here :slight_smile:

Yes, check the developer documentation on the ‘addCapability’ method.

Adds the capability without the need to remove and add the device again.


Ok, thanks! Will read up on that. I guess i would just check if it exist first.

That wouldn’t be fun right :wink:

Yes, you need to check for it’s existence first, because adding/removing capabilities is not a cheap operation. But it is very useful for upgrades indeed. Wish Athom would do the same with the tado test version :smile:


Just include some lines like this in the onInit part of device.js:

		if (!this.getCapabilities().includes("measure_uptime")) {
			this.setCapabilityOptions("unit_uptime", {
				"preventInsights": true,
				"preventTag ": true

The setCapabilityOption call is optional of course


if (! this.hasCapability('measure_uptime')) { … }

Thanks! That should be faster.