Getting undefined error in flow.get


i work with flow.get and global.get a lot
however i get an error in the currrent flow but do not see anything wrong

de output is undefined but it should state up (the value of network.

i suspect that the ipaddress having dots is causing the problem but how to solve this

flow including function

[{"id":"88454dc9.c905c","type":"inject","z":"b26f44fa.693c68","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1800,"wires":[["2bee791b.798fe6"]]},{"id":"dab0419c.cded2","type":"debug","z":"b26f44fa.693c68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":1800,"wires":[]},{"id":"2bee791b.798fe6","type":"change","z":"b26f44fa.693c68","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":1800,"wires":[["62491705.0074d8"]]},{"id":"62491705.0074d8","type":"function","z":"b26f44fa.693c68","name":"","func":" var ip = msg.topic;\n var status = flow.get('network.'+msg.topic+'.ipstate')\n msg.payload = status\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":1800,"wires":[["dab0419c.cded2"]]}]

data in flow


Here you are:

status = flow.get('network')[msg.topic]["ipstate"];
1 Like

The problem comes because you are trying to use as part of the key name.

The full key you function code generates is


which results in:


It doesn't recognise as a single key name, rather it interprets that as the four distinct object property levels.

The fix is to either generate a key like:




or as @techraf suggests, get the whole network object first and then pull out the bits you need.

thanks, almost tried everything (including using ) but sometimes i just can not get it right.

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