I have a Sonoff Basic inside a wall box that is working in Home Assistant as an MQTT switch.
However, it needs some config adjustments, easily done through the console screen. But, I just can’t find the IP of the device. It doesn’t show up in an IP Scan, but I can control it from Home Assistant, so it does have an IP address. (Yes, I did try every IP address that IP Scan identifies as an Expressif device.)
Is there a way to get the IP over MQTT?
My alternative is to open the box, unwire the Sonoff and connect the FTDI adapter, but I would rather do it the easy way.
Those are all for re-connections - you shouldn’t be getting so many, but that is another problem.
If you disconnect the mysterious sonoff and wait for a disconnected message before re-connecting, you should see the new client connection.
Alternatively, try grepping the log file
$ sudo grep "New client" /var/log/mosquitto/mosquitto.log
1543737177: New client connected from 192.168.0.17 as f942fc74-baa3-42d2-8b24-54c18b0c6df7 (c1, k60).
1543745431: New client connected from 192.168.0.9 as 4f530e50-4e21-401f-9f83-6c04cc6e090f (c1, k60).
The log file is pretty short, maybe 100 lines, so it was easy to scan it with cat. No “New Client” connections there. There are a few older log files in .gz format, but I’ve never opened a .gz file in Linux.
I could switch off the circuit breaker to disconnect the device- but that’s in the basement. How long should I wait to see the disconnect in the log file?
$ sudo zgrep -i "connected" /var/log/mosquitto/mosquitto.log.1.gz
1542446407: New client connected from 192.168.0.9 as db8de907-cb85-437c-9993-e54366c97573 (c1, k60).
1542446408: New client connected from 192.168.0.9 as 6ddc1dca-82f7-43b0-94b2-c900af6cabe1 (c1, k60).
It should take about 30s for the client to disconnect - assuming you haven’t changed the default config. But I would hold off using the circuit breaker - I didn’t realize how embedded this was - you should be able to determine what you want from the log files - assuming you know the client id?
I did not know about zgrep, I will look through the older log files.
grep has been very handy, but looking through the older log files for “192.168” didn’t show any new connections.
I am beginning to think it will be easier to just connect the FTDI to the Sonoff again. I am not finding anything in the Mosquitto log files that helps.
Many thanks for your help. All is not lost, since you pointed me to two things I didn’t know before- where are the Mosquitto log files, and zgrep. I’ve added both notes to my Tasmota tips file. (Actually a personal wiki that I use like a lab notebook).
How many MQTT clients do you have? You can get a list of open TCP connections, which will include the source IP, with the netstat command on your MQTT server. On my machine I can do this:
peter@sara:~$ netstat -natu | grep 1883
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:50868 127.0.0.1:1883 ESTABLISHED
tcp 0 0 10.17.17.118:1883 10.17.17.112:40277 ESTABLISHED
tcp 0 0 127.0.0.1:50119 127.0.0.1:1883 ESTABLISHED
tcp 0 0 127.0.0.1:1883 127.0.0.1:50868 ESTABLISHED
tcp 0 0 10.17.17.118:1883 10.17.17.112:46617 ESTABLISHED
tcp 0 0 127.0.0.1:1883 127.0.0.1:50119 ESTABLISHED
tcp6 0 0 :::1883 :::* LISTEN
I’m only interested in ESTABLISHED connections, and 127.0.0.1 is the localhost address so I can ignore those too. That leaves two connections, with a source address of 10.17.17.112 and a destination of 10.17.17.118 port 1883. That tells me that the only MQTT client I have right now is on 10.17.17.112. In my case, that’s the raspberry pi running lighting in my kitchen.
Alternatively, Tasmota devices have a web interface, right? Rather than just scanning for espressif devices, have you scanned for everything on your local network that has port 80 open?