Scenario Synchronization with Equipment
Synchronization is the step that transfers your scenarios from the database to the Logic Controller equipment via MQTT. It's an essential step for your automations to actually be executed.
Synchronization Principle
Scenarios exist in two distinct locations:
- Database (DB): Where you create and modify your scenarios via the web interface
- Logic Controller Equipment: Where scenarios are stored and executed in real-time
Synchronization uses the MQTT protocol to transfer scenarios between these two locations.
A scenario saved in the DB will NOT be executed until it has been synchronized with the equipment.
Accessing Synchronization
Prerequisites
Before you can synchronize, make sure that:
- ✅ The equipment is online (status "online")
- ✅ You have at least one created scenario in the DB
- ✅ You have the necessary permissions (Premium or Demo subscription)
Opening the Synchronization Modal
- Access your equipment's "Scenario" tab
- In the top right, click the "Synchronize with equipment" button
- The synchronization modal opens and automatically loads the scenario status
If the equipment is offline or you have no scenarios, the button will be disabled (grayed out).
Automatic Loading
When opening the modal, the system:
- 📡 Sends a LIST command via MQTT to the equipment
- ⏱️ Waits for the equipment response (8-second timeout)
- 🔍 Compares DB scenarios with equipment scenarios
- 📊 Displays results with possible actions
Synchronization uses the following MQTT topics:
{MAC}/SCENARIO/CMD- Sending commands{MAC}/SCENARIO/CMD/OUT- Receiving scenario list{MAC}/SCENARIO/ACK- Acknowledgments{MAC}/SCENARIO- Sending complete scenarios
Synchronization States
Each scenario in the modal displays a clear visual state:
✅ Synchronized
- Badge: Green "Synchronized" badge with ✓ icon
- Left border: Green
- Meaning: The scenario is identical in DB and equipment
- Condition:
lastSyncAtexists andupdatedAt≤lastSyncAtand active/inactive status matches - Available action: Delete from equipment
⚠️ To Update
- Badge: Orange "To update" badge with ⚠ icon
- Left border: Orange/Yellow
- Meaning: The scenario exists in both but was modified in the DB
- Condition:
- Either
lastSyncAtis null (never synchronized) - Or
updatedAt>lastSyncAt(modified since last sync) - Or the active/inactive status has changed
- Either
- Available actions:
- Update in equipment
- Delete from equipment
❌ Not Synchronized
- Badge: Gray "Not synchronized" badge with ✗ icon
- Left border: Gray
- Meaning: The scenario exists only in the DB, not in the equipment
- Condition: No corresponding scenario found in equipment
- Available action: Add to equipment
🚨 Orphan Scenario
- Badge: Red "Not referenced" badge with ? icon
- Left border: Red
- Background: Slightly transparent red
- Meaning: The scenario exists in the equipment but not in the DB
- Possible cause:
- Scenario deleted from DB but not yet from equipment
- DB reset
- Scenario created directly on equipment (rare case)
- Available action: Delete from equipment
"To sync" Badge in List
In the "Scenario" tab (list view), each scenario card displays an orange "To sync" badge if:
- The scenario has never been synchronized (
lastSyncAtis null) - The scenario was modified after the last synchronization (
updatedAt>lastSyncAt)
This badge allows you to quickly see which scenarios need synchronization without opening the modal.
Synchronization Actions
Add to Equipment
When to use: For a scenario that exists only in the DB
Process:
- Click on "Add to equipment"
- An info toast displays: "Adding scenario [name] in progress..."
- The scenario is converted to MQTT WAGO format
- Published on topic
{MAC}/SCENARIO - Wait 1.5 seconds for confirmation
- Update
lastSyncAtin the DB - Success toast: "Scenario [name] added to equipment"
After creating a new scenario, remember to add it to the equipment for it to be operational.
Update in Equipment
When to use: For a scenario that has been modified in the DB
Process:
- Click on "Update"
- An info toast displays: "Updating scenario [name] in progress..."
- The updated scenario is converted to MQTT WAGO format
- Published on topic
{MAC}/SCENARIO(overwrites the old one) - Wait 1.5 seconds
- Update
lastSyncAtin the DB - Success toast: "Scenario [name] updated in equipment"
If you enable or disable a scenario, this also triggers a "To update" state because the active/inactive status must be synchronized with the equipment.
Delete from Equipment
When to use:
- To remove a scenario from equipment while keeping it in the DB
- To clean up an orphan scenario
Process:
- Click on "Delete" or "Delete from equipment"
- An info toast displays: "Deleting scenario [id] in progress..."
- Send a DELETE command via topic
{MAC}/SCENARIO/CMD - Wait 1.5 seconds
- Update
lastSyncAttonullin the DB (for non-orphan scenarios) - Success toast: "Scenario [id] deleted from equipment"
Deleting from equipment does NOT delete the scenario from the DB. It remains accessible and editable, but no longer executes on the equipment until you add it again.
Refresh State
At the bottom of the modal, the "Refresh" button allows you to:
- Reload the current state of scenarios from the equipment
- Update the DB/Equipment comparison
- Detect new changes
When to use:
- After performing multiple synchronizations
- If multiple users manage the same equipment
- To verify that actions have been applied correctly
Displayed Information
For each scenario in the modal, you see:
Header
- Scenario name with icon
- Active/inactive badge (green/gray)
- Sync state badge (synchronized/to update/not synchronized)
Description (if present)
- Descriptive text of the scenario
Footer
- Last modification date (e.g., "2 hours ago")
- ID in equipment (e.g., "scenario_123") - only if present in equipment
- Action buttons according to state
Error Handling
Error: Timeout
Message: "Timeout: Equipment did not respond to LIST command..."
Cause: Equipment did not respond within 8 seconds
Solutions:
- Verify that equipment is online
- Check MQTT connection
- Ensure equipment firmware is up to date (scenarios feature supported)
- Click on "Retry"
Error: Invalid MQTT Response
Message: "Error processing MQTT response: [details]"
Cause: Equipment response is not in expected format
Solutions:
- Check firmware version
- Contact technical support
- Click on "Retry"
Error: Equipment Reports an Error
Message: "Equipment error: [equipment message]"
Cause: Equipment returned an ACK with "error" or "failure" status
Solutions:
- Check equipment logs
- Verify that scenario is compatible with equipment
- Try deleting then recreating the scenario
Complete Synchronization Workflow
Here's a typical synchronization workflow:
Scenario 1: New Scenario
- ✏️ Create a new scenario in the canvas
- 💾 Save the scenario (saved to DB)
- 🔍 The scenario appears in the list with "To sync" badge
- 🔄 Open the synchronization modal
- ➕ Click on "Add to equipment"
- ✅ The scenario is now active and synchronized
Scenario 2: Modifying an Existing Scenario
- ✏️ Edit an existing scenario in the canvas
- 🔧 Modify blocks, parameters, conditions
- 💾 Save modifications
- 🔍 The scenario now displays the "To sync" badge
- 🔄 Open the synchronization modal
- 🔁 Click on "Update"
- ✅ Modifications are applied to equipment
Scenario 3: Enable/Disable
- 🎚️ Toggle the active/inactive switch of a scenario
- 🔍 The "To sync" badge appears
- 🔄 Open the synchronization modal
- 🔁 Click on "Update" to synchronize the new status
- ✅ Equipment enables or disables the scenario
Scenario 4: Cleaning an Orphan Scenario
- 🔄 Open the synchronization modal
- 🔍 An orphan scenario (red) is detected
- 🗑️ Click on "Delete from equipment"
- ✅ The scenario is removed from equipment
- 🔄 Refresh to confirm deletion
Visual Indicators
Border Color Codes
- 🟢 Green: Synchronized scenario (everything up to date)
- 🟡 Yellow/Orange: Scenario to update (pending changes)
- ⚪ Gray: Not synchronized scenario (never sent to equipment)
- 🔴 Red: Orphan scenario (in equipment but not in DB)
Badge Icons
- ✓ (check-circle): Synchronized
- ⚠ (exclamation-circle): To update
- ✗ (x-circle): Not synchronized
- ? (question-circle): Orphan / Not referenced
Technical Information
MQTT Format
Scenarios are converted to WAGO format before sending via MQTT:
Scenario message structure:
{
"scenarioId": "scenario_123",
"active": true,
"blocks": [...],
"connections": [...],
"parameters": [...]
}
LIST command:
{
"command": "LIST"
}
DELETE command:
{
"command": "DELETE",
"scenarioId": "scenario_123",
"confirm": true
}
Change Detection
The system automatically detects that a scenario has changed if:
lastSyncAtisnull(never synchronized)updatedAt>lastSyncAt(modified since last sync) - comparison to the secondisActive(DB) ≠active(equipment) - status has changed
Best Practices
For effective synchronization:
✅ Synchronize after each important modification: Don't let changes accumulate ✅ Check "To sync" badges: Regularly check the scenario list ✅ Use "Refresh": Before and after a series of synchronizations ✅ Clean up orphans: Delete orphan scenarios to avoid confusion ✅ Check equipment status: Ensure it's "online" before synchronizing ✅ Wait for confirmation: Toasts indicate success or failure of each action ✅ Test after sync: Verify that the scenario executes correctly
Limitations and Constraints
Communication Delay
- Timeout: 8 seconds for LIST command
- Post-action delay: 1.5 second wait after each command
- These delays are necessary for MQTT communication and equipment processing
Firmware
- The feature requires up-to-date firmware on the equipment
- Older firmware may not support scenario commands
- Regularly check for available firmware updates
MQTT Connection
- Equipment must be connected to MQTT broker
- An unstable connection can cause synchronization failures
- In case of problems, check equipment network settings
Troubleshooting
"Synchronize" Button is Disabled
Check:
- Is the equipment online?
- Do you have at least one scenario created?
- Do you have necessary permissions (Premium/Demo)?
Modal Shows "Timeout"
Actions:
- Check equipment state (must be "online")
- Check MQTT connection in settings
- Restart equipment if necessary
- Update equipment firmware
Scenario Not Executing After Synchronization
Actions:
- Verify scenario is enabled (switch ON)
- Open modal and check state (must be "Synchronized")
- Check "Logs" tab to see executions
- Verify sensors used exist and work
- Test the scenario with "Test" button
Orphan Scenarios Appear
Possible causes:
- Deletion of a scenario from DB without deleting it from equipment
- DB reset
- Equipment migration
Solution:
- Delete orphans from equipment via "Delete from equipment" button
Conclusion
MQTT synchronization is the bridge between your web configuration and real-time execution on the equipment. By understanding the different states and following best practices, you'll maintain perfect consistency between your DB scenarios and those active in the field.
You know how to create, configure, and synchronize scenarios. Don't hesitate to experiment and create complex automations adapted to your needs!