logo elektroda
logo elektroda
X
logo elektroda

How to recover MQTT password from Mosquitto broker in new Home Assistant?

p.kaczmarek2 3528 7
ADVERTISEMENT
  • MQTT broker options window with the password field showing __**password_not_changed**__.
    How to recover lost/forgotten MQTT password without creating new MQTT user, without having to reinstall everything again? Why does my password field reads "__**password_not_changed**__" ? Home Assistant Mosquitto broker behaviour has been recently changed. In the past the password was easily accessible via Home Assistant Devices & Services -> MQTT menu, but now it's hidden. That could have taken some users by suprise (including me), so here's a simple solution.

    So, in the past, Home Assistant MQTT password used to be easily available in Re-Configure MQTT menu:
    Screenshot of MQTT settings in Home Assistant with the Re-Configure MQTT button highlighted.
    It was easy to display it and copy to your devices to configure them. However, with recent update 2024.5, it is not possible to get password there:
    MQTT broker settings message in Home Assistant with password __**password_not_changed**__.
    Luckily you can still get it from core.config_entries. For that, you will need to access this file. I have SMB integration already installed, which makes HA access from Windows easy:
    Screenshot of a Windows window showing a network directory view.
    Of course, any other file access solution should also work, it does not have to be the one I used.
    Connect to it and navigate to path:
    
    /config/.storage/core.config_entries
    

    Note that .storage directory will be hidden:
    Screenshot of a file manager showing the .storage folder in the config directory.
    Now, open this file with any text editor and search for Mosquitto:
    Screenshot of a text editor with an open file showing Mosquitto configuration in Home Assistant.
    and here it is - this your lost MQTT password!
    Of course, do not edit this file, just copy out your password...

    Now you can easily use it to configure your other devices, for example, OpenBeken.

    Screenshot of the MQTT settings interface with filled fields for host, port, client topic, and user.

    That's how you can recover your MQTT Mosquitto password now! I hope you've found it helpful. I must admit, that change has taken me a bit by suprise, I didn't expect HA team to hide this password suddenly, as it was visible in the Re-configure menu for years.... strange, but least we know how to recover it.

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 11798 posts with rating 9919, helped 563 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 21378680
    krzbor
    Level 27  
    Personally, I prefer not to integrate everything in HA. Ideally, Mosquitto should be on a separate machine. Since the MQTT broker is the 'heart' of the entire smart home infrastructure its independence from the other components should be ensured. Thus, we have:
    - MQTT broker - our common point,
    - devices communicating over MQTT, including via Zigbee2MQTT,
    - automation using MQTT (e.g. HA, but I also created such automation in PHP).
    I had a Pi3 a few years old with an old operating system. After a couple of years I found the system severely lagged and had problems with the newer version of Zigbee2MQTT. Recommendations to update the OS - install it from scratch :( .
    I tried some tricks with switching between versions, but the Pi didn't get up again. How do you do automation here that is supposed to work for the next 15-20 years?
    I tried another way - I bought a Pi5 with 8GB RAM and a USB3 SSD to go with it, and managed to install Proxmox on that. I installed Apache+PHP on the mother machine - rather for my own use. Anyway, PHP 5.6 still works well, and it's over 10 years old. There is also Mosquitto on this machine. MQTT is basically a very primitive and simple format. I hope it lasts a long time. Everyone uses the old 3.x version of the format anyway. Now two virtuals - on one HA. This system has updates every month. Before major updates I just stop the VM, make a copy of the image and boot. If something stops working just restore the image. On the other Linux VM I have Zigbee2MQTT. Unfortunately this has to be updated to get new hardware working. And Zigbee2MQTT is written in Node.js. That's why it landed on the virtual machine.
    When everything worked I unplugged the USB drive and made a copy of it to a hard drive (this time to a classic platter HDD). This is exactly why I chose USB3 rather than PCIe.

    There is no problem if we do the automation for ourselves and we know it. We can then swap out both hardware and software components - it's even such an enjoyable hobby. However, what about when we do it for others? I'm not talking about commercial implementation, but for family or friends, for example? The whole thing simply has to work reliably for a long time.
    Is 15-20 years a long time? It certainly is, but I have a control panel that has been running for 25 years and is doing well. Will a Pi5 with a decent passive heatsink do the job? I think so - the software problem remains.
    I'm curious to hear your opinions - how do you make a smart home system "for the years"?
  • ADVERTISEMENT
  • #3 21380300
    @GUTEK@
    Level 31  
    I upgraded Debian 9 (or thereabouts Raspbian) to version 12 on the RPi Zero without too much trouble. Yes in a couple of services I had to tweak the configuration, but everything got up nicely.
    I'm also in favour of splitting services as much as possible, maybe not necessarily on physically different devices, but not keeping everything as an add-on to HA. I happen to be using Docker, so in case of an update, all I need to do is make a copy of the folder with the configuration of the service in question.

    And as for the longevity, I doubt that such an RPi or even a modern non-industrial PC will run you trouble-free for those 15-25 years. Not to mention software support and heaviness. The current Raspbian is basically already too heavy for the first Rpi or thereabouts Rpi Zero, it works, but it muddles.

    In my opinion if you want a system for years only some closed industrial smart home for which someone provides technical support, and even here I doubt any manufacturer would want to support it for so many years. I can see it from the industrial in the robot, if after 10 years the manufacturer provides parts for the machines and some kind of service it is a miracle.
    So my opinion is that you either buy some ready-made system and probably pay a subscription for it, and the manufacturer supports it on an ongoing basis and possibly replaces the obsolete equipment (if such a system exists at all? I don't know because I wasn't interested in this topic) or you carve out such an HA and subordinate services yourself from time to time.
  • ADVERTISEMENT
  • #4 21380945
    krzbor
    Level 27  
    I have Linux with OMV. It has been running for over 8 years now and I think it will still work. It serves mainly as a us and web server. It has a passively cooled Atom. Whether it will last 15 years I don't know, but it will certainly be difficult to install anything new on it - unfortunately that's Linux. Programs I compiled on Windows over 20 years ago on Win 2000 still run on Win 11.
    I decided to go for full virtualisation (rather than containers) because I hope to be able to run a brand new system as a VM years later despite the obsolescence of Proxmox. Additionally, I've read that HA as a container is not the best solution (it's all about add-ons).
    As for durability, I chose the Pi with the hope that it would provide this durability - after all, it is manufactured in Wales, not China.
    Manufacturers' own solutions, is a tempting prospect, but it is an expensive solution and much limited compared to ZigBee or WiFi solutions where we have literally thousands of devices and chips.
    I'd love to read further comments on how to make a smart home 'for the years' My choice:
    Hardware:
    - RPi 5 8GB with passive cooling,
    - SAMSUNG USB drive (T7).
    Software:
    - "mother" is PiOS (unfortunately it is getting old),
    - MQTT - Mosquitto - software should last a long time even without updates,
    - Proxmox for virtualisation (QEMU in general),
    - a virtual machine with Zigbee2MQTT - you can put it up again if you need to, and as a last resort you can put up a second machine with Zigbee2MQTT (or something alternative if it is created) with its own coordinator working on a different channel,
    - HA virtual machine.
  • #5 21382130
    @GUTEK@
    Level 31  
    Among other things, this is why Docker and the like were created, so that you don't have to struggle with dependencies for a particular version of an application. Just fire up a ready-made image with whatever libraries it needs.
    The Windows perpetual compatibility crap is also a bad thing, as the system is now a patch on a patch of old libraries.
    Those add-ons you write about in HA are simply services running in Docker, only managed then from within HA. And I just have them running separately and that's it. On the other hand, HA sits nicely in a container, it has its own directory with the database and configuration. There is a separate container for MQTT and Z2M and that is the difference.
  • ADVERTISEMENT
  • #6 21382158
    xury
    Automation specialist
    I, on the other hand, am in favour of native installations of everything I can. Of course HA can't be installed, so it's in a container, as well as a couple of its add-ons that don't come natively (e.g. Frigate, ESP Home). The rest is only natively, so I still have a lot of free RAM and CPU despite quite a number of services. I don't understand virtualisation on Dell Wyse toys, especially just to install HA only on Proxmox.
  • #7 21382398
    krzbor
    Level 27  
    xury wrote:
    I don't understand virtualisation on Dell Wyse type toys, especially just to install HA only on Proxmox.
    Personally I appreciate virtualisation. Its biggest advantage is the ability to easily make a copy of a virtual machine. The QCOW2 format is quite stable over time which makes it easy to move machines around. The ability to remotely help someone (or yourself if the machine is operated remotely) is also an advantage. Normally it would be: "it doesn't start". If you can connect to a monitor then maybe we can at least get a picture of the failed boot screen. With virtualisation we can see everything ourselves and, if necessary, restore the previous working version.
  • #8 21566147
    kuncy7
    Level 9  
    What I am interested in is not how to recover, but how to change!
    I have several clients configured and would like to connect them to a new HA installation with the MQTT add-on.
    It seemed to me that it would be simpler to change the login and password on the new HA installation than to change the login and password on several(dozen) clients.
    Unfortunately I have fallen down on this problem.
    Is it possible to change this generated password and user (I still have from domoticz)?

Topic summary

The discussion revolves around recovering a lost MQTT password from the Mosquitto broker in Home Assistant without creating a new user or reinstalling the system. Users noted that the password was previously accessible through the Home Assistant interface but has been hidden in recent updates. A workaround involves accessing the password from the core.config_entries. Participants also shared insights on the benefits of separating the MQTT broker from Home Assistant, using Docker for service management, and the longevity of Raspberry Pi devices for smart home setups.
Summary generated by the language model.
ADVERTISEMENT