Is there any way to get my ESP-Easy D1 Mini module to send its assigned ip address in a mqtt message? If the router assigns it a different ip address I have to scan the network for the host name of the module to get its new ip address. I was curious if there is a way to setup the module to send its assigned ip address over a mqtt message. I havent been able to find it in a search. I am going to guess if it can be done, it can be done with a rule, which I havent started experimenting with. Has anyone ever setup something like this or know if it may be possible and where I can look to get started?
Rob
sending modules ip address in mqtt message
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 80
- Joined: 25 May 2022, 15:05
-
- Normal user
- Posts: 4342
- Joined: 10 Jun 2018, 12:06
- Location: NL
Re: sending modules ip address in mqtt message
Sending messages via MQTT needs a MQTT Controller, just pick the one that comes closest to what you want to connect to, or select 'Home Assistant (openHAB) MQTT' as that's the most generic one (only one MQTT controller should be enabled).
Once you have enabled Rules on the Tools/Advanced page (and saved) you will see the Rules tab. There you could add some code like this:
This will publish the IP address to the topic you select every time the WiFi is connected (or re-connected).
If by chance you have a space or comma in your topic, then wrap that with quotes.
Once you have enabled Rules on the Tools/Advanced page (and saved) you will see the Rules tab. There you could add some code like this:
Code: Select all
on WiFi#Connected do
Publish,mqtttopic/with/unit/ipaddress,%ip%
endon
If by chance you have a space or comma in your topic, then wrap that with quotes.
/Ton (PayPal.me)
-
- Normal user
- Posts: 80
- Joined: 25 May 2022, 15:05
Re: sending modules ip address in mqtt message
Ath,
Thank you! I already have the controller setup. I have a mqtt server on a raspberry pi & node red setup to work with the messages. But that is exactly what I was needing. I appreciate your help!
Rob
Thank you! I already have the controller setup. I have a mqtt server on a raspberry pi & node red setup to work with the messages. But that is exactly what I was needing. I appreciate your help!
Rob
Who is online
Users browsing this forum: Anthropic Claude Bot [bot], OpenAI GPTBot [bot] and 28 guests