Hey everyone,
Im working on a project for school where I have to track when the user enters or leaves a certain area. Im using OwnTracks to get the coordinates to the broker and the node Geofence to get the valeu for "inarea". I have a function to get the coordinates and then the Geofence node. Then I have a function to count the entrys and leaves in the area but it doesnt work.
First function:
msg.payload={
"lat":msg.payload.lat,
"lon":msg.payload.lon,
"name":"a41774"
}
return msg;
Second function:
var entrada = context.get('entrada')||0;
var saida = context.get('saida')||0;
if(location.inarea == "true"){
entry+= 1;
context.set('entrada',entrada);
msg.count = entrada;
}
else if(msg.payload.inarea == "false"){
saida+= 1;
context.set('saida',saida);
msg.count = saida;
}
msg.payload={
"entrada": entrada,
"saida": saida
}
return msg;