For the complete documentation index, see llms.txt. This page is also available as Markdown.

Shelly 3EM Pro

Onboard via Shelly Web UI

  1. Open the device in the Shelly Web UI.

  2. Go to Scripts.

  3. Click Add script.

  4. Paste the onboarding script.

  5. Set INGEST_INTERVAL_MS and API_KEY.

  6. Save the script.

  7. Start the script.

  8. Check the logs for a successful request.


let INGEST_URL = "https://api.irs.systems/functions/v1/iot-ingest-telemetry";
let API_KEY = "dk_3230af..";
let INGEST_INTERVAL_MS = 600000;  // 10 minutes

Timer.set(INGEST_INTERVAL_MS, true, function () {
    Shelly.call("EM.GetStatus", { id: 0 }, function (emResult, emError) {
        if (emError) {
            print("Error reading EM:", emError);
            return;
        }

        Shelly.call("EMData.GetStatus", { id: 0 }, function (edResult, edError) {
            if (edError) {
                print("Error reading EMData:", edError);
                return;
            }

            let payload = {
                timestamp: new Date().toISOString(),
                total_power: emResult.total_act_power,
                total_energy: edResult.total_act,
                device_mac: Shelly.getDeviceInfo().mac,
            };

            Shelly.call(
                "HTTP.Request",
                {
                    method: "POST",
                    url: INGEST_URL,
                    headers: {
                        "Content-Type": "application/json",
                        "x-api-key": API_KEY,
                    },
                    body: JSON.stringify(payload),
                },
                function (res, err) {
                    if (err) {
                        print("HTTP Error:", err);
                    } else {
                        print("Sent to Supabase:", res.code);
                    }
                }
            );
        });
    });
});

Last updated

Was this helpful?