Add MQTT support for real-time communication alongside existing HTTP API#19
Draft
Add MQTT support for real-time communication alongside existing HTTP API#19
Conversation
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] create models for MQTT based on current models
Add MQTT support for real-time communication alongside existing HTTP API
Jun 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements MQTT communication support while maintaining 100% backward compatibility with the existing HTTP API. The integration follows the requirement to "keep the models as close as they currently are" by wrapping existing models in MQTT-specific containers without modifying the original model definitions.
Key Features
✅ Zero Breaking Changes
Person,Plant,Sensor,SensorResult) remain completely unchanged✅ MQTT Integration
MQTT_ENABLED=true✅ Real-time Capabilities
leaf-lab/person/createdleaf-lab/plant/{plant_id}/sensor/{sensor_id}/readingUsage Examples
HTTP-only (unchanged default):
HTTP + MQTT:
MQTT Message Format:
{ "sensorResult": { "id": 1, "plant_id": 1, "sensor_id": 1, "value": "25.5", "as_of": "2025-06-03T00:26:17.617168388Z" }, "messageId": "uuid-string" }Architecture
The implementation adds MQTT as a parallel communication channel:
Testing
All tests pass and demonstrate proper JSON serialization, topic generation, and model preservation.
Repository Impact
build.sbt(1 dependency),Main.scala(MQTT initialization)Models.scala,Service.scala,Repository.scala,Database.scalaThis implementation provides a foundation for transitioning to MQTT while maintaining all current functionality and allowing gradual migration.
Fixes #18.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https(dns block)git.iocurl -Ls REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.