Jump to content
🌟 NOTIFICATION/Benachrichtigung: Welcome to our New Store! - shelly.com 🌟 ×

(typeof event.delta.apower !== "undefined" ERROR


Recommended Posts

Hi, 

 

I have a crash error with this very simple program:

 

function production (event, user_data) {
  print(JSON.stringify(event)); 
  if (typeof event.delta.apower !== "undefined") {
    print("coucou");
  }
}

Shelly.addStatusHandler(production, null);

 

 

{"component":"switch:0","name":"switch","id":0,"delta":{"id":0,"apower":0,"current":0,"output":false,"pf":0,"source":"WS_in"}}
coucou
Uncaught SyntaxError: Got class expected EOF
at class||class||}
^
in function called from system

 

 

I dont understand the problem.

Link to comment
Share on other sites

I have tried the original version of the Scrip on a Pro 3EM - it just works, i.e. at least there is no error message like yours.

Which Shelly device are you experiencing the error with? Is the firmware up to date, i.e. 1.4.0? @OlivierD

image.thumb.png.7f96fd13779c9993a95f72aeacc4a7f9.png

Edited by tvbshelly
Link to comment
Share on other sites

I have adapted the script to the properties of my Pro 3EM:

function production (event, user_data) {
  print(JSON.stringify(event));
  print("value : " + event.delta.total_aprt_power);
  if (typeof event.delta.total_aprt_power !== "undefined") {
    print("coucou");
  }
}

Shelly.addStatusHandler(production, null);

Result:

{"component":"script:1","name":"script","id":1,"delta":{"id":1,"running":true}}
value : undefined
{"component":"em:0","name":"em","id":0,"delta":{"id":0,"a_act_power":-3411.3,"a_aprt_power":3418.4,"a_current":14.102,"a_freq":50,"a_pf":1,"a_voltage":242,"b_act_power":-3240.8,"b_aprt_power":3244.6,"b_current":13.587,"b_freq":50,"b_pf":1,"b_voltage":238.4,"c_act_power":-3152.6,"c_aprt_power":3163.9,"c_current":13.171,"c_freq":50,"c_pf":1,"c_voltage":240,"n_current":null,"total_act_power":-9804.665,"total_aprt_power":9826.854,"total_current":40.86}}
value : 9826.854
coucou

 

if ( event.delta.total_aprt_power !== undefined ) {

@mschaeffler suggestion also works.

 

Edited by tvbshelly
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.

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.

×
×
  • Erstelle neue...