I have a question. I have a project, a domotic (home automation) system, in which I have to send some commands via interface to some sensors, temperature sensors, power sensors, contact sensors, etc.
I've already done the part in wich I can send the on/off/toggle command to a ZigBee sensor. I've followed this manual and this command is described at page 196.
I have this part in python in my project to set the right packet to send to the sensor:
if command not in ['ON', 'OFF', 'TOGGLE']:
raise tornado.web.HTTPError(404, "Unknown command: " + str(command))
op_group = "70"
op_code = "50"
# *9999999999999999;70;50;;100260EB008060008000000D8#
# 70 50 100231AC00000000000008060008000101A9
packet_meta = "*%s;%s;%s;%s;02%s%s600080000%s#" # D8 i s the CRC who compute that?
pkt_len = hextransform(16, 2)
# Hexify the network ID
netid = hextransform(int(nid), 16)
# Hexify the sensor ID
# TODO: - split sensor_id in ZTC sensor_id and endpoint!
# - ZTC sens ID is 2 bytes
# - ZTC endpoint is 1 byte
# sens_id = hextransform(int(sid) >> 8, 4)
# end_point = hextransform(int(sid) & 0x0000FF, 2)
# print("\nsens_id: '" + sens_id + "'\n")
# print("\nendpoint: '" + end_point + "'\n")
# TODO: - split sensor_id in ZTC sensor_id and clusterid!
# - ZTC sens ID is 2 bytes
# - ZTC clusterid is 2 bytes
sens_id = hextransform(int(sid) >> 16, 4)#elisa
sens_id_little = invert2bytes(sens_id,0)
cluster_id = hextransform(int(sid) & 0x00FFFF, 4)#elisa
end_point = "08" #elisa
if command == 'ON':
cmd_data = "01"
elif command == 'OFF':
cmd_data = "00"
elif command == 'TOGGLE':
cmd_data = "02"
packet = packet_meta % (netid, op_group, op_code, pkt_len, sens_id, end_point, cmd_data)
packet = packet.upper()
print("\t\t " + packet + "\n")
################ ELISA #########################################
cmd_meta = "02%s000000000000080600080000%s" #elisa
mycommand = cmd_meta % (sens_id_little, cmd_data) #elisa
len_mycommand = len(mycommand)/2
op_group_hex=0x70
op_code_hex=0x50
mynet_type ="ztc"
cmdjson = packet2json(op_group_hex,op_code_hex, mycommand)
#
#
#TODO : -write command into db
ts = datetime.datetime.now().isoformat()
self.lock_tables("write", ['confcommands'])
self.db.execute("INSERT INTO confcommands (network_id, ntype, timestamp, command) \
VALUES (%s,%s,%s,%s)", nid, mynet_type, ts, cmdjson)
self.unlock_tables();
Now, following the manual, I would add the restart command, to restarting the sensor. And then also add the restore startup configuration command.
So I don't know where are these commands in the manual. There are several of them. Then, I don't see e clearly value for the command restart or restore startup configuration. If for the on/off/toggle there are three values (00, 01, 02), in this case the manual don't say what's the value to assign to cmd_data variable for create the right packet to send to the sensor.
I hope you can help me, because I don't know anymore where search for this. Thank you very much.