Is it possible to make a capability invisible from lua in an edge driver?

I am looking at writing an edge driver which discovers the capabilities of a device and adapts the detailed view according, at run time, to the type of device it discovers.

I.e. the profile used by the driver would contain all possible capabilities a device may have.
Once the driver has discovered the capabilities of a specific device it would make the unused capabilities invisible in the detailed view.

A simple example would be: The profile contains the contactSensor and a motionSensor capabilities. If the driver discovered a motion sensor device, it would make the contactSensor capability invisible.

Is this possible?

Many Thanks Tim

I solved this partially by creating multiple profiles.

I think this is not possible considering the current architecture, but hopefully I am wrong and someone will bring us good news.

I feel that defining multiple profiles in the driver for all of the possible device configurations is really the ‘correct’ way to go, however tedious that might be. Depending on the nature of the integration and at what point you can characterise the device, you would either create the device with the correct profile to start with or assign a default profile and change it.

I don’t know how quickly the mobile apps respond to profile changes, so there might be some benefit in using visibleCondition to make the default profile as dynamic as possible. I believe it will only grey out capabilities but that buys time until a new view is switched in that completely hides them.

That rather assumes a static device type though. If a given device is acting as a motion sensor one moment and then can change on the fly to being a contact sensor I believe your options may be far more limited.

2 Likes

My experience is that it is best to create different profiles and assign them when starting the driver. Although you must assign an initial profile by default.

For Android, changing from one profile to another already works very well, it detects if they have different capabilities and warns you to close the device and when you open it, it already shows the new profile.

I think it will wokk fine in iOs too

The maximum number of 20 capabilities per component and 10 components per profile is also limited.

I tried to make a profile with 20 capabilities to avoid to delete the routines when changing to the zwave Device Config Mc driver and it was unmanageable for the app.

I think you should also enable the profile to be assigned manually, as I don’t think it’s easy to always hit the correct device type automatically.

Although you might have problems configuring zigbee or zwave devices, that need to configure their attributes or parameters during the initial installation according to the correct type and capabilities of devices.

1 Like

Hi, @Tim99
As mentioned by everyone else above, the device profile cannot be generated/changed in configuration at run time and you cannot make capabilities invisible.
You can only disable them but they will still be shown in the detail view (you cannot do that at run time unless you’re working with custom capabilities and have an attribute exclusively used for “visibility” and use it in your condition (property in the device-config: “VisibleCondition”)
To change the device profile assigned to a device, you need to use the try_update_metadata function, but the profile you call must be already included in the driver package.

1 Like

Ok, thanks.