Auto Discovery

In the new installation of Ubuntu Server you have the option to install Mosquitto at install time.

Found the file and it is Default with everything hashed out, you were right.

It was in /snap/mosquitto/269
It currently wont let me save the file giving me error messages

There it is and via Ubuntuā€™s now preferred method of using snap (instead of apt).

Check the fileā€™s permissions; it probably belongs to the root account.

In other words, the account you are currently using probably only has ā€œreadā€ permission but not ā€œwriteā€ permission. So you can open the file to view it but you canā€™t save any changes you make.

You can either log in as root or, using your existing account, temporarily raise its privileges to root-level status by prepending sudo to whatever command you execute. For example, if I want to use the nano editor to modify a file (owned by root), Iā€™ll execute it as sudo nano (and then it will prompt me to supply the root accountā€™s password).

Strange I was going to use chmod 775 and then restore after edit.

I can see the file with WINSCP , but when I use the command line to use SUDO it tells me
file does not exits, DIR command shows no files, Oh well onto the UBUNTU site

Its no wonder all those with linux knowledge are old and grey

1 Like

Just looked at ASK UBUNTU it states you cannot modify a file installed with SNAP you have to rebuild it. Its a safeguard to make sure the install has not been tampered with.It does state ways of remounting the file system elsewhere, but looks pretty involved. New install with apt-get is looking pretty tempting right now

That is why I prefer debian over ubuntu :slight_smile:

Like @francisp is liking Debian over ubuntu, I donā€™t care which but I like docker over anything installed on the system. I would not even go for the apt install but go for a docker install.

Given that you installed Home Assistant Supervised, you can simply use its mosquitto addon. Remove the snap-installed instance of mosquitto and proceed to Supervisor > Add-on Store, click Mosquitto broker and follow the instructions.

If you choose to install mosquitto via apt-get, you may eventually need to manage it and that will require skills that you have described as:

You already have easy access to installing mosquitto, as a Home Assistant addon (which is, under the hood, a docker container) so skip apt-get and simplify your life.

Sounds like a good alternative, but I had read people were having problems with the addon of Mosquito with reference to retained messages, which is why I avoided it in the first place.
I think what I will do is put a test system together and try various methods, to see what works and what does not. By the way I knocked up a VM this morning, edited the file as you described and it worked just fine, your a genius.
I have one question for you, if it is now set as retained and I make up test devices which I would like to remove later, I will need to remove the Retained from Mosquitto in order to stop it popping up. I assume I can do this with MQTT Explorer

To remove a topic containing a retained message you simply publish an empty retained message to that topic. That procedure can even be done using Developer Tools > Services and using mqtt.publish with:

topic: your/topic/goes/here
payload: ''
retain: true

Or you can use MQTT Explorer to do it.

Please post links to those posts.

Seems perfect, Im not to bothered about using APT installs, its what I have used in the past. I usually use WINSCP for administration unless it requires root access.
On another subject although English Ilive in Cyprus, the virus has nearly cleared up here after the lockdown.Last Iread we had three new cases. How is it with you, Im guessing you live in the States. The newspapers dont always tell the full story

I tried to execute it but I got the error message in Configuration->Logs

Unable to parse JSON example: '{ "name": "Example", "unique_id": "ABC123", "stat_t": "home/example", "cmd_t": "home/example/set", "bri_stat_t": "home/example/brightness", "bri_cmd_t": "home/example/brightness/set", } '
"bri_cmd_t": "home/example/brightness/set", }
                                          ^
                                          |
                                  Remove this comma

The example contains a typo that only took a year to discover. :slight_smile:

This comma removal works now.

I want to execute the state of the light and brightness. Both do not work with the following:

  example_execute_mqtt_light:
    sequence:
      service: mqtt.publish
      data:
        topic: 'home/example'
        retain: true
        payload: >
           {
             "state": "ON",
             "brightness": 100
           }

  example_execute_mqtt_light_state:
    sequence:
      service: mqtt.publish
      data:
        topic: 'home/example/set'
        payload: "ON"

  example_execute_mqtt_light_brightness:
    sequence:
      service: mqtt.publish
      data:
        topic: 'home/example/brightness/set'
        payload: 50

What goes wrong?