CONTROLLERS · multi-relay

Multi-channel Relay

A reusable relay bank for custom builds.

4 capabilitiesREST + secure WebSocketProduction schema
OVERVIEW

Built from capabilities, not assumptions.

Multi-channel Relay is a canonical HomeAutoPro controllers template. The same production capability schema drives validation, controls, reported state, telemetry, scenes and automations. Undeclared keys are rejected.

WRITABLE CAPABILITIES

Controls

ControlTypeRange / valuesDescription
Channel 1channel_1booleanON / OFFWritable through validated owner commands and automations.
Channel 2channel_2booleanON / OFFWritable through validated owner commands and automations.
Channel 3channel_3booleanON / OFFWritable through validated owner commands and automations.
Channel 4channel_4booleanON / OFFWritable through validated owner commands and automations.
DEVICE → HOMEAUTOPRO

Feedback / state

Every connected device also reports online state and last-seen time. Applied values remain distinct from requested values until the device acknowledges them.

Channel 1channel_1

boolean. Report the value actually applied after each command.

Channel 2channel_2

boolean. Report the value actually applied after each command.

Channel 3channel_3

boolean. Report the value actually applied after each command.

Channel 4channel_4

boolean. Report the value actually applied after each command.

TIME-SERIES VALUES

Telemetry

This template declares no telemetry-only values. Report readable applied values as state.

CAPABILITY-AWARE WORKFLOWS

Automations

Triggers

State/telemetry changes for channel_1, channel_2, channel_3, channel_4, plus online and offline events.

Actions

Validated commands for channel_1, channel_2, channel_3, channel_4. Applied state is reported as ACK.

ACTUAL PRODUCTION PROTOCOL

Payloads and acknowledgement

Dashboard/APIHomeAutoProDeviceApplied-state ACK

Authenticate

{"type":"auth","device_secret":"YOUR_DEVICE_SECRET"}

Command

{
  "event": "command",
  "state": {
    "channel_1": true,
    "channel_2": true,
    "channel_3": true,
    "channel_4": true
  }
}

State ACK

{
  "state": {
    "channel_1": true,
    "channel_2": true,
    "channel_3": true,
    "channel_4": true
  },
  "type": "state"
}
CAPABILITY-GENERATED EXAMPLES

Sample code

Choose one platform. All examples use the production protocol and placeholders; no stored secret is retrieved.

C++ · ESP8266
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <WebSocketsClient.h>

const char* DEVICE_CODE = "YOUR_DEVICE_ID";
const char* DEVICE_SECRET = "YOUR_DEVICE_SECRET";
WebSocketsClient socket;

// Handle only: channel_1, channel_2, channel_3, channel_4
// Connect: socket.beginSSL("api.homeautopro.in", 443, path);
// First message: {"type":"auth","device_secret":DEVICE_SECRET}
// After a command, publish {"type":"state","state":applied}.
SAFE DIAGNOSTICS

Troubleshooting

401 authentication

Use the current Device Secret locally. Rotate it in Device Details if it was lost.

422 validation

Compare every key, type and range with the capability schema above.

No command ACK

Publish the value actually applied after handling event=command.