Difference between revisions of "Automation - MQTT"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
(Created page with "*Proven on Mint 19.3 *Proven on SparkyLinux 5.11 *Proven on raw Debian (With a caveat) [https://mosquitto.org/ Mosquitto MQTT Broker] == Installing Mosquitto == *<code>sudo apt-get install mosquitto</code> Pretty simple, eh? === Ensure that Mosquitto broker is running === *<code>sudo service mosquitto status</code> expected result is <u><code>Active: active (running)</code></u> == Install client tools for testing etc == (Do this on any machine expected to manually...")
 
Line 1: Line 1:
*Proven on Mint 19.3
*Proven on Mint 19.3
*Proven on SparkyLinux 5.11
*Proven on SparkyLinux 5.11
*Proven on raw Debian (With a caveat)
*Proven on raw Debian (With a [[#Debian Caveat{{!}}caveat]])
[https://mosquitto.org/ Mosquitto MQTT Broker]
[https://mosquitto.org/ Mosquitto MQTT Broker]


== Installing Mosquitto ==
= Installing Mosquitto =


*<code>sudo apt-get install mosquitto</code>
*<code>sudo apt-get install mosquitto</code>
Pretty simple, eh?
Pretty simple, eh?


=== Ensure that Mosquitto broker is running ===
== Ensure that Mosquitto broker is running ==


*<code>sudo service mosquitto status</code>
*<code>sudo service mosquitto status</code>
expected result is <u><code>Active: active (running)</code></u>
expected result is <u><code>Active: active (running)</code></u>


== Install client tools for testing etc ==
== Debian Caveat ==
 
= Install client tools for testing etc =


(Do this on any machine expected to manually use MQTT)
(Do this on any machine expected to manually use MQTT)
Line 20: Line 22:
*<code>sudo apt install mosquitto-clients</code>
*<code>sudo apt install mosquitto-clients</code>


=== Testing ===
== Testing ==


==== In a terminal: ====
=== In a terminal: ===


*<code>mosquitto_sub -h localhost -t "mqtt" -v</code>
*<code>mosquitto_sub -h localhost -t "mqtt" -v</code>


==== In another terminal: ====
=== In another terminal: ===


*<code>mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"</code>
*<code>mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"</code>

Revision as of 17:13, 11 January 2022

  • Proven on Mint 19.3
  • Proven on SparkyLinux 5.11
  • Proven on raw Debian (With a caveat)

Mosquitto MQTT Broker

Installing Mosquitto

  • sudo apt-get install mosquitto

Pretty simple, eh?

Ensure that Mosquitto broker is running

  • sudo service mosquitto status

expected result is Active: active (running)

Debian Caveat

Install client tools for testing etc

(Do this on any machine expected to manually use MQTT)

  • sudo apt install mosquitto-clients

Testing

In a terminal:

  • mosquitto_sub -h localhost -t "mqtt" -v

In another terminal:

  • mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"

Now the message “mqtt Hello MQTT” will be displayed in the first terminal where the topic “mqtt” is subscribed.

Subscribing to # gives you a subscription to everything except for topics that start with a $ (these are normally control topics anyway).