Table of Contents
MQTT Message Bus
Hostname: mqtt.hacklab
Port: 1883
Warning
- Do not use the MQTT network for evil.
- Do not annoy other lab users (especially with sound or lighting).
- Do not be the reason for new rules.
Quick Example
mosquitto_sub -h mqtt.hacklab -t '#' -v # listen to all messages mosquitto_sub -h mqtt.hacklab -t 'sensor/g1/temperature' -v # listen to a single topic mosquitto_pub -h mqtt.hacklab -t 'display/g1/leds' -m red # send a message mosquitto_pub -h mqtt.hacklab -t 'dali/g1/preset/harmony' -n # send an empty message
Devices
Sensors
| Topic | Payload | Notes |
|---|---|---|
| sensor/g1/lightlevel | 0-100 | |
| sensor/g1/temperature | float, deg-C | |
| sensor/g11/temperature/28767aa8040000cf | float, deg-C | Store Room, supply fan |
| sensor/g11/temperature/28c483a704000069 | float, deg-C | Store Room, extract fan |
| sensor/g11/temperature/28c893a704000068 | float, deg-C | Store Room, corridor outside |
| Topic | Payload | Notes |
|---|---|---|
| sensor/g1/pir | (none) | Sent when PIR sensor is triggered in G1 |
| sensor/g2/pir | (none) | Sent when PIR sensor is triggered in G2 |
| sensor/g8/pir | (none) | Sent when PIR sensor is triggered in G8 |
| sensor/g11/pir | (none) | Sent when PIR sensor is triggered in G11 |
| sensor/g1/presence | active/idle/empty | |
| sensor/g2/presence | active/idle/empty | |
| sensor/g8/presence | active/idle/empty | |
| sensor/g11/presence | active/idle/empty | |
| sensor/global/presence | active/idle/empty | Summary of the per-room status (e.g. if any room is “active” then the global output is also “active”) |
| sensor/g1/window | Always reports open | |
| sensor/g11/current/1 | float, amps | |
| sensor/g1/fridge | seconds | Number of seconds that the fridge door has been open, 0 means “closed” |
| fridge-door/status | open/closed | Generated by a script on ehl-vm-things |
Lab Status
This sets the labs public open/closed status. Changing the value will cause an IRC notification and changes on SpaceAPI and the website. A notification will also appear on https://twitter.com/edinhacklabopen.
| Topic | Payload | Notes |
|---|---|---|
| labstatus | open, closed |
When updating, the message should be sent with retain=True.
Tools
| Topic | Payload | Notes |
|---|---|---|
| tool/lasercutter/active | 0=no, 1=yes | Is the laser cutter running a job? |
| tool/lasercutter/power | 0-1023 | |
| tool/lasercutter/temperature/ambient | float, deg-C | Air temperature near the device |
| tool/lasercutter/temperature/reservoir | float, deg-C | Water temperature in the main reservoir |
| tool/lasercutter/temperature/chiller | float, deg-C | Water temperature in the chiller reservoir |
| tool/lasercutter/time/power | float, seconds | Time spent powered-up |
| tool/lasercutter/time/session | float, seconds | Time spent in a cutting session |
| tool/lasercutter/time/cutting | float, seconds | Time spent with the laser active |
| tool/lasercutter/time/analog | float, seconds | Time spent with the laser active, adjusted by power level |
| tool/lasercutter/pulse_count | integer | |
| tool/lasercutter/error_count | integer | |
| tool/lasercutter/combined_laser_stats | json | Legacy formatted data for compatibility with existing script |
| tool/lasercutter/combined_temperature_stats | json | Legacy formatted data for compatibility with existing script |
| tool/dustextractor | 0=off, 1=on | Control the big dust extractor in the workshop |
Access-controlled tools (read-only values):
| Topic | Payload | Notes |
|---|---|---|
| tool/<id>/status | active, standby, idle, offline | |
| tool/<id>/user | string, username | current or previous username |
| tool/<id>/current | float, amps | |
| tool/<id>/sketch_md5 | string | md5 of currently-running firmware |
Environment
| Topic | Payload | Notes |
|---|---|---|
| environment/g1/air_purification_level | none, extract, extract_and_filter, extract_and_big_filter | Controls extraction and small+big filters. Preferred over addressing directly. Runs on carbon.hacklab:/srv/docker/py3scripts/scripts/g1-air-control |
| environment/g1/extractor | 0=off, 1=on | Controlled by ESP32-S2 relay board. Debugging feedback availble on debug/esp-487f307d5dad |
| shellies/g1/right_ceiling_filter/relay/0/command, shellies/g1/left_ceiling_filter/relay/0/command | on/off | Small air purifiers on the ceiling |
| plug/g1_big_filter/cmnd/POWER | on/off | Big air purifier next to the electronics corner |
| environment/g1/heating | 0-30, off | Send a numeric value to set a target temperature for G1, off to turn the heating off. Mark the message as retained in case the thermostat script is restarted. |
| environment/g2/heating | 0-30, off | Send a numeric value to set a target temperature for G2, off to turn the heating off. Mark the message as retained in case the thermostat script is restarted. |
| environment/g8/extraction | off/on | Wall extractor in workshop |
| environment/g14/heating | 0-30, off | Send a numeric value to set a target temperature for G14, off to turn the heating off. Mark the message as retained in case the thermostat script is restarted. |
Lighting
The ceiling lights in the main (G1) room and G14 are connected via a DALI bus. They can be controlled by selecting a preset, setting individual light levels or by passing a script.
| Topic | Payload | Notes |
|---|---|---|
| dali/g1/preset/<preset> | (none) or <light-id> | preset=off/dim/bright/corners/movie/comfort/presentation/harmony or preset=<number> (use payload to apply the preset to a group of lights) |
| dali/g14/preset/<preset> | (none) or <light-id> | preset=off/dim/bright/comfort (use payload to apply the preset to specific lights) |
| dali/g1/set/<light-id> | 0-254 | light-id=0-17, light-id=all, or light-id=group (also supports multiple comma-separated values and ranges) |
| dali/g14/set/<light-id> | 0-254 | light-id=18,21-23, light-id=all (also supports multiple comma-separated values and ranges) |
| Topic | Payload | Notes |
|---|---|---|
| display/g1/blacklights/relay/0/set | 0=off 1=on | Switch the G1 blacklight on/off |
Displays
Doorbot
The wooden box by the door in G1, with two buttons and a 16×2 LCD:
| Topic | Payload | Notes |
|---|---|---|
| display/doorbot/message | text | Two lines of 16 characters each. Use \n to separate lines. |
| display/doorbot/flash | text | As for message, but original message will be restored after 2 seconds. |
| display/doorbot/contrast | 0-255 | |
| display/doorbot/backlight | 0-255 | |
| display/doorbot/buttons/red/shortpress | (none) | Sent by device, do not write |
| display/doorbot/buttons/red/longpress | (none) | Sent by device, do not write |
| display/doorbot/buttons/red/state | up, down | Sent by device, do not write |
| display/doorbot/buttons/green/shortpress | (none) | Sent by device, do not write |
| display/doorbot/buttons/green/longpress | (none) | Sent by device, do not write |
| display/doorbot/buttons/green/state | up, down | Sent by device, do not write |
G1 LED strip (the one that goes around the edge of the room)
| Topic | Payload | Notes |
|---|---|---|
| display/g1/leds | <colour> | css3 web colours or hex values (e.g. ff0000) |
| display/g1/leds | <preset> | choose name from list below |
| display/g1/leds/brightness | [0-100] | changes the brightness of the leds to n percent |
| display/g1/leds/picker/json | <json> | When in the pixelpicker preset send the following example payload, '{“1”:[255, 255, 0], “2”:[0, 0, 255]}' , this will set LED 1 to yellow, and LED 2 to blue |
Presets
- rainbow
- zap
- chase
- test
- pixelpicker
- redalert
- emergency
- xmas
- cyber
- lmanberg
Pride flags
- lessbeans / lesbinyan
- nyanbinary
- pan
- trains / trams
The LEDs can also be addressed in real time via a UDP network protocol. See this example.
The strip is controlled by ledpi.hacklab, a pi 2 in the corner of the ceiling of G1. All code is in /opt/leds/. See README there for more info.
G1 LED String
The one that goes across the ceiling in the middle of the room.
These are running the WLED firmware, which is ridiculously comprehensive and can talk to basically everything. However, MQTT seems to have been disabled.
There is a web interface at http://wled-ceiling-string-a.hacklab.
Full MQTT docs at https://github.com/Aircoookie/WLED/wiki/MQTT
^ Topic ^ Payload ^ Notes ^
| display/g1/wled/$STRIP_NAME | 0-255, “ON”, “OFF”, or “T” | “T” means toggle |
| display/g1/wled/$STRIP_NAME/col | #RRGGBB | |
|||STRIP_NAME can be replaced with “dangle” for the strip dangling in G1 or “all” for every strip running this firmware in G1|
G1 Light Turret
See also: Light Turret
| Topic | Payload | Notes |
|---|---|---|
| display/g1/turret/red | 0=off 1=on | Turns on the red band on the Turret light |
| display/g1/turret/amber | 0=off 1=on | Turns on the amber band on the Turret light |
| display/g1/turret/green | 0=off 1=on | Turns on the green band on the Turret light |
New Window display
| Topic | Payload | Notes |
|---|---|---|
| display/g1/windowled/text | text | seems to slow down render with large text |
| display/g1/windowled/colour | r,g,b | comma separated string of red, green, and blue (0-255) Takes effect on next text change |
| display/g1/windowled/warning/red | text | |
| display/g1/windowled/warning/amber | text | |
| display/g1/windowled/warning/yellow | text |
Chart
The blinky chart of the West of Scotland in G1.
Note: Lighting mode may be overriden by hardware nya nya switch.
| Topic | Payload | Notes |
|---|---|---|
| display/chart/mode | rainbow, normal | Engage nya nya rainbow mode, or normal light colours / patterns. |
Access Control
Code for this can be found on ehl-vm-things:/srv/docker/py3scripts/entrance-handler
The door is opened by a small ESP8266 and a relay connected to the intercom phone under the IRC terminal in G1
| access/entrance/request | Button has been pressed at the entrance read only | |
| access/entrance/release | Release the entrance door (for 2 seconds) |
Sound
| Topic | Payload | Notes |
|---|---|---|
| sound/[room]/play | filename | Sound files must be installed on squawk |
| sound/[room]/speak | text | |
| sound/[room]/announce | text | |
| sound/[room]/polly/[voice] | text | See voice list at https://docs.aws.amazon.com/polly/latest/dg/voicelist.html |
| sound/kill | empty message | Kills all queued and/or playing sounds |
| | | |
| sound/time-out | seconds | Kill all playing sounds and remain silent for N seconds |
Replace [room] with one of g1, g2, g8, g11, or all. Room names can also be combined. e.g. “g1-g2-g8”
Sound effects get annoying fast. Don't say we didn't warn you.
JeeNode Radios
| Topic | Payload | Notes |
|---|---|---|
| rf/jeenode868/received/<network>/<node> | {“node”: 10, “line”: “OK 10 77 8 160 2”, “data”: “TQigAg==”, “network”: 38} | Received message |
| rf/jeenode868/send | binary data | Transmit a message |
OOK Radios
On-Off keying for remote controlled mains sockets.
| Topic | Payload | Notes |
|---|---|---|
| rf/ook433/send/homeeasy2/<controller>/<device> | 0, 1 | controller=0-67108863 device=0-15 |
| rf/ook433/send/homeeasy2/program/<controller>/<device> | 0, 1 |
Space API
Space API is a standard for publishing data about Hackerspaces. Our data is generated at http://spaceapi.edinburghhacklab.com/spaceapi.json. The sensors section of the data can be extended by sending messages:
| Topic | Payload | Notes |
|---|---|---|
| spaceapi/sensors/<type> | json | type is the sensor type as specified in the Space API specification. The payload is a JSON dictionary of the format given in the Space API specification. |
e.g. a temperature reading - type=temperature
{
"_ttl": 300,
"location": "In a deep dark hole",
"value": 3.14,
"unit": "\u00b0C"
}
_ttl=300 will cause the entry to expire after 5 minutes (change this to be 2-3x your update interval).
IRC
| Topic | Payload | Notes |
|---|---|---|
| irc/send | JSON | {“to”: “#edinhacklab”, “message”: “Hello World”} |
| irc/receive | JSON | {“channel”: “#edinhacklab”, “sender”: “timvik”, “message”: “Hello World”, “action”: false} |
| irc/status/connected | (none) | Read Only |
| irc/status/join | JSON | {“channel”: “#edinhacklab”, “user”: “timvik”} Read Only |
Time Signals
These are beacons that can be used as time-based callbacks. This allows simple scripts to be written, driven only by incoming MQTT events.
| Topic | Payload | Notes |
|---|---|---|
| timesignal/60 | (none) | Sent every 60 seconds by the “timesignal” script |
| timesignal/300 | (none) | Sent every 5 minutes |
| timesignal/600 | (none) | … |
| timesignal/1800 | (none) | … |
| timesignal/3600 | (none) | … |
| timesignal/86400 | (none) | … |
Misc
| Topic | Payload | Notes |
|---|---|---|
| stats/member_count | n | Number of members |
| time-since-last/reset | <name> | Reset “time since last” timer <name> |
| stock/<item-name>/in/<location>/add | <quantity> | Add <quantity> of <item-name> to <location> |
| stock/<item-name>/in/<location>/remove | <quantity> | Remove <quantity> of <item-name> from <location> |
| stock/<item-name>/in/<location>/current | <quantity> | Read Only: There is <quantity> of <item-name> in <location> |
| stock/<item-name>/in/<location>/important | 0-1 (retain) | Report when we run out of <item-name> in <location>, or are running low (see minimum below) |
| stock/<item-name>/in/<location>/minimum | 2-n (retain) | Report when we have fewer than <n> of <item-name> in <location> |