sending modules ip address in mqtt message

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Rob73
Normal user
Posts: 30
Joined: 25 May 2022, 15:05

sending modules ip address in mqtt message

#1 Post by Rob73 » 25 Jul 2022, 15:31

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: sending modules ip address in mqtt message

#2 Post by Ath » 25 Jul 2022, 15:41

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:

Code: Select all

on WiFi#Connected do
  Publish,mqtttopic/with/unit/ipaddress,%ip%
endon
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.
/Ton (PayPal.me)

Rob73
Normal user
Posts: 30
Joined: 25 May 2022, 15:05

Re: sending modules ip address in mqtt message

#3 Post by Rob73 » 25 Jul 2022, 16:18

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

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests