How to identify the device profile name being used?

Sometimes, I use try_update_metadata({profile = "..."}) to update the profile at certain circumstances.

I tried using device.profile.name and device.profile.NAME to get the current device profile name, but it didn’t work.

Currently, I had to create an enumeration preference that contains profile device names in the options.
And I use device.preferences.presentation to identify it.

It works satisfactorily when I have a device with multiple profiles, but creating a preference with single option just to identify the device profile name doesn’t make much sense to me.

So, my question is: Is there any way to programmatically detect what is the current device profile name being used?

No, the name isn’t included device object, using the following you can get the capabilities configured in the profile and its ID:

log.info(st_utils.stringify_table(device.profile, "Device Profile", true))

That was previously asked and someone shared his workaround here:

So, instead of having profile name, the ideia is to have custom capabilities to act as tag ?
Then we would check existence of that capability instead of profile name… yeah, it might work.

I still think that sometimes is useful to compare the current profile with the one that were chosen or the available options.
As we update profile by its name using try_update_metadata({profile = "..."}), then the way to compare is by name.

Thanks @nayelyz