Skip to content

Service: MQTT Broker

Mario R edited this page Jul 14, 2021 · 29 revisions

Service description

MQTT mosquitto-eclipse opn-source brocker

Common topic convention

"$service-name/$service-ID/" + ├── "config"
                               ├── "value/$value-name/" + ├── "state"
                                                          ├── "setpoint"
  • $service-name - container name
  • $service-ID - ID of the service if it implements multiple hubs (i.e: multiple Arduinos reading the same data). In case of single-ID service put "0"
  • "config" - topic with this tag includes configuration info of the services, to administrate global parameters
  • "value" - tag for value logging
  • $value-name - clarifies the physical name of the logged values (could not only be one value, can include multy-value JSON-messages)
  • "state" - tag to identify a sensor log
  • "setpoint" - tag to identify an actuator set value

Examples:

topic: "environment-service/0/value/brightness/state" - for logging brightness sensor data on the pi-1 device, 0-service-ID message: {"brightness":0.76,"timestamp":1622406177} "environment-service/0/value/brightness/setpoint" - for defining desired brightness value message: {"lights":true}


Used topics and their functions

Please describe all used topics with message examples here. Messages should be transported in JSON format.

climate-service

  • Sensors state: "climate-service/0/value/sensors/state" - {"brightness":0.91,"temperature":24.93,"humidity":0.57,"aircondition":0.42}
  • Actuators state: "climate-service/0/value/actuators/state" - {"light":false,"thermostat":true,"humidifier":true, "airfilter":true}

time-slot-booking

  • Booked occupancy for the week: "time-slot-booking/0/value/booking/state"
{
  "firstname": "Max",
  "lastname": "Muster",
  "email": "[email protected]",
  "bookings": [
    { "week": 0, "slot": 0 },
    { "week": 0, "slot": 1 }
  ]
}

time-slot-validation

  • Message to open door if booking was valid: "time-slot-validation/0/value/door/setpoint" - {"open": true} "time-slot-validation/0/value/door/state" - {"validToken": true}

door-service

  • Opening the door: "door-service/0/value/door/state" - `{"open":true}

control-dashboard

  • Temperature setpoint: "control-dashboard/0/value/temperature/setpoint" - {"set": 21}
  • Humidity setpoint: "control-dashboard/0/value/humidity/setpoint" - {"set": 0.57}
  • Brightness setpoint: "control-dashboard/0/value/brightness/setpoint" - {"set": 0.54}
  • Air condition setpoint: "control-dashboard/0/value/aircondition/setpoint" - {"set": 0.51}

decision-maker

  • Actuators setpoint: "decision-maker/0/value/actuators/setpoint" - {"thermostat": False, "humidifier": False, "airfilter": False, "light": False}