How to create a settings option in DTH?

Hi,
I am building a ZigBee DTH for a light switch. However, the status of the light switch does not correctly resemble the actual state of the lights. So I have added a feature to “reverse” the status. It looks like this:

image

However, I don’t want people to accidentally press the “reverse” button since they only need to set this option once. So I want to move this feature to the settings option so that it looks like the the circled area below:

image

How can I make this settings option in my DTH?

In a DTH, these are called Preferences (not Settings).

The input types are specified here: https://docs.smartthings.com/en/latest/device-type-developers-guide/device-preferences.html

@tgauchat When I change the preference to “true” or “false”, how do I add functions that will handle these actions?

Read the manual?

1 Like

@tgauchat Yes, but what do I name the “someCommandMethod”. And how is it called when the user changes the value?

Preference inputs do not call methods.

Please read the entire development manual.

It has plenty of examples.

1 Like

@tgauchat So, I am also able to invert the status on the app directly from my device. Is it possible for the preference to be updated too?

I don’t think so.