J'ai une question. J'ai un projet, un système domotique (domotique), dans lequel je dois envoyer des commandes via l'interface à certains capteurs, capteurs de température, capteurs de puissance, capteurs de contact, etc.Redémarrer et restaurer la configuration de démarrage pour un capteur ZigBee via Tornado/Python
J'ai déjà fait le rôle dans Je peux envoyer la commande on/off/toggle à un capteur ZigBee. J'ai suivi this manual et cette commande est décrite à la page 196.
Je cette partie en python dans mon projet de mettre le paquet droit d'envoyer au capteur:
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();
Maintenant, après le manuel , Je voudrais ajouter la commande de redémarrage, pour redémarrer le capteur. Et puis ajoutez également la commande de configuration de démarrage de restauration. Donc, je ne sais pas où sont ces commandes dans le manuel. Il y en a plusieurs. Ensuite, je ne vois pas clairement la valeur pour le redémarrage de la commande ou la restauration de la configuration de démarrage. Si pour l'on/off/toggle il y a trois valeurs (00, 01, 02), dans ce cas le manuel ne dit pas quelle est la valeur à affecter à la variable cmd_data pour créer le bon paquet à envoyer au capteur.
J'espère que vous pouvez m'aider, parce que je ne sais plus où chercher. Merci beaucoup.
Ok merci j'ai essayé. – sharkbait