Jump to content

Recommended Posts

Posted (edited)

Good day everyone,

 

I would like to send data of a 3em device to thingspeak by scripting. This is my actual script:


Timer.set(30000, true, function () {

  Shelly.call("EM.GetStatus", { id: 0 }, function (result) {
      let total_act_power = result.total_act_power;
      let a_act_power = result.a_act_power;
      let b_act_power = result.b_act_power;
      let c_act_power = result.c_act_power;
      let total_energy = result.total_apparent_power;
      
      Shelly.call(
        "HTTP.GET", {
        "url": "https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXX&field1=" + a_act_power+ "&field2=" + b_act_power+ "&field3=" + c_act_power+ "&field4=" + total_act_power + "&field5=" + total_energy,
        }  
      );
  });
});

 

it works well and the channel data at thingspeak is being updated every 30 seconds. But unfortunately only regarding the values measured for a_act_power, b_act_power and c_act_power. As scripted I would like also the total energy measured in kWh. There are no values coming for total_apparent_power. I also tried total_energy, but ist does not seem to be a valid variable with value. 
 

does anyone know the problem here? Thank you. 

Edited by Henning
Posted

I've added 3 lines to the beginning of the script. It should work now.

Please see the link below. [EM vs EMData/EM1Data]

https://shelly-api-docs.shelly.cloud/gen2/Devices/Gen2/ShellyPro3EM

 

Timer.set(30000, true, function () {
   ///////////////////////////////////////////////////////////////////////////////////////////////////
  let total_energy;
  Shelly.call("EMData.GetStatus", { id: 0 }, function (result) {
      total_energy = result.total_act;
 });
 ///////////////////////////////////////////////////////////////////////////////////////////////////
  Shelly.call("EM.GetStatus", { id: 0 }, function (result) {
      let total_act_power = result.total_act_power;
      let a_act_power = result.a_act_power;
      let b_act_power = result.b_act_power;
      let c_act_power = result.c_act_power;
      
      Shelly.call(
        "HTTP.GET", {
        "url": "https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXX&field1=" + a_act_power+ "&field2=" + b_act_power+ "&field3=" + c_act_power+ "&field4=" + total_act_power + "&field5=" + total_energy,
        }  
      );
  });
});

 

Join the conversation

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

Guest
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...