How to integrate Shelly 3EM in Emoncms local?

It is a theoretical question at the moment as I don’t have an emoncms server running.
But I plan to run one as I would also like to monitor my other 3-phase input running on another tariff for my heatpump.

I have a Shelly 3EM for monitoring my 3-phase house input (and solar output) connection.
What would be the way to get the data from the Shelly device to Emoncms?

The Shelly has a REST API where you can query the measurements.
If I disable the cloud access, it also has MQTT, although probably not in the format Emonhub is expecting data.

I was thinking of something simple in Node Red. It would query the Shelly REST API and in the same flow commit the data to Emoncms with HTTP.

Could this be working? Did somebody manage something like this already?

I don’t have a 3EM, but I do have a 1PM. I use Node-RED to convert the MQTT from the Shelly to an emon/shellies-topic for emoncms.

Thank you very much!

It seems like a good solution and I am happy to hear, that it is already working.
The firmware of EM and 3EM should not be that much different from this point of view.

I have a further question on this subject, hope that someone has the answer.

Would it be possible to use the HTTP post from Shelly, to send data straight to another server then the Shelly cloud? And that way divert data from Shelly cloud to any server of my own preference?

Is there any place i can find out how the post string looks like and how to use it?

Thank you kindly for any input here, as you notice i am not a developer.

best regards

I know of no documentation about the format of the data posted to the Shelly cloud.

But at Shelly you can find the documentation about getting data from the Shelly locally over HTTP.
Finally I use this way to read data from my Shellies with NodeRed.

Hello M2ts,
I’m totally new on nodered.

I’m trying to connect a shelly HT to emoncms. Please could you explain how do you set “string2numer” note ?

thank you.

GL

Look at the JSONATA docs. Numeric functions · JSONata.

However, I think Emoncms will translate a string to number when it reads the topic (IIRC).

You can use a JSONATA string function to set the Topics.

Hi I am trying to get my Shelly data also into Emoncms and have been following a number if threads to try and make it work… Could someone clarify the steps? I have nodered setup on a pi - do I need an mqtt server? would really really appreciate some advice on the pieces and how?

This node-red flow has following code:

[
    {
        "id": "8df86475.aaf888",
        "type": "comment",
        "z": "d9c796e6.c2ab38",
        "name": "Shelly 3EM H-tarifa gépház",
        "info": "",
        "x": 410,
        "y": 40,
        "wires": []
    },
    {
        "id": "5cf9dc07.825e24",
        "type": "comment",
        "z": "d9c796e6.c2ab38",
        "name": "EmonBase",
        "info": "",
        "x": 1020,
        "y": 20,
        "wires": []
    },
    {
        "id": "746f1cd83294019b",
        "type": "mqtt out",
        "z": "d9c796e6.c2ab38",
        "name": "",
        "topic": "emon/shellies",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "7e58b0fd.b40ed",
        "x": 1040,
        "y": 80,
        "wires": []
    },
    {
        "id": "7aa382efa6dd5620",
        "type": "http request",
        "z": "d9c796e6.c2ab38",
        "name": "HTTP GET request - Shelly H-tarifa",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "http://192.168.1.36/status",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 480,
        "y": 80,
        "wires": [
            [
                "d19e2b9b01f6bf7a"
            ]
        ]
    },
    {
        "id": "c8e60ef593b182b3",
        "type": "inject",
        "z": "d9c796e6.c2ab38",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 190,
        "y": 60,
        "wires": [
            [
                "7aa382efa6dd5620",
                "30db49ce4537de79",
                "0ed1caaa9251fdfd"
            ]
        ]
    },
    {
        "id": "d19e2b9b01f6bf7a",
        "type": "function",
        "z": "d9c796e6.c2ab38",
        "name": "H-tarifa",
        "func": "var emeter_L1 = msg.payload.emeters[0];\nvar emeter_L2 = msg.payload.emeters[1];\nvar emeter_L3 = msg.payload.emeters[2];\nvar emeter = {\"H_tarifa_L1_power\": emeter_L1.power,\n              \"H_tarifa_L1_pf\": emeter_L1.pf,\n              \"H_tarifa_L1_current\": emeter_L1.current,\n              \"H_tarifa_L1_voltage\": emeter_L1.voltage,\n              \"H_tarifa_L1_total\": emeter_L1.total,\n              \"H_tarifa_L1_total_returned\": emeter_L1.total_returned,\n              \n\t\t\t  \"H_tarifa_L2_power\": emeter_L2.power,\n              \"H_tarifa_L2_pf\": emeter_L2.pf,\n              \"H_tarifa_L2_current\": emeter_L2.current,\n              \"H_tarifa_L2_voltage\": emeter_L2.voltage,\n              \"H_tarifa_L2_total\": emeter_L2.total,\n              \"H_tarifa_L2_total_returned\": emeter_L2.total_returned,\n\n\t\t\t  \"H_tarifa_L3_power\": emeter_L3.power,\n              \"H_tarifa_L3_pf\": emeter_L3.pf,\n              \"H_tarifa_L3_current\": emeter_L3.current,\n              \"H_tarifa_L3_voltage\": emeter_L3.voltage,\n              \"H_tarifa_L3_total\": emeter_L3.total,\n              \"H_tarifa_L3_total_returned\": emeter_L3.total_returned,\n};\n\nvar msgout = { payload : emeter };\nmsgout.topic='H-tarifa';\n\nreturn msgout;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 760,
        "y": 80,
        "wires": [
            [
                "a3a019199cf138ad",
                "746f1cd83294019b",
                "15d7ec6c8cee2bce"
            ]
        ]
    },
    {
        "id": "7e58b0fd.b40ed",
        "type": "mqtt-broker",
        "name": "Emonbase",
        "broker": "192.168.1.24",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

It simply does a http request to the Shelly 3EM and constructs a JSON string, which is actually a list of the values for the 3 phases.
Then it is passed to an MQTT node. The MQTT broker runs on my local emonPi/emonBase.
You will find the data under Inputs/shellies in emonCMS.

Depending on what you want to do with data, you need to configure processing the inputs to feeds, like sum of L1+L2+L3.

thnx bekesizl for replying and sharing your code… starting to make more sense

i am using a shellyplus 1pm - the status api is giving me a Not found error… now trying to understand why not returning info

Unfortunately I only have 1st generation devices, no ShellyPlus.

Here is the part of the documentation about my Shelly 3EM.
https://shelly-api-docs.shelly.cloud/gen1/#shelly-3em-status

Here is the documentation of the Gen2 devices.
My example uses the HTTP GET request.

Maybe this one is the closest to the one I am using:

You should direct the output of the HTTP GET node to a debug node and check the results. Then you will have to assemle a JSON object with the new data.