EXAMPLE → Shelly Plug S
This guide explains how to integrate a Shelly Plug S device with the ADA P1 Meter system.
The integration allows the Shelly Plug S to send measurement data over the local network to the ADA P1 Server, which then processes and forwards the data to the okosvillanyora.hu system.
Requirements
- ADA P1 Meter firmware version 1.2.77 or later
- Shelly Plug S device
- Access to the local network where both devices are connected
How It Works
-
The Shelly Plug S collects measurement data, including:
- Voltage
- Current
- Power
- Total Energy Consumption
-
At regular intervals (e.g., every 60 seconds), the Shelly Plug S sends an HTTP POST request to the ADA P1 Server's
/write
endpoint. -
The ADA P1 Server incorporates the received data into its JSON structure under the
plugins
key. -
The okosvillanyora.hu dashboard recognizes the plugin data and displays it in graphical format.
JSON Data Format
The Shelly Plug S sends data in the following JSON format:
{
"device": "plugins",
"values": [
{ "index": 0, "name": "Shelly01_total", "value": 1234.56, "unit": "Wh" },
{ "index": 1, "name": "Shelly01_voltage", "value": 230.1, "unit": "V" },
{ "index": 2, "name": "Shelly01_current", "value": 0.41, "unit": "A" },
{ "index": 3, "name": "Shelly01_power", "value": 94.4, "unit": "W" }
]
}
⚠️ Important: The "device": "plugins"
declaration is required to ensure proper processing in ADA P1 Server.
Shelly Plug S Script Snippet
Below is a working script for the Shelly Plug S (with correct JSON format):
Timer.set(60000, true, function () {
Shelly.call("Switch.GetStatus", { id: 0 }, function (res) {
if (res && res.apower !== undefined) {
let jsonData = {
device: "plugins", // Required key!
values: [
{ index: 0, name: "Shelly01_total", value: res.aenergy.total, unit: "Wh" },
{ index: 1, name: "Shelly01_voltage", value: res.voltage, unit: "V" },
{ index: 2, name: "Shelly01_current", value: res.current, unit: "A" },
{ index: 3, name: "Shelly01_power", value: res.apower, unit: "W" }
]
};
let payload = JSON.stringify(jsonData);
print("📤 Sending: " + payload);
Shelly.call("HTTP.POST", {
url: "http://okosvillanyora.local:8989/write",
headers: { "Content-Type": "application/json" },
body: payload
}, function (response, error_code, error_msg) {
if (error_code === 0) {
print("✅ Response: " + JSON.stringify(response));
} else {
print("❌ Error sending data: " + error_msg);
}
});
} else {
print("❌ Failed to retrieve Switch status.");
print(JSON.stringify(res));
}
});
});
This script sends the Shelly Plug S's measurement data to the ADA P1 Server every 10 seconds.
The ADA P1 Server processes and publishes this data in its /json
output, and also forwards it via MQTT to Home Assistant and the okosvillanyora.hu cloud.
Recommended Data Transmission Frequency
The ADA P1 Server runs on an ESP32 microcontroller, which performs multiple tasks simultaneously.
To ensure stable operation:
- Send data no more frequently than once every 10–60 seconds.
- Keep the number of values per request minimal (ideally ≤ 5).
- Use a unique prefix in the
name
field per Shelly device (e.g.,Shelly01
,Shelly02
).
Visualization
Data sent in this format will appear in the okosvillanyora.hu dashboard under the plugin_
prefix and in CSV exports as:
plugin_Shelly01_total
plugin_Shelly01_voltage
plugin_Shelly01_current
plugin_Shelly01_power
To use multiple Shelly devices, ensure each uses unique name
prefixes in the values
array.
For more information, see the original article (in Hungarian):
https://greenhess.com/shelly-plug-s-integracio-az-ada-p1-meter-rel