RelayX Documentation

website·Indexed 30 days ago

https://docs.relay-x.io

A platform for device connectivity and monitoring featuring an App SDK for telemetry streaming, alerts, and command delivery, a Device SDK for publishing sensor readings and managing configuration, and a UI Kit with components like needle gauges and presence indicators.

Tokens
32.2K
Snippets
168
Records
224
Agent score
48%

What's inside RelayX

  1. Overview of the RelayX Platform Ecosystem

    RelayX is a platform for building real-time IoT applications. It consists of three primary components that facilitate the flow of data from hardware to the end-user interface:

    1. Device SDK: Runs on the physical device. It handles publishing telemetry, responding to RPC calls, listening for commands, managing configuration, and emitting events. Available in JavaScript, Python, and C++.
    2. App SDK: Runs on the backend or web application. It is used to manage devices, stream telemetry, send commands, configure alerts, and organize device groups. Available in JavaScript and Python.
    3. UI Kit: A browser-based library of pre-built React components (gauges, charts, stat cards, and presence indicators) that connect to live device data via hooks.

    Core Features:

    • Real-Time Telemetry: Millisecond-latency data streaming from devices to backend/UI.
    • Command & Control: Server-to-device RPC calls and commands.
    • Live Dashboards: Real-time visualization via React components.
    • Threshold Alerts: Notifications triggered when metrics cross defined boundaries.
    • Fleet Management: Bulk operations and grouping of devices.
    • Offline Resilience: Automatic message buffering during disconnects with flushing upon reconnection.
  2. Overview of RelayX Group Types

    RelayX provides two models for organizing devices into groups to facilitate batch operations and aggregated telemetry streaming:

    1. Logical Groups (app.logicalGroup): Tag-based grouping. A single device can belong to multiple logical groups.
    2. Hierarchy Groups (app.heirarchyGroup): Path-based grouping using a tree structure (e.g., zone-1.building-a.floor-1), ideal for physical layouts.
  3. Overview of RelayX Notification Channel Types

    RelayX supports two primary delivery channels for alerts:

    • Webhook: Sends an HTTP POST request with the alert payload to a specified endpoint. Ideal for integrations with Slack, PagerDuty, or custom dashboards.
    • Email: Sends emails to one or more recipients. Supports template variables such as {{rule.name}} and {{device_id}} in the subject and body. Note that email limits depend on your specific plan.
  4. Overview of RelayX Server-Side Alert Types

    RelayX provides server-side alerts that evaluate continuously on the platform, meaning they function even when your application is not running. They are accessed via the app.alert object.

    There are two primary alert types:

    • Threshold: Triggers when a metric stays above or below a specific value for a sustained period (e.g., temperature > 80).
    • Rate-change: Triggers when a metric changes too quickly over a defined time window (e.g., a pressure drop of 10 units in 1 minute).
  5. Handle RPC calls using the Device SDK

    RPC (Remote Procedure Call) in the Device SDK follows a request/reply pattern where the calling app waits for a response from the device. To handle an RPC call, you must register a listener with a unique name. Every RPC handler must call either request.respond(data) for success or request.error(data) for failure to avoid leaving the caller waiting.
  6. Build a current-monitoring system with RelayX

    This project implements a real-time current-monitoring system where an ESP32 reads current, voltage, and power from an INA219 sensor and publishes the data to a React dashboard. The system allows for live telemetry visualization (gauges and time-series charts) and remote control of a physical relay via the internet with sub-second latency.
  7. Install RelayX SDKs and UI Kit

    Depending on your role in the IoT architecture (device-side, backend/app-side, or frontend), install the corresponding RelayX package using npm.
    # For device-side logic (JS version)
    npm install @relay-x/device-sdk
    
    # For backend or web app management (JS version)
    npm install @relay-x/app-sdk
    
    # For React-based dashboards
    npm install @relay-x/ui
  8. StateTimeline Component Overview

    The StateTimeline component is a canvas-based horizontal bar chart that visualizes state transitions over time. Each row represents a device, and the bars are colored based on the device's state at a given time.
  9. Synchronize device time using the Time module

    The SDK maintains a clock offset by syncing with an NTP server (time.google.com) upon initialization. This offset is applied to all telemetry, event payloads, and calls to now(). The offset is automatically refreshed every 3 hours while connected; if a sync fails, the SDK continues using the last cached offset to ensure now() remains functional.
  10. StatCard component overview and props

    The StatCard is a responsive component that displays a single value. It supports zone-aware coloring (where the value text color changes based on defined alert zones), custom formatting for values and timestamps, and loading states via skeleton shimmers.
    // Basic usage
    <StatCard 
      data={{ value: 25.5, timestamp: Date.now() }} 
      label="Temperature" 
    />
  11. Use StatCardWithGraph to display metrics with trend lines

    The StatCardWithGraph component extends the standard StatCard by adding an inline sparkline chart at the bottom 60% of the card. It is used to visualize the recent trend of a specific metric alongside its current value.
  12. Publish sensor readings using the telemetry module

    The telemetry module allows devices to publish sensor readings to RelayX. Telemetry is 'fire-and-forget', meaning readings are delivered to the app and stored for historical queries. The SDK automatically attaches NTP-synchronized timestamps to every reading. If the device is offline, readings are buffered in memory and flushed in order upon reconnection.