Jump to content

3empro


urmel

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.


 

 

Link to comment
Share on other sites

@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);

 

Script-Settings.png

MQTT-Settings.png

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.

×
×
  • Create New...