[OBSOLETE] FAQ: An Overview of Using Custom Code in SmartThings (SmartThings Classic, Groovy Code)

JDRoberts, how do I remove a custom device handler created in error?

  1. make sure there are no devices assigned to that device type handler

  2. choose My Device Handlers and click on the details button to the left of the device type handler that you want to delete. This will bring up its details page.


3) there will be a delete button at the bottom of the details page

1 Like

So I copied the DTH code and published it to my library. When I go the to device in the IDE and edit it, I don’t see anywhere to link the device to the handler. First time using any of this, so thanks in advance for the help.

The process for steps DTH five and six has changed slightly since this was written and I can no longer edit the first post.

DTH5a) Select “My Devices.” This will show the list of your devices.

DTH5b) click on the display name of the device that you want to assign to your new device type handler. This will open up its details page.

DTH5c) click on the “edit” button at the bottom left of the details page.

Now you can complete DTH6) and edit the device details so that it uses your new device type handler.

3 Likes

Thanks @JDRoberts.
I didn’t realize the new DTH was at the bottom of the list. I thought I was changing the device itself under the type* scroll box. Then I saw the new codes name at the bottom. Much appreciated.

1 Like

How do you “Edit the Device so that it uses that device type handler”. I have created the DTH and published it. When I select the device that should use it I don’t see a way to specify the DTH.

See the update in post 27, two above yours.

When I go to edit the device I don’t see any option to specify the DTH.

The fields are Name, Label, Zigbee ID, Network Device ID, Type, Version, Hub and Group

SmartThings keeps changing its own terminology. It can definitely get confusing.

“Type” = “Device Type” = “Device Type Handler”= “Device Handler” = “DTH” = “DT” = “DH”

All the same thing.

@JDRoberts. Greats post!
Can you help with how to attach a child DTH to a device and also is it possible to have 2 DTH for 1 device? I saw a post earlier where a developer provided 2 DTH and recommended to attach both to the same device…

It is not possible to use two device type handlers at the same time for a single device. I suggest you post a reply to the post you are referring to and ask the developer for more clarification.

Parent and Child Device Type Handlers are created when a device type handler is identified as a “composite” device. The device type handler for the parent device will have code that automatically creates a “child instance” for each child device. It’s easiest to understand this by looking at an example.

Consider the Zooz Power Strip. The strip is a composite device with five individual sockets. The parent device type handler will create the child instance for each of the five sockets when the power strip is paired to your smartthings hub.

So when you choose a device type handler for the composite device, then you will automatically get the device type handlers for its children. You only pair the power strip once to your account, but you will end up with an individual device tile for each of the individual sockets under the parent device in the SmartThings mobile app. This will allow you to turn each socket on and off individually. :sunglasses:

IMG_3761

For more information, see the developer documentation:

http://docs.smartthings.com/en/latest/composite-devices/index.html

1 Like

Thanks @JDRoberts. i think the other post was misleading…Im trying to get the qubino 2 way relay as well as the on/off thermostat to work. managed to get the relays working with child device added but the thermostat is still a struggle.

After some confusion, I figured out that IDE stands for the developer site I’m already in.

In what way do I edit the device to use the handler I just published?

A little more digging, and I found the answer.
Click edit
Select Type
Scroll to the bottom of the drop down menu to find the custom handler and select it.
Click update

2 Likes

Great post

Thanks @JDRoberts. Just diving into the ST world. Most of my smart devices were from Lowes and was using their Iris system. I have successfully moved most of my Iris gear over to ST. The only thing I haven’t found a DTH for is the Iris Smart Wifi switch. (https://support.irisbylowes.com/link/portal/30143/30206/Article/835/Iris-Wi-Fi-Smart-Switch). I saw some articles about it but I don’t think anyone’s completed anything yet.

My first project to install was the Automated Garage Door Opener app. It absolutely blew my mind away. I’m an old time techie and many many moons ago dabbled in programming so I found it very fascinating. And the more research I did on a topic, it seems I ran into a post by @JDRoberts. :slight_smile: So thank you for all you do for this community. It is very much like the computer user communities that existed “back in the day”.

Thanks again and best wishes.

Michael

I just came up with a work around for the Iris Wi-Fi Smart switch. See how I did it here.

March 2018 Update

There are now two mobile apps:

"SmartThings classic,” which we are calling the V2 classic app in the forum.

“SmartThings (Samsung connect),” which we are calling the V3 app in the forum.

The process described in this FAQ will only make sense if you are using SmartThings classic.

At the time of this writing, The V3 app will not support custom device type handlers at all.

It will support custom smartapps, but only if you first add them through the SmartThings classic app.

We have not been given a timeline for when custom code will work with The V3 app :disappointed_relieved:

4 Likes

Very useful for understanding custom code, smart app and device handler. I was struggling to configure monoprice zwave motion sensor through my smarthings app. I tried to change the battery and unpair / repair countless of time, but it was always disconnecting randomly. One of my colleague sent me this link and I went through all post and comment. Changed device handler to Go control motion sensor and i didn’t have any problem since last 4 days… Kudos to you guys and making life little easier.

2 Likes

Where can I find a getting start guide for smartthings?