Jump to content
New translation feature for the Shelly Forum ×

Multiple Pro3EM data collection and action

Recommended Posts

Example how to read data from  3 Pro EM meters measuring the consumption on the 3 different zones and script which is run on Pro3EM with ADD-ON to EV Charger which  disconnects (EV charging) for 30 min if the total power (represented by the consuming value on the right of the picture) is above a certain value.
A JScript which can do that: 
// Configuration

var deviceIPs = ['', '', '']; // Add your device IPs here
const switchOff = 2000 ; // Total power in W above this device will switch off output

// Function to read data from a single Shelly Pro3EM
function readEMData(ip, callback) {
    { url: "http://" + ip + "/rpc/EM.GetStatus?id=0" },
    function (response, error_code, error_message) {
      if (response && response.message && response.code === 200) {
        var data = JSON.parse(response.body);
        var total_power = Math.round(data.total_aprt_power);
        callback(null, total_power); // Pass the total power to the callback
      } else {
        callback("Error: " + response.message, null);

// Function to calculate the total power from multiple devices
function calculateTotalPower(ips) {
  var totalPower = 0;
  var count = 0;

  ips.forEach(function(ip) {
    readEMData(ip, function(err, power) {
      if (err) {
        print(err); // Handle the error, for example by logging it
      } else {
        totalPower += power;
      // Check if all requests are processed
      if (count === ips.length) {
        print("Total power: " + totalPower + " W");
        if (totalPower > switchOff) {        
          Shelly.call("Switch.set", {'id': 100, 'on': false});
        print("Switch OFF!");  

// Execution: 
Timer.set(5000 /* ms */, true /* repeating */, function () {


Then you need to set Auto-ON in the Add-on relay: 

As a last step do not forget to set a script to start when device boot. 


With firmware 1.4, All pro devices will support virtual components. This will allow to monitor total consumption from the Shelly App and control the max power.  I will update this script when this new feature are available. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...