How to subscribe using mosquitto_sub with HassOS?

Sorry if this is a stupid question…when I used the ResinOS based Hassio on my RPi, I could SSH in and use the mosquitto_sub command to see the messages from my sensors. I can’t figure out how to do this on the new HassOS based system. I’ve tried at the hassio prompt (which I knew wasn’t going to work):

hassio > mosquitto_sub -h 192.168.0.10 -u redactedusername -P redactedpassword -v -t “#”
hassio: ‘mosquitto_sub’ is not a hassio command. See ‘hassio --help’.

and then I tried logging in

hassio > login
~ # mosquitto_sub -h 192.168.0.10 -u redactedusername -P redactedpassword -v -t “#”
/bin/ash: mosquitto_sub: not found

but that didn’t work either. I have to admit I don’t know much about using the host system.

Can anyone point me in the right direction? Thanks!

ssh in and it will be there.

I said in my question that I did ssh in but I don’t know how to make it work. Could you explain in more detail?

HassOS is a managed environment, and when you SSH into the “machine”, you’re actually connecting to an isolated container. (It’s possible to SSH in to the actual underlying system for development, however the environment is very bare-bones and it’s not recommended that you do this.) This is why you cannot manually install anything through the shell. I recommend that you use this add-on to test out MQTT.

PS. Use this link to add the community addon repo: https://github.com/hassio-addons/repository

1 Like

Thank you very much. I’ll check it out. I have been using the Mosquitto add-on from the official add-ons, and didn’t realize there was another choice. Thanks for your reply and the information.

No problem. Glad I helped.

When you set up the ssh addon for hassio and then ssh, mosquitto_sub is available on the commandline. I have no mosquitto addon set up.

@nickrout Are you using HassOS? I have the SSH add-on set up, I use Putty to SSH in and log in as root, I get the Hassio CLI. It tells me mosquitto_sub is not a valid command. I don’t understand what you are doing to get mosquitto_sub available on the command line. I could do it as you are describing when I used the ResinOS version, but not now.

I am using the hassio vmdk file on virtualbox. I can’t work out how hassio/hassos is built, perhaps there is a difference in the builds?

yeah there is a difference in what is available with hassOS - based on buildroot. different to installing on linux or a venv.where you have full access to a real underlying OS.

I am not installed on a venv or over the top of a linux system. It is hassos inside virtualbox (on windows 10).

I didn’t know that was even possible…

Under the heading “As a virtual appliance:”

Thanks Nick. I’m using Hass.io but as a generic linux install.

What does uname -a from a command prompt give you?

From ssh login

Linux core-ssh 4.14.82 #1 SMP Wed Nov 21 10:50:27 UTC 2018 x86_64 Linux

On the virtualbox console

Linux hassio 4.14.82 #1 SMP Wed Nov 21 10:50:27 UTC 2018 x86_64 Linux

Interesting… so it’s using the underlying Linux it seems… I guess that explains why it’s different to Hassio on a Pi…