How to use 1 ZigBee device to control multiple channels?


(Jack) #1

Hi,
I have a ZigBee device that can control other devices via a different RF protocol. And the number of devices connected to my ZigBee device may vary. When I pair my ZigBee device to ST, I want the number of RF devices to reflect how many tiles will show on the “tiles” screen. For example, if I have 2 RF devices, then 2 tiles should appear on the “tiles” screen like this:

How can I do this?


(Dan) #2

You’ll need to use a Composite Device Handler design to achieve this. One Parent Device Handler and Child Device Handler(s). The Parent will create the child devices so they are exposed as individual devices to all other SmartApps.

Here’s an example of a DTH that demonstrates the design.

If you additional examples, you can look at my ST_Anything DTHs.


(Jack) #3

Cool. I also want to group channels together - like a scene. So, if I have 20 channels in the ZigBee device, is there a way to group these channels - 10 channels in group1 and 10 channels in group2?


(Dan) #4

You could use the SmartThings Scenes feature… ;). But it depends on how you plan on using them.

What is your end goal?


(Jack) #5

Everytime I try to add the virtual device (with Zooz Power Strip DTH) to the scene, the app goes crazy and exits out of scene setup.

My end goal is to be able to control each channel individually, but also control groups of the channel too.


(Dan) #6

Controlling groups of child devices is absolutely no different than controlling a group of independent physical devices. Most people use Routines or webCoRE Pistons to control a group of devices.


(Jack) #7

Thanks. How come this can’t work in a Scene, but can work in a Routine?


(Dan) #8

I don’t know


(Jack) #9

Do you know if there’s been an update in composite devices that allow you to change individual channel names?


(Dan) #10

You can programmatically call them anything you like when creating them. If the child devices are created with “isComponent: false”, then each child can have its label changed from within the ST Mobile App (at least it works on iOS.)


(Jack) #11

I tried setting “isComponent: false”, but I don’t see an option to change each child’s label in the ST app. Why?


(Dan) #12

Did you recreate all of the child devices? Are you using iOS or Android?

Each child should show up independently in the things view.


(Jack) #13

I just use a virtual device with Zooz Power Strip DTH and modified the below. I use Android.


(Dan) #14

Did you remove the device and re-add it? That’s probably when the child devices are created.

Also, I do not know if Android supports editing the name of the child devices.


(Jack) #15

It works. I see all 5 separate channels now. However, I see the parent show up too. Is there a way to prevent the parent from showing up in the things view?


(Dan) #16

Give me a break!!! :joy:

No, the parent will still show up…


(Jack) #17

Is there a way to assign the parent as channel 1 (and only control ch 1), and have channels 2-5 show up too? Just wondering.


(Dan) #18

Sure. It’s your code, you can do whatever you’d like with it. Only create child devices for 2 through 5. Add local support in the parent for device 1.


(Jack) #19

@ogiewon So I’ve been trying to use a child device to control the parent. However, when I try the below code in the parent handler, the parent doesn’t turn on. Why is this so?

void childOn(dni) {
	zigbee.on()
}

(Dan) #20

I am not 100% sure. You can try changing your code as follows to see if it helps, as this is basically what my code uses for the old SmartShield.

def childOn(dni) {
    def cmd = zigbee.on()
    sendHubCommand(new physicalgraph.device.HubAction(cmd))
}