Memory management

Hi Guys, good morning!

I working to finish my Zigbee gateway and I have check an important issue. Some devices, after turn on, sending all those messages necessary and used in the attaching procedure. My parsing code module catches it and including it in the memory, unnecessary because the device already exists in the memory.

The device object has this structure:

Blockquote
11 Jun 11:31:38 - [info] [debug:Parc_Context Def]
{ ext_addr: '00137a000000873b',
properties:
{ nwk_addr: 'fc0a',
nwk_addrb1: 'fc',
nwk_addrb2: '0a',
EP1: '0a',
ModelID: 'ZBMLC15',
Ext_addrb1: '00',
Ext_addrb2: '13',
Ext_addrb3: '7a',
Ext_addrb4: '00',
Ext_addrb5: '00',
Ext_addrb6: '00',
Ext_addrb7: '87',
Ext_addrb8: '3b',
Type: 'Netvox one circuit actuator' },
_msgid: '5faf619b.9de95' }
Blockquote

I try to check if the device object exists in the memory but I didn't have success:
I have used null or undefined to check if exists but is not working.

Could you see bellow the part of code of my parsing code:

Blockquote
node.send({
"ext_addr":unique,
"properties":properties});
var hwid = global.get(unique);

console.log("hwid:",hwid.ext_addr);

//seting global variable
if (hwid.EP1=== undefined ){ // doblecheck p/ verificar se o hwid existe
global.set(unique,
{"ext_addr":unique,
"properties":properties}, "file");
global.set(unique,
{"ext_addr":unique,
"properties":properties}, "memoryOnly");
console.log("Device foi registrado");

Blockquote

Could you see below the error in the console log:
11 Jun 11:31:38 - [error] [function:Context Definiton] TypeError: Cannot read property 'ext_addr' of undefined

**My context data you can see in the pic below that unique doesn't exist in the global variable:

Anybody can help me how to implement it?