Controle smartthings devices with xbee

hi , i have an xbee S2B , a smartthing motion sensor and multipurpose sensor. i configured the xbee as api coordinator using the Xctu ( i m still looking for the right configuration )

SC = 7FFF
ZS = 2
NJ = 5A
NI = Xbee coordinator
NH = 1E
NO = 3
EE = Enabled (1)
EO = 1
KY = 5A6967426565416C6C69616E63653039
AP = 2

i can see the sensors on the xctu .My problem is that the sensors enter in sleep mode after 2 to 3 minutes so press the reset button again . and the frame that i recive seem to be crypted :
-frame id : 2 bite incrimente each time .
-data :4 bites change every time . it seems to be crypted
-adress; 16 bites adress of the sensor

can you help me i m blocked

Tagging @JohnR …

1 Like

I think it may help if you take a look at my post on how to add an xBee ZB radio to SmartThings here. Things you should pay attention to are the type of xBee radio you have, make sure your security settings are set as I laid out, and note you can only have one coordinator on an ZigBee network and it has to be the SmartThings hub. So right off the bat your configuration is going to have problems since you are trying to bring up your radio as a coordinator, it has to be configured as a router or an end device.

Just an FYI this is not a trivial process if you truly want to do this it is going to take some research.

2 Likes

thank you for your reply,

to better understand my problem here is a screen capture of the xctu. you noticed the presence of the motion sensor and the multipurpose sensor. I try to change the links between smartthing and xbee from gray to green .so i m still searching the right configuration .

and I present frames that I receive from the multipurpose sensor (for examole) that I have no idea how to treat them

{ type: 145,
remote64: β€˜000d6f000bbb30c6’,
remote16: β€˜085d’,
sourceEndpoint: β€˜00’,
destinationEndpoint: β€˜00’,
clusterId: β€˜0013’,
profileId: β€˜0000’,
receiveOptions: 66,
data: <Buffer e4 5d 08 c6 30 bb 0b 00 6f 0d 00 80> }

{ type: 145,
remote64: β€˜000d6f000bbb30c6’,
remote16: β€˜a718’,
sourceEndpoint: β€˜00’,
destinationEndpoint: β€˜00’,
clusterId: β€˜0013’,
profileId: β€˜0000’,
receiveOptions: 66,
data: <Buffer e5 18 a7 c6 30 bb 0b 00 6f 0d 00 80> }
the β€œ5d 08” and the β€œ18 a7” in the two frames are the data that i think it is crypted
@JohnR

Sorry, I misunderstood. So your not going to use the SmartThings hub just SmartThing sensors with your own hub.

Now that I understand what is going on here it looks like things are working the way they should. When a ZigBee device connects to a ZigBee network it will send out a ZDO Cluster 0x0013 device announce, and that is what you are seeing. That is supposed to trigger a discovery process from the hub in where it will send several ZDO packets to the sensor to discover what it is and how to communicate with it. The following is an excerpt from an article I wrote this summer for Nuts and Volts about the ZigBee communications between a device and the SmartThings hub.

ZigBee Network layer communications
The ZigBee Device Objects (ZDO) library is a collection of clusters for sending and receiving ZigBee network layer packets. Sending a ZDO cluster command is very similar to sending a ZCL command but with two small changes. To send a ZDO packet you have to set your profile ID to 0x0000 and your destination endpoint to 0x00. This tells your radio to treat the data packet as a ZDO command. ZDO commands are extremely powerful. They allow you to bind devices together, create groups, check signal strength, read routing tables, and query devices for their capability.
To be properly identified on a ZigBee network our IoT panel meter needs to support at least 3 ZDO commands.
β€’ Device Announce, ZDO Cluster 0x0013 see page 111 of ZDO spec. When a ZigBee device joins a ZigBee network it needs to announce itself. This cluster is broadcasted to all non-sleeping devices on the network letting them know it’s available to receive data. Often a device announce will trigger an identification process from the ZigBee Coordinator (hub).
β€’ Active End Point Response, ZDO Cluster 0x8005 see page 163 of ZDO spec. When the hub receives a device announce packet it will send a ZDO Cluster 0x0005 report active end point request. The IoT panel meter will listen for this request and respond with a list of its active end points by sending a ZDO Active End Point Response packet 0x8005.
β€’ Simple Descriptor Response, ZDO Cluster 0x8004 see page 161 of ZDO spec. Once a list of endpoints has been received by the hub it will then ask for details on each end point by sending a ZDO Cluster 0x0004 report simple descriptor. The IoT panel meter will listen for this request and respond with the details for each end point in a ZDO Cluster 0x8004 formatted packet. This packet will contain a list of clusters supported by that end point.

Your will need to write some firmware for the xBee to send out these packets to communicate with the devices. You have done some good work to get this far hope this helps!

2 Likes

I will try to do what you asked me .and you will be informed if there are somthings new .

Many thanks for your help ,It was kind of you.

1 Like

hello @JohnR ,
i sent a frame to the smartthing sensor with the cluster 0x0005 after reciving the frame with the cluster 0x0013 . And i recived this frame with the cluster 0x8005 :
{ type: 145,
remote64: β€˜000d6f000bbb3b30’,
remote16: β€˜d7d7’,
sourceEndpoint: β€˜00’,
destinationEndpoint: β€˜00’,
clusterId: β€˜8005’,
profileId: β€˜0000’,
receiveOptions: 65,
data: 0c 80 00 ff 00

next, i sent a frame with cluster 0x0004 as as you mentioned in your document . and i recived a frame with the cluster 0x0006 :

{ type: 145,
remote64: β€˜000d6f000bbb3b30’,
remote16: β€˜d7d7’,
sourceEndpoint: β€˜00’,
destinationEndpoint: β€˜00’,
clusterId: β€˜0006’,
profileId: β€˜0000’,
receiveOptions: 66,
data: 0a fd ff 04 01 00 01 00 05

fdff: remote adress
0401: HA profile
0005: cluster
0001: i don’t know what it means i hope you can help me on this

I am in the right direction ? and can u told me what i should do next.
Yours faithfully,

Your are definitely heading in the right direction but you might have the conversation a little backwards. After your device sends out a device announce packet (ZDO cluster 0x0013), it then needs to listen for packets from the SmartThings hub. When the hub receives your device announce packet it will send you a Report Active End Points request (ZDO cluster 0x0005). You need to respond to that packet with an Active End Point Response packet (ZDO cluster 0x8005). Here is another excerpt from my Nuts&Volts article mentioned above that details the conversation between a ZigBee device and the hub.

Hi @JohnR ,
I finished sending the frames that you recommended to me as the table indicates:
i send the frame with the cluster 0005 and i receive this :
type: 145,
remote64: β€˜000d6f000bbb3b30’,
remote16: β€˜d3b0’,
sourceEndpoint: β€˜00’,
destinationEndpoint: β€˜00’,
clusterId: β€˜8005’,
profileId: β€˜0000’,
receiveOptions: 65,
data: 0c 80 00 ff 00
i send the frame with the cluster 0004 and i recive this :
type: 145,
remote64: β€˜000d6f000bbb3b30’,
remote16: β€˜b187’,
sourceEndpoint: β€˜00’,
destinationEndpoint: β€˜00’,
clusterId: β€˜8004’,
profileId: β€˜0000’,
receiveOptions: 65,
data: 0d 80 00 ff
i send the frame with the cluster 0006 and i receive this :
type: 145,
remote64: β€˜000d6f000bbb3b30’,
remote16: β€˜edcb’,
sourceEndpoint: β€˜01’,
destinationEndpoint: β€˜00’,
clusterId: β€˜0006’,
profileId: β€˜0104’,
receiveOptions: 65,
data: 08 aa 01 00 00 86

i don’ t know how to proceed and receive the data from the smartthing sensor can you help me

What language are you programming in? You code needs to interpret the packets; parse out the data and respond accordingly. I will be happy to help with the code (if I can). It would help to see what you have to this point.

1 Like

Hi , i use node js https://github.com/jankolkmeier/xbee-api
my code recives the packets , analyses it and then respond accordingly.
I published the execution of my code in my last post.
the code :

var util = require(β€˜util’);

var SerialPort = require(β€˜serialport’);

var xbee_api = require(β€˜xbee-api’);

var C = xbee_api.constants;
var sleep = require(β€˜system-sleep’);
var xbeeAPI = new xbee_api.XBeeAPI({

api_mode: 1

});

var serialport = new SerialPort("/dev/ttyUSB3", {

baudrate: 9600,

parser: xbeeAPI.rawParser()

});
var cluster;
var frame_obj = {

type: 0x11, // xbee_api.constants.FRAME_TYPE.ZIGBEE_TRANSMIT_REQUEST 
id: 0x03, // optional, nextFrameId() is called per default 
destination64: "000d6f000bbb30c6", // default is broadcast address 
destination16: "fffe", // default is "fffe" (unknown/broadcast) 
sourceEndpoint: 0x00,
destinationEndpoint: 0x00,
clusterId: 0x0005,
profileId: 0x0000,
broadcastRadius: 0x00, // optional, 0x00 is default 
options: 0x00, // optional, 0x00 is default 
data: [0x0C, 0x00, 0xFF, 0xFE, 0x01, 0x08]

};

var frame_obj2 = {

type: 0x11, // xbee_api.constants.FRAME_TYPE.ZIGBEE_TRANSMIT_REQUEST 
id: 0x03, // optional, nextFrameId() is called per default 
destination64: "000d6f000bbb30c6", // default is broadcast address 
destination16: "fffe", // default is "fffe" (unknown/broadcast) 
sourceEndpoint: 0x00,
destinationEndpoint: 0x00,
clusterId: 0x0004,
profileId: 0x0000,
broadcastRadius: 0x00, // optional, 0x00 is default 
options: 0x00, // optional, 0x00 is default 
data: [0x0D, 0x00, 0xFF, 0xFE, 0x01, 0x08]

};
var frame_obj3 = {

type: 0x11, // xbee_api.constants.FRAME_TYPE.ZIGBEE_TRANSMIT_REQUEST 
id: 0x03, // optional, nextFrameId() is called per default 
destination64: "000d6f000bbb30c6", // default is broadcast address 
destination16: "fffe", // default is "fffe" (unknown/broadcast) 
sourceEndpoint: 0x00,
destinationEndpoint: 0x01,
clusterId: 0x0006,
profileId: 0x0104,
broadcastRadius: 0x00, // optional, 0x00 is default 
options: 0x00, // optional, 0x00 is default 
data: [0x00, 0xAA, 0x00, 0x00, 0x00]

};

serialport.on(β€œopen”, function send(frame) {

xbeeAPI.on(β€œframe_object”, function (frame) {
console.log(">>", frame);
cluster= frame.clusterId;
if(cluster==β€œ0013”){
serialport.write(xbeeAPI.buildFrame(frame_obj));
console.log(xbeeAPI.buildFrame(frame_obj));
console.log(β€˜sent frame 1’);
}else if (cluster==β€œ8005”){
serialport.write(xbeeAPI.buildFrame(frame_obj2));
console.log(xbeeAPI.buildFrame(frame_obj2));
console.log(β€˜sent frame 2’);

}else if (cluster==β€œ8004”){
serialport.write(xbeeAPI.buildFrame(frame_obj3));
console.log(xbeeAPI.buildFrame(frame_obj3));
console.log(β€˜sent frame 3’);

}else{
console.log(β€˜no frame sent’);
}
});

i hope you can help me @JohnR to recive the data from this sensor .

That is an awesome looking node.js object your using. I’m going to need some time but I would love to install that and play with it to see if I can get it working. I will need a little time may be January after Christmas before I can get to it.

hi @JohnR @slagle @tpmanley ,
can i ask you what is foot printing process ? and it can help me to bind my smartthings sensors with the xbee ?
i found this concept in your forum :
link
@slagle and @tpmanley , you can see my work and my code in this forum i hope you can help me .

@Marwen_Dhahri did you ever get your device connected to your xbee? I’m trying to do the same except I have an Iris V2 Contact Sensor I’m trying to pair with my Xbee. The device joins the network, but sends a NWK Leave command after 4 seconds. I don’t know why.

my smartthings sensor device joins the xbee network and sends an announce frame(0x0013) i respond to it like the table ( you can find it in @JohnR previous comments) but i didn’t receive any data . you should respond to the device announce frame otherwise it falls in sleep mode .

Thanks for the response. I’m responding to the 0013 request with a 0005 request (active endpoints) but that doesn’t seem to do the trick. I get a 8005 response and everything looks good, but the device still leaves. Is the destination64 the sensor address? Can you tell me what the data[] values mean? I know one is a sequence and the others are endpoint values???

type: 0x11, // xbee_api.constants.FRAME_TYPE.ZIGBEE_TRANSMIT_REQUEST
id: 0x03, // optional, nextFrameId() is called per default
destination64: β€œ000d6f000bbb30c6”, // default is broadcast address
destination16: β€œfffe”, // default is β€œfffe” (unknown/broadcast)
sourceEndpoint: 0x00,
destinationEndpoint: 0x00,
clusterId: 0x0005,
profileId: 0x0000,
broadcastRadius: 0x00, // optional, 0x00 is default
options: 0x00, // optional, 0x00 is default
data: [0x0C, 0x00, 0xFF, 0xFE, 0x01, 0x08]

Can you tell me what sensor you are using?

Hi @rclark31978 ,
Yes the destination64 is for the sensor address .In the data field you can find the cluster id , the list of the end points that your device supports and in the case of pairing the device with the xbee you will receive the data information ( temperature , luminance , detect movement …). And it may have the command that you wish send to your device.
I use the smartthings motion sensor and multipurpose sensor.
Try to send a frame with the cluster 0x0006 and the profile id 0x104

Thanks @Marwen_Dhahri. I’ll give that a try. I might even buy one of the sensors you mentioned just to see if I can make it work. I’m just about out of options.

you are welcome @rclark31978. Cool , i will try it with the xbee S2C since i used the S2B before and if there is news i will post in this forum i hope you do the same :wink:

I have an S2C as well. I might also mention that I’m using a Python Xbee api and not the javascript api you are using. But that shouldn’t matter.