Can a direct connected device use "Device Preferences"?

Hi,

Can a direct connected device use “Device Preferences”?

If so: how are the values/parameters accessed by the device?

Cheers

Yes, you define the preferences in the device profile.

You can access as device.preferences.<preference_name>

As soon as any single preference is changed, an infoChanged lifecycle event is generated. Inside that handler, you can access the previous preferences as

args.old_st_store.preferences.<preference_name>

Only the ST app can modify the preferences.

Hi,

Thanks for reply but I don’t understand how this can be used in the C API for a direct connected device (GitHub - SmartThingsCommunity/st-device-sdk-c-ref: SmartThings SDK Reference for Direct Connected Devices for C).

Maybe I’m missing something.

I’ve not used direct connected devices, but I was under the impression that Device Preferences were currently for hub connected devices, which going forward would mean Edge Drivers as a successor to DTHs.

I would be more than happy to be completely wrong though, as I can see how Device Preferences would be as applicable to certain direct connected and cloud connected devices.

I guess the advantage to a direct connected device is that it doesn’t require a hub.

If the device has a display, then you’d configure the preferences there.

Otherwise, most mass-produced devices would have an app of their own.

That pretty much eliminates the need for ST preferences unless Samsung or a partner wanted to piggyback on the ST app.

There’s a fine line between preferences/settings and attributes. I think of settings as a one-time or infrequent change. Everything could be exposed as attributes. It just makes for a very crowded detailView.

I would welcome an optional collapsible area in detailView or just make each component collapsible.

Sorry, my reply assumed a device directly connected to a hub. I think your only option is to expose your preferences as more capabilities. If your values are of similar type, you could use a list to select the preference name.

I can certainly see why it wouldn’t be anywhere near the top of the to-do list but clearly there is some demand so I’d like to think that, technology permitting, it is something that’ll come along later.

AFAIK, the device preferences can be added to all device profiles and they would be displayed in the app. This could be done updating the device profile from the CLI.
However, I will confirm with the corresponding team if they support the access to them in Direct-Connected integrations.

Hi,

It would be great if it worked. In my/our case we have a number of parameters that are perfect for settings/preferences instead of attributes.
How would changes in the preferences be communicated to the device? Is there a mechanism documented in st-device-sdk-c/APIs.md at master · SmartThingsCommunity/st-device-sdk-c · GitHub or is there a function somewhere else?

Cheers

There is no problem adding a preference and it does show up in the App interface. The docs (Device Preferences | SmartThings Developers) are somwhat incomplete though.

I have no idea how to setup a callback in my code for this event or if it’s possible to so. I’m looking in the code on GitHub but…

Maybe st_conn_set_noti_cb could be used/extended?

Hi, the team mentioned they are not supported yet, so even if we create them, we won’t be able to get their value.
I already created a feature request to support them, in case I receive more info, I’ll let you know but just a head’s up, it can take some time as it depends on the team’s workload.