Need help rebuilding home automation raspberry pi

OK Since everyone is (wisely) trying to get @merkelck to use allow_anonymous false, this post is irrelevant.
Deleted to try and reduce confusion.

Unfortunately, the screenshot doesn't match the topic. Since you have managed to update the 4004_05 topic, you should copy the on, off, ui switch and mqtt-out nodes. Paste a new copy of them and change the new mqtt-out to have a topic of home/office/4004_05/state - that should work.

OK, this is good - you are definitely getting traffic from outside the server.

As others have said - TURN ON THE allow_anonymous setting in the mosquitto config!!

This is a very important question. To get MQTTExplorer to connect to mosquitto did you have to enter a user and password on the MQTTExplorer MQTT Connection page?

If not then, as has been suggested a number of times, in your mosquitto config file set allow_anonymous true.

@TotallyInformation have you any idea why MQTTExplorer might not be showing the $SYS topic? I have never seen that not present.

Well, been a while since I set it up! I do know that the $SYS topic is not exposed with a root wildcard (#) topic, you have to explicitly subscribe to it with $SYS/#. So whether I added that manually at some point, I can't remember I'm afraid.

Hmm, just creating a new dummy connection seems to suggest that it is included by default:

Is there a mosquitto config setting to turn it off? It does generate a lot of messages.

wed_mqtt_problem
Your screenshot above shows devices trying to make a connection and then being disconnected by the broker as not authorised. That means the user/password is not correct or not present.

People have said previously, set the statement in the conf file to this allow_anonymous true
Then restart mosquitto and then have a look at your log file.
At this stage, during initial testing, you don't need a user/passswd.

Earlier in this thread you posted a very simple back-to-back simple test for your MQTT.
monday_mqtt_problem
I assume the MQTT-In and -OUT nodes are using your new broker.
Can you verify when you click the Inject node you see the result on the Debug ?
You should be able to also see this activity on the MQTT Explorer as well.

Did you give up or figure it out?

1 Like

Hello , I did not get it working nor did I figure it out. Sometimes other irrelevant things get in the way. (Doctor visits, etc.)

Dave, this is the log after setting "allow_anonymous true". It is trying to connect to the correct device but can't.
In response to the simple test . Yes, it responds in the Debug pane every time. I am going explore MQTTEX some more .

Charles

1 Like

Did you restart mosquitto (or reboot) after changing the settings file?
Which file are you editing (full path to the file please).

Please:

  1. Unplug power from all Sonoffs
  2. Delete the Mosquitto log. sudo rm /var/log/mosquitto/mosquitto.log
  3. Reboot the Pi with the new broker. sudo reboot
  4. Plug in just one Sonoff, ideally the one which had/has IP 192.168.1.221, but any one should do.

After 1 minute run sudo cat /var/log/mosquitto/mosquitto.log
Copy the full contents of the logfile and post them here, as text not a screen capture please.
(If you are getting many repeats of connection, not authorised by all means delete duplicates, but keep the first connection in your reply)

This will probably not immediately resolve the problem but it may form a basis for more questions.

Entirely up to you, but your problem seems to be how Mosquitto is setup, not how you are monitoring it.

for COLIN Yes, I did and the file is
"/etc/mosquitto/mosquitto.conf"

Right now I am running two systems the old and the new. But the new has a different i/p and I have only one sonoff connected with the correct i/p for the new broker.
for jbudd

ckentm@4004HOME:~ $ sudo cat /var/log/mosquitto/mosquitto.log
1774634449: mosquitto version 2.0.21 starting
1774634449: Config loaded from /etc/mosquitto/mosquitto.conf.
1774634449: Opening ipv4 listen socket on port 1883.
1774634449: Opening ipv6 listen socket on port 1883.
1774634449: mosquitto version 2.0.21 running
1774634459: New connection from 127.0.0.1:36746 on port 1883.
1774634459: New client connected from 127.0.0.1:36746 as nodered82dfbce05e3db765 (p2, c1, k60, u'ckentm').
1774634512: New connection from 192.168.1.221:51122 on port 1883.
1774634512: Client 4004_05 disconnected, not authorised.
1774634517: New connection from 192.168.1.221:60978 on port 1883.
1774634517: Client 4004_05 disconnected, not authorised.
1774634522: New connection from 192.168.1.221:59810 on port 1883.

I hope this is what you are looking for

Charles

Have you got any files in /etc/mosquito/conf.d?

Thanks.

Now please, on the new broker: (Copy & paste the commands onto the Pi if possible to avoid typos)

cat /etc/mosquitto/mosquitto.conf
for f in $(find /etc/mosquitto/conf.d/ -type f); do echo $f; cat $f; echo; done

for Colin. Nothing but README at this point.

for jbudd

ckentm@4004HOME:~ $ cat /etc/mosquitto/mosquitto.conf
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf
per_listener_settings true

pid_file /run/mosquitto/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

allow_anonymous true
listener 1883
password_file /etc/mosquitto/passwd


ckentm@4004HOME:~ $ for f in $(find /etc/mosquitto/conf.d/ -type f); do echo $f; cat $f; echo; done
/etc/mosquitto/conf.d/README
Any files placed in this directory that have a .conf ending will be loaded as
config files by the broker. Use this to make your local config.

It appears the answer is the same.
conf.d is essentially empty

Charles

[Admin Edit: Added triple backticks round the file contents to stop the forum from interpreting it as markdown.

I think there is a conflict between allow_anonymous false and password_file ...

Edit: Senior moment! Sorry I said reboot the router but should have said reboot the broker!

Can you try removing the line password_file /etc/mosquitto/passwd from mosquitto.conf, deleting the mosquitto log as before & rebooting the broker.
Check again if you still get connection & not authorised lines in the new log file.

I understand but I seem to have a had a moment as well as I can not get the RPi to restart. Can't even log in. Be right back

My RPi refuses to start. There seems to be network activity but I don't even get the login screen. Just blank terminal window and after a minute or so it times out and says "no network connection"
I will let you when I get back on

That's frustrating.

Did you in fact reboot the router (as I mistakenly said)?
Does the Pi have a keyboard & monitor attached, or is it "headless"?

No , I didn't reboot the router. and no , it is headless.

These are the commands to restart Mosquitto...

sudo systemctl restart mosquitto
sudo systemctl status mosquitto