Custom DTH for Customizable Simulated Switch—where to start?

How can I go about creating a custom DTH for a simulated switch? I want to replicate a regular simulated switch, except I want to modify the text on the switch from “ON” and “OFF” to custom text defined in the switch’s settings. Are there any good guides on how to do this? Perhapsa known template to start from?



Just start with this:


Perfect! Simple enough for me to play with. Perhaps a presence sensor is a better template as I want to display bibary status, not control. Off to the playground!

Is there any online guide as to the parts and pieces to a custom DTH? I am looking at 3 binary sensor DTH files (Presence, Motion & Contact) and comparing them side by side along with the proposed switch one above.

I see the overall architecture is:

metadata {
definition(name, namespace, author, runLocally)
capability "AAA"
capability “BBB”

command "DDD"
command “EEE”


simulator {
status “DDD”: "capability:command"
status “EEE”: “capability:command”
//simulator not present on virtual switch

tiles {
state ()
state ()
main ""
details “”

def parse(description){}

def DDD( ) {log.trace " "
sendEvent(name: " ", value: " ") }

def EEE( ) {log.trace " "
sendEvent(name: " ", value: " ") }

So where is there a good guide to help guide me through these parts and pieces?

Also, I see many of these seem to reference icons, is there a master list of existing icons?

Finally, if I want my simulated sensor to have settings that can be user defined, how do I establish this? Perhaps user provided “open” and “closed” labels as well as user selected icons under the sensor settings?

Though not the quickest; I always recommend reading all of the Developer Documentation:

Once you’ve done that; make tiny incremental changes - ONE at a time - compiling and testing it each time until it breaks. Then go back a step and try again and again and again.

SmartThings is a super complex system that would be a 2-term college class at least. Don’t expect to learn it in a week!

Thanks for the direction! No worries, I plan to keep my day job :slight_smile: Action Tiles will remain safe!

I just like to tinker and learn :slight_smile:

1 Like

It’s definitely fun to learn, but takes some patience; hence the iterative “test one change at a time” approach.

And: Never trust the Simulator: It is much less frustrating, though a tiny bit slower, to keep using “Publish - For me” and then testing in the SmartThings App on your phone or tablet.

One more hint: Frequently pasting your code into GitHub will allow you to not only track your changes to make it easier to backtrack when something breaks, but also super easy to share the entire DTH here (just like I pasted the sample above…) so that folks can copy it to their own environment to help see the exact bug you have encountered.


1 Like