0

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.

tomlogic
  • 11,489
  • 3
  • 33
  • 59
sharkbait
  • 2,980
  • 16
  • 51
  • 89

2 Answers2

1

I do not know the ZigBee techno, but according to your documentation you can try to send the APS messages called APSME-RESET.Request and APSME-REST.Confirm for plateform reset or NLME-Reset.Request and NLME-Reset.Confirm for network manager reset

lucasg
  • 10,734
  • 4
  • 35
  • 57
1

It looks like this code is using the ZigBee OnOff cluster (0x0006), since the commands match up with what your code is doing. Since ZigBee is little endian, one of the 0600 sequences in your code is the cluster ID.

The Basic cluster (0x0000) supports a single command, 0x00, which resets a device to factory defaults. Be careful with this command, as it could result in the device leaving the network and going back to its default network settings as well.

I'm not aware of a ZCL (ZigBee Cluster Library) cluster and command you can use to restart/reboot a device. ZigBee sensors are designed to run for years without having to restart.

To learn more about ZCL clusters and commands, you can download the ZigBee Cluster Library from the ZigBee Alliance.

Why does your device need to restart the sensor?

tomlogic
  • 11,489
  • 3
  • 33
  • 59
  • because I want do a domotic interface and I want the user can restart the sensor, or reset to the startup configuration... – sharkbait Oct 23 '12 at 20:42
  • Ok @tomlogic I understood that ZigBee sensors are designed to not having restart ;) I remove this command from the system. Thank you for the info! – sharkbait Oct 24 '12 at 10:29
  • @sharkbait: out of curiosity, where are you getting your sensors? I'm always interested to learn about new commercial ZigBee sensor devices. – tomlogic Oct 24 '12 at 16:46
  • Are sensors that are developed and made in a private organization in Italy, in my university – sharkbait Oct 24 '12 at 20:45