Energy Meter
Electrical measurements without fabricated values.
Built from capabilities, not assumptions.
Energy Meter is a canonical HomeAutoPro energy template. The same production capability schema drives validation, controls, reported state, telemetry, scenes and automations. Undeclared keys are rejected.
Controls
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.
voltagenumber · V. Read-only device feedback.
currentnumber · A. Read-only device feedback.
power_wnumber · W. Read-only device feedback.
energy_kwhnumber · kWh. Read-only device feedback.
frequencynumber · Hz. Read-only device feedback.
power_factornumber. Read-only device feedback.
Telemetry
voltageValidated number in V, 0–300. Publish in a telemetry message.
currentValidated number in A, 0–100. Publish in a telemetry message.
power_wValidated number in W, 0–10000. Publish in a telemetry message.
energy_kwhValidated number in kWh, 0–100000. Publish in a telemetry message.
frequencyValidated number in Hz, 0–100. Publish in a telemetry message.
power_factorValidated number, 0–1. Publish in a telemetry message.
Automations
State/telemetry changes for voltage, current, power_w, energy_kwh, frequency, power_factor, plus online and offline events.
This read-only template cannot be an action target.
Payloads and acknowledgement
Authenticate
{"type":"auth","device_secret":"YOUR_DEVICE_SECRET"}Telemetry
{
"telemetry": {
"current": 50.0,
"energy_kwh": 50000.0,
"frequency": 50.0,
"power_factor": 0.5,
"power_w": 5000.0,
"voltage": 150.0
},
"type": "telemetry"
}Sample code
Choose one platform. All examples use the production protocol and placeholders; no stored secret is retrieved.
#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}.#include <WiFi.h>
#include <ArduinoJson.h>
#include <WebSocketsClient.h>
const char* DEVICE_CODE = "YOUR_DEVICE_ID";
const char* DEVICE_SECRET = "YOUR_DEVICE_SECRET";
// Use TLS port 443 and the same authenticated command/state ACK lifecycle.
// Generate handlers only for: (no writable keys)import requests
url = "https://homeautopro.in/api/device-ingest/DEVICE_CODE/telemetry"
headers = {"X-Device-Secret": "YOUR_DEVICE_SECRET"}
payload = {"telemetry": {"current": 50.0, "energy_kwh": 50000.0, "frequency": 50.0, "power_factor": 0.5, "power_w": 5000.0, "voltage": 150.0}}
response = requests.post(url, headers=headers, json=payload, timeout=10)
response.raise_for_status()const response = await fetch(
"https://homeautopro.in/api/device-ingest/DEVICE_CODE/telemetry",
{ method: "POST", headers: { "X-Device-Secret": "YOUR_DEVICE_SECRET", "Content-Type": "application/json" },
body: JSON.stringify({"telemetry": {"current": 50.0, "energy_kwh": 50000.0, "frequency": 50.0, "power_factor": 0.5, "power_w": 5000.0, "voltage": 150.0}}) }
);
if (!response.ok) throw new Error(`HomeAutoPro ${response.status}`);curl --fail-with-body -X POST \
-H "X-Device-Secret: YOUR_DEVICE_SECRET" \
-H "Content-Type: application/json" \
-d '{"telemetry": {"current": 50.0, "energy_kwh": 50000.0, "frequency": 50.0, "power_factor": 0.5, "power_w": 5000.0, "voltage": 150.0}}' \
https://homeautopro.in/api/device-ingest/DEVICE_CODE/telemetryTroubleshooting
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.