Skip to main content

Equipment Monitoring System

The Equipment Monitoring System provides real-time temperature and humidity monitoring for your refrigeration equipment, integrated with Swift Sensors hardware.

Real-time Monitoring

Monitor temperature and humidity across all your fridges and freezers

Smart Alerts

Receive notifications via email, SMS, or in-app when thresholds are exceeded

Historical Reports

Generate reports for compliance and analysis

Multi-channel Notifications

Configure who receives which alerts through which channels

Architecture Overview

Swift Sensors API → API Client → Supabase (historical storage) → Admin Dashboard

                                   Background Sync Jobs
The system consists of five backend modules that work together:
  1. Swift Sensors API Client - Handles authentication and data fetching from Swift Sensors
  2. Equipment Module - Manages equipment units and threshold configuration
  3. Temperature Data Module - Stores and queries time-series data
  4. Alert System - Detects threshold violations and tracks alert status
  5. Notification System - Routes alerts to assigned users

Setup

1

Configure environment variables

Add your Swift Sensors credentials to your .env file:
.env
SWIFT_SENSORS_API_KEY=your_api_key
SWIFT_SENSORS_EMAIL=your_email
SWIFT_SENSORS_PASSWORD=your_password
SWIFT_SENSORS_ACCOUNT_ID=your_account_id
Never commit API credentials to version control. Use environment variables or a secrets manager.
2

Register the modules

Add the equipment modules to your medusa-config.js:
medusa-config.js
module.exports = {
  modules: [
    { resolve: "@switchyard/equipment" },
    { resolve: "@switchyard/temperature-data" },
    { resolve: "@switchyard/equipment-alerts" },
    { resolve: "@switchyard/equipment-notifications" },
  ],
}
3

Run database migrations

Create the required database tables:
Terminal
npx medusa migrations run
Verify the migration created these tables: equipment, equipment_thresholds, temperature_readings, equipment_alerts, alert_notification_assignments
4

Access the dashboard

Navigate to Equipment → Refrigeration in the admin dashboard to begin monitoring.

Database Schema

Equipment Table

The equipment table stores your refrigeration units:
id
string
required
Primary key for the equipment record
name
string
required
Human-readable name (e.g., “Walk-in Fridge 1”)
type
string
required
Equipment type: refrigerator, freezer, handheld, or robot
inventory_group_id
string
Link to associated inventory group for location tracking
swift_sensor_id_temperature
integer
Swift Sensors temperature sensor ID
swift_sensor_id_humidity
integer
Swift Sensors humidity sensor ID (optional)
is_active
boolean
Whether the equipment is currently monitored

Equipment Thresholds Table

Configure custom alert thresholds for each equipment unit:
equipment_id
string
required
Foreign key to the equipment record
measurement_type
string
required
Either temperature or humidity
low_critical
number
Value below which a critical alert is triggered
low_warning
number
Value below which a warning alert is triggered
high_warning
number
Value above which a warning alert is triggered
high_critical
number
Value above which a critical alert is triggered

Alert Types

The system monitors for these alert conditions:
Alert TypeDescriptionDefault Severity
temperature_highTemperature exceeds high thresholdBased on threshold
temperature_lowTemperature below low thresholdBased on threshold
humidity_highHumidity exceeds thresholdBased on threshold
humidity_lowHumidity below thresholdBased on threshold
connectivity_lossNo readings received for 15+ minutesCritical
battery_lowSensor battery needs replacementWarning
sensor_offlineSensor not respondingCritical
Configure thresholds per equipment unit to account for different requirements. Freezers typically need different thresholds than refrigerators.

API Endpoints

Equipment Management

curl -X POST 'https://switchyard.run/admin/equipment' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{
    "name": "Walk-in Fridge 1",
    "type": "refrigerator",
    "inventory_group_id": "inv_group_123"
  }'

Alert Management

curl -X GET 'https://switchyard.run/admin/equipment/alerts?status=active' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Time Series Data

Retrieve historical readings for analysis and reporting:
Get Time Series
curl -X GET 'https://switchyard.run/admin/equipment/equip_123/time-series?startTime=1704067200000&endTime=1704153600000&measurementType=both' \
  -H 'Authorization: Bearer YOUR_TOKEN'
startTime
integer
required
Start timestamp in milliseconds
endTime
integer
required
End timestamp in milliseconds
measurementType
string
default:"both"
Filter by temperature, humidity, or both

Reports

Generate historical reports for compliance and analysis:
Generate CSV Report
curl -X GET 'https://switchyard.run/admin/equipment/reports?equipmentId=equip_123&startTime=1704067200000&endTime=1704153600000&format=csv' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -o report.csv

Dashboard Features

Equipment Monitoring Tab

The monitoring tab provides:
  • Active Alerts Section - View and manage current alerts with one-click resolve/acknowledge
  • Equipment Grid - Cards showing current temperature, humidity, and status for each unit
  • Status Indicators - Color-coded badges (green/orange/red) for normal/warning/critical states

Equipment Detail Modal

Click any equipment card to open the detail view:
  • Historical Charts - Temperature and humidity over time with selectable ranges (1h, 6h, 24h, 7d, 30d)
  • Active Alerts - Alerts specific to this equipment
  • Configuration - Sensor IDs and threshold settings

Notifications Management Tab

Configure which users receive which alerts:
  1. Select an alert type
  2. Choose users to assign
  3. Select notification channels (email, SMS, in-app)
  4. Optionally limit to specific equipment
Users only receive notifications for alert types they are explicitly assigned to. Unassigned users will not receive any equipment alerts.

Historical Reporting Tab

Generate reports for compliance and analysis:
  1. Select equipment from the dropdown
  2. Choose date range
  3. Select format (CSV for raw data, JSON for summary)
  4. Click Generate Report

Troubleshooting

  1. Verify credentials - Check that your Swift Sensors credentials are correct in .env
  2. Check sensor pairing - Ensure equipment records have swift_sensor_id_temperature set
  3. Review sync logs - Check the background sync job logs for errors
  4. Test API connection - Try fetching data directly from Swift Sensors API
  1. Check thresholds - Verify thresholds are configured for the equipment
  2. Verify readings - Ensure sensor data is being recorded in temperature_readings
  3. Review alert detection - Check that the alert detection service is running
  1. Check assignments - Verify notification assignments exist for the alert type
  2. Verify user data - Ensure assigned users have valid email/phone
  3. Review notification logs - Check the notification service logs

Next Steps: When Sensors Arrive

1

Install sensors

Follow Swift Sensors installation documentation to mount sensors in your refrigeration units.
2

Note sensor IDs

Log into the Swift Sensors dashboard and note the sensor IDs for each device.
3

Pair sensors to equipment

Update each equipment record with the corresponding sensor IDs via the API.
4

Configure thresholds

Set appropriate temperature and humidity thresholds for each unit type.
5

Set up notifications

Assign users to receive alerts through their preferred channels.
6

Begin monitoring

The dashboard will start showing real-time data once sensors are paired.