SENSORS · air-quality

Air Quality Sensor

AQI, CO₂, and particulate readings.

3 capabilitiesREST + secure WebSocketProduction schema
OVERVIEW

Built from capabilities, not assumptions.

Air Quality Sensor is a canonical HomeAutoPro sensors template. The same production capability schema drives validation, controls, reported state, telemetry, scenes and automations. Undeclared keys are rejected.

WRITABLE CAPABILITIES

Controls

This telemetry-first template has no writable controls.
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.

Air Qualityaqi

number. Read-only device feedback.

CO₂co2

number · ppm. Read-only device feedback.

PM2.5pm25

number · µg/m³. Read-only device feedback.

TIME-SERIES VALUES

Telemetry

Air Qualityaqi

Validated number, 0–500. Publish in a telemetry message.

CO₂co2

Validated number in ppm, 0–10000. Publish in a telemetry message.

PM2.5pm25

Validated number in µg/m³, 0–1000. Publish in a telemetry message.

CAPABILITY-AWARE WORKFLOWS

Automations

Triggers

State/telemetry changes for aqi, co2, pm25, plus online and offline events.

Actions

This read-only template cannot be an action target.

ACTUAL PRODUCTION PROTOCOL

Payloads and acknowledgement

Dashboard/APIHomeAutoProDeviceApplied-state ACK

Authenticate

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

Telemetry

{
  "telemetry": {
    "aqi": 250.0,
    "co2": 5000.0,
    "pm25": 500.0
  },
  "type": "telemetry"
}
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: (no writable keys)
// 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.