urmel Posted May 4 Share Posted May 4 Hello. I have an 3em gen2. I will send the actual values to an mqtt server. How can i do that. I need current,power for all 3 phases seperate Quote Link to comment Share on other sites More sharing options...
Moderators terae Posted May 5 Moderators Share Posted May 5 Turn MQTT on and RPC event messages ("RPC status notifications over MQTT:")on from it. It will send info to MQTT broker, including all that and more. {"src":"shellypro3em-##########","dst":"#########/events","method":"NotifyStatus","params":{"ts":1714929935.58,"em:0":{"id":0,"a_act_power":216.2,"a_aprt_power":297.5,"a_current":1.268,"a_freq":50.0,"a_pf":0.72,"a_voltage":234.9,"b_act_power":-20.5,"b_aprt_power":65.3,"b_current":0.276,"b_freq":50.0,"b_pf":0.31,"b_voltage":236.8,"c_act_power":46.7,"c_aprt_power":185.8,"c_current":0.786,"c_freq":50.0,"c_pf":0.27,"c_voltage":236.7,"n_current":null,"total_act_power":242.430,"total_aprt_power":548.652,"total_current":2.330}}} There you find all the values like a_current b_current and c_current Quote Link to comment Share on other sites More sharing options...
urmel Posted May 6 Author Share Posted May 6 OK. I know. However, I want the EM3 the power and the current of the three phase (i.e. individual 6 values) to another MQTTServer on 6 different topics. Actions? Scripts? Any example available? Quote Link to comment Share on other sites More sharing options...
Members thgoebel Posted May 6 Members Share Posted May 6 Did you check the knowledge base yet? https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Mqtt Quote Link to comment Share on other sites More sharing options...
urmel Posted May 6 Author Share Posted May 6 These usage is Client -> subscribs-from -> EM3P i search for EM3P -> publish -> MyMqttServer automaticly if values changes. Any Script will be runing on EM3 background or any Acrtion muss "publish" to My MQTT Server. I seach for an example Action/Script that "publish" to an MQTT Server. Quote Link to comment Share on other sites More sharing options...
Hummelchen Posted May 13 Share Posted May 13 @urmel Here an Example which 6 values subcript to the MQTT // set this to >0 then log is activ let log = 0; // set this to false to stop publishing on MQTT let MQTTpublish = true; //published variables let lastPublishedMQTT_A_Act_Power = ""; let lastPublishedMQTT_B_Act_Power = ""; let lastPublishedMQTT_C_Act_Power = ""; let lastPublishedMQTT_A_Voltage = ""; let lastPublishedMQTT_B_Voltage = ""; let lastPublishedMQTT_C_Voltage = ""; // query the MQTT prefix on startup let SHELLY_ID = undefined; /// Shelly.call("Mqtt.GetConfig", "", function(res, err_code, err_msg, ud) { SHELLY_ID = res["topic_prefix"]; }); /// function timerHandler(user_data) { let em = Shelly.getComponentStatus("em", 0); if (typeof em.total_act_power !== 'undefined') { // a act power let value = em.a_act_power.toFixed(1); if (value !== lastPublishedMQTT_A_Act_Power) { MQTT.publish( SHELLY_ID + "/MyMQTTValues/A_Act_Power", value, 0, false ); lastPublishedMQTT_A_Act_Power = value; if (log > 0) print("A_Act_Power: " + value); } // b act power let value = em.b_act_power.toFixed(1); if (value !== lastPublishedMQTT_B_Act_Power) { MQTT.publish( SHELLY_ID + "/MyMQTTValues/B_Act_Power", value, 0, false ); lastPublishedMQTT_B_Act_Power = value; if (log > 0) print("B_Act_Power: " + value); } // c act power let value = em.c_act_power.toFixed(1); if (value !== lastPublishedMQTT_C_Act_Power) { MQTT.publish( SHELLY_ID + "/MyMQTTValues/C_Act_Power", value, 0, false ); lastPublishedMQTT_C_Act_Power = value; if (log > 0) print("C_Act_Power: " + value); } // a voltage let value = em.a_voltage.toFixed(1); if (value !== lastPublishedMQTT_A_Voltage) { MQTT.publish( SHELLY_ID + "/MyMQTTValues/A_Voltage", value, 0, false ); lastPublishedMQTT_A_Voltage = value; if (log > 0) print("A_Voltage: " + value); } // b voltage let value = em.b_voltage.toFixed(1); if (value !== lastPublishedMQTT_B_Voltage) { MQTT.publish( SHELLY_ID + "/MyMQTTValues/B_Voltage", value, 0, false ); lastPublishedMQTT_B_Voltage = value; if (log > 0) print("B_Voltage: " + value); } // c voltage let value = em.c_voltage.toFixed(1); if (value !== lastPublishedMQTT_C_Voltage) { MQTT.publish( SHELLY_ID + "/MyMQTTValues/C_Voltage", value, 0, false ); lastPublishedMQTT_C_Voltage = value; if (log > 0) print("C_Voltage: " + value); } } } Timer.set(500, true, timerHandler, null); 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.