Skip to content

API Reference ​

This page documents the HTTP endpoints exposed by v2c-any when running in REST mode.

Endpoints ​

GET /health ​

Health check endpoint.

Response:

json
{
  "ok": true
}

Status codes:

CodeDescription
200Healthy

GET /rpc/EM1.GetStatus ​

Get energy meter status. Compatible with the Shelly Pro EM API format.

Query Parameters:

ParameterTypeRequiredDescription
idnumberYesMeter ID (0 = grid, 1 = solar)

Success Response (200):

json
{
  "id": 0,
  "voltage": 230.5,
  "current": 12.3,
  "act_power": 2834,
  "aprt_power": 2875,
  "pf": 0.986,
  "freq": 50.0,
  "calibration": "factory"
}

Response Fields:

FieldTypeDescription
idnumberEM1 component instance ID
voltagenumberVoltage measurement (V)
currentnumberCurrent measurement (A)
act_powernumberActive power measurement (W)
aprt_powernumberApparent power measurement (VA)
pfnumberPower factor
freqnumberNetwork frequency (Hz)
calibrationstringCalibration status (e.g., "factory")
errorsstring[]Error conditions (present only if not empty)
flagsstring[]Condition flags (present only if not empty)

Error Response:

json
{
  "code": -1,
  "message": "Error description"
}

POST /expectaction ​

Update mock meter values at runtime. Only works with feeds configured as type: mock.

Request Body:

json
{
  "id": 0,
  "act_power": 3000,
  "voltage": 230.0,
  "calibration": "factory"
}

The body follows the same schema as the EM1Status object. At minimum, id and calibration are required.

Status Codes:

CodeDescription
200Value updated successfully
400Unknown meter ID or meter not in mock mode
500Internal error

MQTT Topics ​

When running in MQTT mode, v2c-any publishes to these topics:

TopicDirectionFormatDescription
trydan_v2c_grid_powerPublishPlain number (watts)Grid power
trydan_v2c_sun_powerPublishPlain number (watts)Solar power

Example:

text
trydan_v2c_grid_power: 3450
trydan_v2c_sun_power: 2100

CLI ​

v2c-any is invoked via the v2ca binary. It accepts no command-line arguments - all configuration is loaded from configuration files (see Configuration).

bash
# Run with auto-detected configuration
v2ca

# Run via npx
npx v2c-any

# Run in development mode
npm run dev

The application logs to stdout using pino with pino-pretty formatting.

Released under the MIT License.