Common Composite (Child) Device Handlers


(Eric M) #1

So I recently added some functionality to a device handler of mine that required several child handlers to be used. I though, “this is going to be a pain for the community to install all of these” (especially if they don’t have github integration setup). So I had a thought that it would be a good idea for community developers to use a common set of child device handlers. At least until SmartThings releases their own. This would make things a lot easier for developers and users utilizing this new functionality. Here is a list with links for all the composite handlers I have created. Anyone is free to use them if they would like as well as add any missing capabilities by posting in this thread.

Child Device Handlers:

Contact Sensor
Metering Switch
Switch
Smoke Alarm
Water Sensor
Carbon Monoxide Sensor
Carbon Dioxide Sensor
Motion Sensor


(Dan) #2

Eric,

I really appreciate you posting these Child Device Handlers here. Great idea for everyone to share a common pool. Thank you!

One thing I have noticed is that it appears the Parent DH and the Child DH must be in the same namespace. Otherwise, the Parent DH fails to add the child device. I simply copied and pasted your code into a new DH. When it kept failing on the addChildDevice() call, I tried changing the namespace and author in the definition to match my values in my parent DH. Afterwards, the addChildDevice() call succeeded.

Dan


(Eric M) #3

So when creating a child device from a SmartApp you can specify a name space. Haven’t tried it yet with a composite device but will when I get a chance. If it doesn’t work that would be too bad as that would mean you couldn’t even use a common set of SmartThings provided child handlers. This is the command that I use in one of my apps:

def child = addChildDevice(“erocm123”, “SmartLife RGBW Virtual Switch”, getDeviceID(i), null, [name: getDeviceID(i), label: switchName, completedSetup: true])

There are obviously some variables in there so it isn’t a complete explanation, but just a demonstration that it can be done (in a SmartApp).


(Eric M) #4

@ogiewon Ok, so I just verified and if you put the name space in front of the Device Handler name, then you can use handlers that don’t have matching namespaces. For example:

addChildDevice(“erocm123”, “Metering Switch Child Device”, “${device.deviceNetworkId}-ep${i}”, null,
[completedSetup: true, label: “${device.displayName} (Q${i})”,
isComponent: false, componentName: “ep$i”, componentLabel: “Output $i”])


(Dan) #5

Thanks for the solution! I appreciate you taking the time to figure this out.


(Dale C) #6

Eric, how about a dimmer switch? We have one on the Zigbee Ceiling Fan/Light controller. I am sure you must have one in mind because the H801 uses it right? What do you recommend we change below to fit in best with the new unofficial composite standards?


(Eric M) #7

Yeah, I definitely am working on bringing child devices to the H801. My plan was to use a “Dimmer Child Device” that would look a lot like that one minus the custom icons. So I’m not sure if you want to make any changes to it. I could maybe list it in the original post as an alternative that some could use.


(Dale C) #8

Thanks for the reply. OK , Anyone of course can grab the code. In my case I do want to use the custom icons because it is matching the icons of this specific product hardware controller. So go ahead and pick a dimming light bulb icon to make it compatible for your composite library.


(lubabalo) #9

@ogiewon Ok, so I just verified and if you put the name space in front of the Device Handler name, then you can use handlers that don’t have matching namespaces. For example:

addChildDevice(“erocm123”, “Metering Switch Child Device”, “${device.deviceNetworkId}-ep${i}”, null,
[completedSetup: true, label: “${device.displayName} (Q${i})”,
isComponent: false, componentName: “ep$i”, componentLabel: “Output $i”])
this is giving me hard time it continues to fail whatcan be the issue


(lubabalo) #10

I did this too buy ddnt work


(Dan) #11

I ended up making a complete set of Child Device handlers for my ST_Anything project, using my own namepsace and stored in my Github repository. I did this primarily to allow users of my project to simply use the ST IDE Github integration for ST_Anything, making adding and maintaining the custom DH’s much simpler for everyone. Feel free to take a look at my parent and child device handlers to see how I have chosen to implement the Composite Device Handler. I implemented an automatic child creation mechanism within the parent DH, which allows the user to customize their Arduino sketch to include whatever “devices” they’d like and have the corresponding children automagically created. Users of ST_Anything do NOT need to customize the DH groovy code at all (unless they want to customize the child devices to their liking.)


(lubabalo) #12

this one is a bit complicated for my level. is there a step by step on how to install it. I have tried installing ST_Anything aswellwith the documented Child Device handlers but didnt win at all


(Dan) #13

The ReadMe on my Github is a set of step by step instructions.

What are you trying to accomplish? Knowing that would help us to be able to help you.


(lubabalo) #14

I bought this device Fibaro Double Switch 2 fgs-223 EU v3.2 and trying to get it to work with my smartthings hub. I have a double switch on my wall controliing two light. in short am trying to have a one switch that splits into two once i enter it. eg kitchen------->switch1---------Switch2


(lubabalo) #15

SmartThingsPublic/devicetypes/erocm123/metering-switch-child-device.src/metering-switch-child-device.groovy this was probably the closest but couldnt get the parent to call it out.


(Dan) #16

Since you’re trying to use a Fibaro device, neither my code nor @erocm1231’s is going to work without some changes.

Personally, I would recommend you start with the example code highlighted in the following post. This appears to be very similar to what you’re trying to accomplish.


(lubabalo) #17

thank your for your reply this worked. it shows 5 channels at the moment and am only using the first two. thank you.


(Eric M) #18

I have a handler created for that device that uses the composite device scheme. Have you tried it?

Also, I’m really surprised that putting the namespace in the addChildDevice call didn’t work. In my testing, it allowed me to use other people’s namespaces:

addChildDevice("erocm123", "Metering Switch Child Device", "${device.deviceNetworkId}-ep${i}", null,
[completedSetup: true, label: "${device.displayName} (Q${i})",
isComponent: false, componentName: "ep$i", componentLabel: "Output $i"])

(lubabalo) #19

thank you for the time you put working in these things. I tried your code earlier but it didnt work I tried it now again and its working just fine. do youhave any thing for the fibaro roller shutter fgr222eu2.5


(Eric M) #20

Sorry, I do not.