This application allows users to create and manage custom dashboards featuring various IoT devices. Devices communicate via MQTT and can be dynamically controlled and monitored through a user-friendly web interface. Features
Users can create personalized dashboards that aggregate controls and information from multiple devices.
Users can create an arbitrary number of devices that connect to the application, provided they adhere to a specified communication protocol.
Devices can perform various actions such as toggle, number input, provide value, and execute commands based on their capabilities.
Devices can post state updates and respond to commands dynamically via MQTT topics.
Device types are pre-configured with applicable actions to simplify setup.
Each device integrated into the system must support the following MQTT topics and functionalities (note that all "uuid" parameters are generated on the end device side):
- Devices must be able to connect to a mqtt broker, which is specified in the env.list file
- login/request/uuid: Devices post to this topic to request login.
- login/response/uuid: Devices subscribe to this topic to receive login confirmation and initial configuration, like receiving their last available state, before they went offline for example.
- state/uuid: Devices post their current state updates to this topic, for example when a device is commanded to do something, it posts to this topic notifying it executed the command properly.
Actions are specified in this format: "action_name" : "type_of_action" and must be encoded into one json
Devices can currently support these types of actions:
- toggle: Toggle between two states (typically on/off actions).
- number_input: Adjust a setting using numeric input (typically to set interval of gaps between data readings).
- provide_value: Provide data readings (typically sensor data).
- command: Execute a specific command or action (a specific action that the device is capable of).
The system supports several pre-configured templates that define standard actions for common types of IoT devices. Devices send their device type in the login packet, and are therefore expected to support the advertised functionality. Below is a list of device types with their pre-defined respective action templates:
light_switch
Template actions: {"Light_state": "toggle"}
temperature_sensor
Template actions: {"Interval_ms": "number_input", "Temperature": "provide_value"}
soil_moisture_sensor
Template actions: {"Interval_ms": "number_input", "Soil_moisture": "provide_value"}
humidity_sensor
Template actions: {"Humidity": "provide_value", "Interval_ms": "number_input"}
Example of connecting to the system with light switch device, that is also capable (for whatever reason) to have extra toggle and number_input functionality.
If the device type matches one of the previous ones, the system will automatically suppose this device is capable of the specified functionalities.
Serial.print("Attempting MQTT connection...");
if (mqttClient.connect(mqttClientId)) {
Serial.println("connected");
StaticJsonDocument<200> loginDoc;
loginDoc["uuid"] = "here goes your generated uuid";
loginDoc["name"] = "light_switch_bedroom";
loginDoc["device_type"] = "light_switch";
loginDoc["custom_actions"] = "json string of custom actions, can look like this or can be empty ->
{"action_name_1": "toggle", "action_name_2": "number_input"}"
char loginJsonBuffer[512];
serializeJson(loginDoc, loginJsonBuffer);
mqttClient.subscribe(login_response_topic.c_str());
mqttClient.publish(login_request_topic.c_str(), loginJsonBuffer);
Setup and Configuration
Run PostgreSQL+Timescale DB, Mosquitto broker and web server with gui by executing this command in the root directory:
docker compose up