Display POI on map taken from db and updated in realtime

Hi to all.
I need to display POI, stored in db, on map but I am a beginner and I have many problems...
I have POI coordinates and status stored on db, when I load map I need to display POIs regardless status (on status I can read battery voltage and other values), let's say "battery discharged" to be shown as blue icon color.
Then I receive updates via TCP, so I need to compare received values with db stored ones, if different I need to update both db and icon color.
If status not received for, let's say 10 minutes, I have to set battery status as "discharged", store it on db and change icon color...
I have no idea about doing this in node red, now I am just testing TCP server...

I found several examples about using db using inject node but I tried to use function node due to "on start" and "on message" options.
On my function node:

msg.topic="SELECT name, lat, lon, type, status FROM stations"
return msg;

I correctly get output value from db but I still get error "ReferenceError: msg is not defined" even if the same msg.topic I've found on many examples... so what's wrong?
I used function node due I suppose placing same code on "on startup" I can see POI displayed first time I load map, but not working.
I also set inject note to send timestamp "inject once after" as found in some examples... is this best way?

Using inject node "inject once after" I can display current status but I have to distinguish between first read and following. I supposed to use a counter as global variable, right?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.