OlivierD Posted August 15 Share Posted August 15 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. Quote Link to comment Share on other sites More sharing options...
Members mschaeffler Posted August 15 Members Share Posted August 15 Why not: if ( event.delta.apower !== undefined ) { Quote Link to comment Share on other sites More sharing options...
tvbshelly Posted August 15 Share Posted August 15 (edited) 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 Edited August 15 by tvbshelly Quote Link to comment Share on other sites More sharing options...
tvbshelly Posted August 15 Share Posted August 15 (edited) 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 August 15 by tvbshelly Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.