I use cast nodes to transmit text to my Google Home speaker devices. Works like a charm, but the IP address changes every so often (after reboot of my router). I could set a static address based on mac address, but I wondered if I could be more dynamic than that.
I would prefer for the devices to get a dynamic IP address, and then in Node-Red "discover" these addresses.
Is there a way to do this?
If you look through your routers page that displays the IP addresses, you might find an option
Like "Always use this address", my last two routers had this option.
Otherwise, I would set static addresses, it saves a lot of trouble.
If your node-red is running on linux the command arp-e will give you a table of IP addresses and
MAC's.
Can you dynamically change the IP address in the cast nodes?
An example of Using arp -e:
[{"id":"2b15bbfcf854692c","type":"inject","z":"08a01d3d77d9d931","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":120,"wires":[["23d2f6df140899cf"]]},{"id":"23d2f6df140899cf","type":"exec","z":"08a01d3d77d9d931","command":"arp -e","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":440,"y":140,"wires":[["98ec1f3dd5f4c373"],[],[]]},{"id":"98ec1f3dd5f4c373","type":"debug","z":"08a01d3d77d9d931","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":140,"wires":[]}]
Try this flow, with a MAC address from your network:
[{"id":"369eadc9b8b90dc5","type":"comment","z":"08a01d3d77d9d931","name":"Put a known MAC address from your newwork here","info":"","x":210,"y":80,"wires":[]}]
Yes, that's how I set up all important devices on our home network. You connect the device, it gets an initial DHCP IP address, you check on the router to find its MAC address and then create a static DHCP entry for it.
I also keep a list of IP and MAC addresses. Used to be manual but now I use nmap to get updates and update a table using Node-RED with a uibuilder web page for entry of descriptions.
Thanks... but I am having trouble copying the flow you specified.... I click the "copy" icon above the text, then in Node-Red import, and paste it. But all I get is a comment node...
Sorry, my fault.
[{"id":"08a01d3d77d9d931","type":"tab","label":"Flow 6","disabled":false,"info":"","env":[]},{"id":"2b15bbfcf854692c","type":"inject","z":"08a01d3d77d9d931","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"68:ec:c5:11:16:f6","payloadType":"str","x":140,"y":120,"wires":[["23d2f6df140899cf"]]},{"id":"23d2f6df140899cf","type":"exec","z":"08a01d3d77d9d931","command":"arp -e | grep ","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":390,"y":140,"wires":[["98ec1f3dd5f4c373"],[],[]]},{"id":"98ec1f3dd5f4c373","type":"debug","z":"08a01d3d77d9d931","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":140,"wires":[]},{"id":"369eadc9b8b90dc5","type":"comment","z":"08a01d3d77d9d931","name":"Put a known MAC address from your newwork here","info":"","x":210,"y":80,"wires":[]}]
Got it. Took me a few seconds to find out that the MAC address is case sensitive... I took the address from the device info on Google Home, which gives the letters in uppercase.
Arp gives the mac addresses in lower case.
Sofar, so good.
Next hurdle: when I do an arp on a speaker device, it comes back with TWO IP addresses: looks like an address that was used previously. What could be the cause for that?
arp -e | grep 44:07:0b:7b:01:81
10.0.0.17 ether 44:07:0b:7b:01:81 C eth0
10.0.0.57 ether 44:07:0b:7b:01:81 C eth0
Hi, ping both addresses, one is probably in the cache.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.