Difference between revisions of "MQTT"

From RevSpace
Jump to navigation Jump to search
m
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Revspace currently pushes some MQTT/Moquitto messages to a mosquitto (mqtt) server running on gateway. The messages are also bridged to the public test.mosquitto.org server.
+
== Live sensortjes gluren ==
 +
 
 +
https://revspace.nl/maquette/
 +
 
 +
(Experimenteel, net als alles.)
 +
 
 +
== Saaie informatie, redelijk achterhaald ==
 +
 
 +
 
 +
Revspace currently pushes some MQTT/Moquitto messages to a mosquitto (mqtt) server running on mosquitto.revspace.nl. The messages are also bridged to the public test.mosquitto.org server.
 
Since mosquitto also runs on IPv6, you can subscribe to the internal server (if you have ipv6)
 
Since mosquitto also runs on IPv6, you can subscribe to the internal server (if you have ipv6)
  
We are currently using the namespace '/revspace/'
+
We are currently using the namespace 'revspace/'
  
 
Under this namespace we currently send messages for:
 
Under this namespace we currently send messages for:
 
<ul>
 
<ul>
<li>/revspace/sensors/co2  -- The current value on the co2 meter
+
<li>revspace/sensors/co2  -- The current value on the co2 meter
<li>/revspace/button/skip - skip button for the music
+
<li>revspace/sensors/#-t#  -- Temperature sensor (Zone, Sensor-nr), Zone 2 is the basement
<li>/revspace/button/stop - stop button for the music
+
<li>revspace/power/group##/minute -- Powerusage for this power group in W-h over the last minute (pulsecount / 2 * 60)
<li>/revspace/button/shuffle - shuffle-play for the music
+
<li>revspace/power/group##/hour -- Powerusage for this power group in W-h over the last hour (pulsecount / 2)
<li>/revspace/button/nomz - NOMZ button pressed
+
<li>revspace/power/group##/pulse -- Fires once for every 0.5W-h of power used in the group
 +
<li>revspace/button/skip - skip button for the music
 +
<li>revspace/button/stop - stop button for the music
 +
<li>revspace/button/shuffle - shuffle-play for the music
 +
<li>revspace/button/nomz - NOMZ button pressed
 +
<li>revspace/state -- Space state (open|closed)
 +
<li>revspace/music/klusbunker/volume -- Music volume (0-100)
 +
<li>revspace/music/klusbunker/mode  -- Music mode (play|stopped)
 +
<li>revspace/music/klusbunker/np  -- Music: Now playing (artist/title)
 +
<li>revspace/spacesucker/level -- fan speed level in %
 +
<li>revspace/spacesucker/mode -- auto/manual/demoist/wait/refresh
 +
<li>many more (geiger/nose/cams/doorduino etc.), check it out!
 
</ul>
 
</ul>
  
 +
'''Update 2014/04/26''' Around 00:00 we switched from '/revspace/#' to 'revspace/#' ... to fit with the MQTT standard better
  
 
To receive/subscribe to these messages, download mosquitto-clients, or a MQTT library and write your own client.
 
To receive/subscribe to these messages, download mosquitto-clients, or a MQTT library and write your own client.
Line 18: Line 39:
 
For mosquitto-clients, use:
 
For mosquitto-clients, use:
 
   (public server)
 
   (public server)
   mosquitto_sub -h test.mosquitto.org -t "/revspace/#" -v
+
   mosquitto_sub -h test.mosquitto.org -t "revspace/#" -v
 
or:
 
or:
 
   (revspace internal or ipv6 server)
 
   (revspace internal or ipv6 server)
   mosquitto_sub -h bar.space.revspace.nl -t "/revspace/#" -v
+
   mosquitto_sub -h mosquitto.space.revspace.nl -t "revspace/#" -v
  
  
For debian users... please use the following repository, as the packages in debian are ancient:
+
<strike>For debian users... please use the following repository, as the packages in debian are ancient:
 
   http://mosquitto.org/2013/01/mosquitto-debian-repository/
 
   http://mosquitto.org/2013/01/mosquitto-debian-repository/
   deb http://repo.mosquitto.org/debian wheezy main
+
   deb http://repo.mosquitto.org/debian wheezy main</strike>
 +
 
 +
== Server Side Events ==
 +
 
 +
JavaScript example, see for example https://bewaar.me/mqtt/#
 +
 
 +
var stream = new EventSource('https://revspace.nl/mqtt?revspace%2F%23=');
 +
stream.onmessage = function(e) {
 +
  var data = JSON.parse(e.data);
 +
  if (data.length !== 3) throw 'invalid data';
 +
}
 +
 
 +
== Scripts ==
 +
 
 +
* The power monitoring script is 'powermonitor' and runs as 'spaceloop' user on gateway
 +
* The CO2/NOMZ/SKIP/SHUF script is '/root/rf24skip/skip.pl', and runs on squeezebox-klusbunker
 +
* The music related events come from '/home/bar/squeezen/now-playing.pl' running as 'spaceloop' on gateway
 +
* The spacestate messages and unlocked messages come from 'slmonitor', running as 'spaceloop' on gateway
 +
* The temperature messages come from 'slmonitor', running as 'spaceloop' on gateway

Revision as of 19:18, 17 November 2016

Live sensortjes gluren

https://revspace.nl/maquette/

(Experimenteel, net als alles.)

Saaie informatie, redelijk achterhaald

Revspace currently pushes some MQTT/Moquitto messages to a mosquitto (mqtt) server running on mosquitto.revspace.nl. The messages are also bridged to the public test.mosquitto.org server. Since mosquitto also runs on IPv6, you can subscribe to the internal server (if you have ipv6)

We are currently using the namespace 'revspace/'

Under this namespace we currently send messages for:

  • revspace/sensors/co2 -- The current value on the co2 meter
  • revspace/sensors/#-t# -- Temperature sensor (Zone, Sensor-nr), Zone 2 is the basement
  • revspace/power/group##/minute -- Powerusage for this power group in W-h over the last minute (pulsecount / 2 * 60)
  • revspace/power/group##/hour -- Powerusage for this power group in W-h over the last hour (pulsecount / 2)
  • revspace/power/group##/pulse -- Fires once for every 0.5W-h of power used in the group
  • revspace/button/skip - skip button for the music
  • revspace/button/stop - stop button for the music
  • revspace/button/shuffle - shuffle-play for the music
  • revspace/button/nomz - NOMZ button pressed
  • revspace/state -- Space state (open|closed)
  • revspace/music/klusbunker/volume -- Music volume (0-100)
  • revspace/music/klusbunker/mode -- Music mode (play|stopped)
  • revspace/music/klusbunker/np -- Music: Now playing (artist/title)
  • revspace/spacesucker/level -- fan speed level in %
  • revspace/spacesucker/mode -- auto/manual/demoist/wait/refresh
  • many more (geiger/nose/cams/doorduino etc.), check it out!

Update 2014/04/26 Around 00:00 we switched from '/revspace/#' to 'revspace/#' ... to fit with the MQTT standard better

To receive/subscribe to these messages, download mosquitto-clients, or a MQTT library and write your own client.

For mosquitto-clients, use:

 (public server)
 mosquitto_sub -h test.mosquitto.org -t "revspace/#" -v

or:

 (revspace internal or ipv6 server)
 mosquitto_sub -h mosquitto.space.revspace.nl -t "revspace/#" -v


For debian users... please use the following repository, as the packages in debian are ancient:

 http://mosquitto.org/2013/01/mosquitto-debian-repository/
 deb http://repo.mosquitto.org/debian wheezy main

Server Side Events

JavaScript example, see for example https://bewaar.me/mqtt/#

var stream = new EventSource('https://revspace.nl/mqtt?revspace%2F%23=');
stream.onmessage = function(e) {
  var data = JSON.parse(e.data);
  if (data.length !== 3) throw 'invalid data';
}

Scripts

  • The power monitoring script is 'powermonitor' and runs as 'spaceloop' user on gateway
  • The CO2/NOMZ/SKIP/SHUF script is '/root/rf24skip/skip.pl', and runs on squeezebox-klusbunker
  • The music related events come from '/home/bar/squeezen/now-playing.pl' running as 'spaceloop' on gateway
  • The spacestate messages and unlocked messages come from 'slmonitor', running as 'spaceloop' on gateway
  • The temperature messages come from 'slmonitor', running as 'spaceloop' on gateway