I’m making a simple node-red flow which reacts to the intent “WhatsMyIp”.
I used an exec-node in node-red to execute the following bash-command:
sbin/ip -4 -o addr show dev eth0| /usr/bin/awk ‘{split($4,a,"/");print a[1]}’
This “works” but it gives the ip-address “in the container” and that of course is not the one I need, it’s the ip-address of the raspberry in my home network I want.
I posted this also on the node-red forum but, there they suggested to not use docker, which seems a drastic measure for this problem.
Her is my node-red flow:
[{"id":"aa7ebe61.f0a9f","type":"tab","label":"WhatsMyIp","disabled":false,"info":""},{"id":"507071fb.dfcf78","type":"debug","z":"aa7ebe61.f0a9f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":100,"wires":[]},{"id":"4c8ca89e.31f138","type":"exec","z":"aa7ebe61.f0a9f","command":"/sbin/ip -4 -o addr show dev eth0| /usr/bin/awk '{split($4,a,\"/\");print a[1]}'","addpay":false,"append":"","useSpawn":"false","timer":"20","oldrc":false,"name":"GetIp","x":310,"y":160,"wires":[["507071fb.dfcf78"],[],[]]},{"id":"db06641a.216ec8","type":"inject","z":"aa7ebe61.f0a9f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":260,"wires":[["4c8ca89e.31f138"]]}]
any idea for a better solution?
kind regards,
hugo