Thingshield Zigbee Command Queue [Question for other Thingshielders]

(Keith Croshaw) #1

Note: There are a lot of variables in this post and I’d be more than happy to divulge code, I’m more just interested to poll the community to see if anyone has experienced this before.

I haven’t really seen this anywhere in the forum so I’m going to go ahead and see if anyone has any ideas or if I’m just out of my depth. So I’m in the process of testing out my Smarthings Shield RF bridge that issues commands to 433 mhz switches. Things are pretty mature and work somewhat reliably but I’ve run into one issue that is very repeatable which is I can’t tell it to turn more than 1 switch on at a time. I have a SmartApp reading commands from virtual switches and issuing commands to the Arduino Shield.

I see the two virtual switches toggle, I see the SmartApp send two commands, but only one actually toggles.

My big question is has anyone experienced issues where zigbee can only handle 1 stream at a time? For example if 1 command would be rcwitch1on, would two commands look like: rcswitch1onrcswitch2on

1 usually works so the arduino is understanding something, just not both.

(John Rucker) #2

When you say ZigBee where is that coming into play if your using 433 Mhz? Do you have a ZigBee shield on the arduino and then another 433Mhz radio? I bet that is what you mean by bridge. Sounds like a cool project If you have a sketched out diagram that may help.

Here is what I have seen in sending standard ZigBee commands from a SmartThings custom device type. As far as standard ZigBee is concerned each switch would be on its own endpoint and you would send the command to that endpoint. So each command would be a ZigBee packet to the same address and cluster but with a unique end point. For example to turn on a two relay ZigBee switch you would send these two commands from your smartThings device type:

st cmd 0x${device.deviceNetworkId} 0x01 0x0006 0x1 {}
st cmd 0x${device.deviceNetworkId} 0x01 0x0006 0x1 {}

The 0x01 and 0x02 are the end Points for the switch, 0x0006 is cluster number, and 0x1 is the on command as defined in that cluster’s ZigBee HA documentation.

Its possible your doing this but your device is missing the second packet because it can’t process the first packet quick enough. If that is the case put a delay between each command in your code for example the above two commands would look like this:

def cmd = []
cmd << "st cmd 0x${device.deviceNetworkId} 0x01 0x0006 0x1 {}"	// Send on command to End point 0x01 
cmd << "delay 150"
cmd << "st cmd 0x${device.deviceNetworkId} 0x02 0x0006 0x1 {}"	// Send on command to End point 0x02 

Now with all that said I dont think there is anything standard about the SmartThings arduino shield. When I looked at it last year it didn’t appear to use standard home automation clusters. But maybe knowing how to send the commands to a standard ZigBee cluster and end point will help you. If I had to guess you may need to put a delay between the two packets.

Sounds like an awesome project let us know how it turns out.

(Keith Croshaw) #3

Thanks, I’m just passing strings, which is what most of the SmartThings shield projects do. That being said yes the SmartThings shield is the zigbee component. Now groovy doesn’t work in a loop like arduino so I don’t think delays really work. Or did you mean to pass the raw text in the Zigbee command?

(John Rucker) #4

Humm, I bet they exchange date over a proprietary cluster and allow you to send what every you want as a string. I don’t think I’m going to be much help.

Need a SmartThings shield guy or gal on this one.

(John) #5

I had the exact same problem.

It can only process one command at a time. Furthermore, it can only process one message to the cloud (including debug) at a time, not just a ThingShield message. If another message is sent and the processing hasn’t completed on the first, then the first gets trounced. I have found that a one second delay works, but not all of the time. For one of my projects, it generates a couple of message back to back, but relatively infrequently. I found that depending on the processing time in the cloud, sometimes delaying by 5 seconds didn’t always work. I increased the delay to solve it.

(Keith Croshaw) #6

Wow thanks, I’m glad someone else is in the same boat and I’m not going crazy. I’m using the to delay the two switches by switched apart from eachother.

Thanks a lot.