Shelly EM support

Hey guys,

I have 2 x Shelly EM with 3 CT, 1 on each of my 2 inverters and one on my main switch measuring total import/export.

Is there a way to get this data into PV output?

https://shelly.cloud/shelly-energy-meter-with-contactor-control-wifi-smart-home-automation/

Do you use home assistant or node red?

Yes I have both running.

This is how I do it. I’ve renamed my shelly em’s to Utility and Solar. Home assistant sensor and utility meter config pasted below.

[
    {
        "id": "bcba7892.f81718",
        "type": "api-current-state",
        "z": "3ecef44f.692d0c",
        "name": "Daily Solar",
        "server": "cbbf6ce3.4f5eb",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.daily_solar_energy_wh",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "",
        "override_data": "none",
        "blockInputOverrides": false,
        "x": 210,
        "y": 620,
        "wires": [
            [
                "91ccdcd1.126c2"
            ]
        ]
    },
    {
        "id": "ba80a412.30d8b8",
        "type": "inject",
        "z": "3ecef44f.692d0c",
        "name": "Every 5 Minutes",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "300",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 230,
        "y": 540,
        "wires": [
            [
                "bcba7892.f81718",
                "12cf0de3.3d1642",
                "e3acb2c1.7a983",
                "27f9ebae.0c5e14",
                "cb1b8a.3b766478",
                "88e8e360.2b18e",
                "3ea9a1a8.cb079e",
                "4e320437.1c9b7c"
            ]
        ]
    },
    {
        "id": "b0ef636d.fa8a5",
        "type": "join",
        "z": "3ecef44f.692d0c",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "8",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 650,
        "y": 540,
        "wires": [
            [
                "e60ed32d.448f"
            ]
        ]
    },
    {
        "id": "91ccdcd1.126c2",
        "type": "change",
        "z": "3ecef44f.692d0c",
        "name": "V1",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "v1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 620,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "12cf0de3.3d1642",
        "type": "api-current-state",
        "z": "3ecef44f.692d0c",
        "name": "Total Solar Power",
        "server": "cbbf6ce3.4f5eb",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.total_solar_power",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "",
        "override_data": "none",
        "blockInputOverrides": false,
        "x": 230,
        "y": 660,
        "wires": [
            [
                "708af9f1.e1ff28"
            ]
        ]
    },
    {
        "id": "e3acb2c1.7a983",
        "type": "api-current-state",
        "z": "3ecef44f.692d0c",
        "name": "Daily Consumed",
        "server": "cbbf6ce3.4f5eb",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.daily_consumed_energy_wh",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "",
        "override_data": "none",
        "blockInputOverrides": false,
        "x": 220,
        "y": 700,
        "wires": [
            [
                "a3029cb7.1ef1c"
            ]
        ]
    },
    {
        "id": "27f9ebae.0c5e14",
        "type": "api-current-state",
        "z": "3ecef44f.692d0c",
        "name": "Consumed Power",
        "server": "cbbf6ce3.4f5eb",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.total_consumed_power",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "",
        "override_data": "none",
        "blockInputOverrides": false,
        "x": 230,
        "y": 740,
        "wires": [
            [
                "b77b4aca.2f1178"
            ]
        ]
    },
    {
        "id": "cb1b8a.3b766478",
        "type": "api-current-state",
        "z": "3ecef44f.692d0c",
        "name": "Temperature",
        "server": "cbbf6ce3.4f5eb",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.temperature",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "",
        "override_data": "none",
        "blockInputOverrides": false,
        "x": 210,
        "y": 780,
        "wires": [
            [
                "66dd12e5.e2bffc"
            ]
        ]
    },
    {
        "id": "88e8e360.2b18e",
        "type": "api-current-state",
        "z": "3ecef44f.692d0c",
        "name": "Volts",
        "server": "cbbf6ce3.4f5eb",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "sensor.utility_voltage",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "",
        "override_data": "none",
        "blockInputOverrides": false,
        "x": 190,
        "y": 820,
        "wires": [
            [
                "3800e3d4.15a57c"
            ]
        ]
    },
    {
        "id": "708af9f1.e1ff28",
        "type": "change",
        "z": "3ecef44f.692d0c",
        "name": "V2",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "v2",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 660,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "a3029cb7.1ef1c",
        "type": "change",
        "z": "3ecef44f.692d0c",
        "name": "V3",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "v3",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 700,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "b77b4aca.2f1178",
        "type": "change",
        "z": "3ecef44f.692d0c",
        "name": "V4",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "v4",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 740,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "66dd12e5.e2bffc",
        "type": "change",
        "z": "3ecef44f.692d0c",
        "name": "V5",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "v5",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 780,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "3800e3d4.15a57c",
        "type": "change",
        "z": "3ecef44f.692d0c",
        "name": "V6",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "v6",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 470,
        "y": 820,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "4af04a29.1038a4",
        "type": "function",
        "z": "3ecef44f.692d0c",
        "name": "Set API key and site ID",
        "func": "msg.action = msg.payload;\nmsg.headers = { \n 'X-Pvoutput-Apikey': 'sd0fusoijflksd',\n 'X-Pvoutput-SystemId': '0909098',\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 720,
        "y": 640,
        "wires": [
            [
                "1203ae8.a034a52"
            ]
        ]
    },
    {
        "id": "1203ae8.a034a52",
        "type": "function",
        "z": "3ecef44f.692d0c",
        "name": "Set up data",
        "func": "msg.action = msg.payload;\n\nmsg.url = \"http://pvoutput.org/service/r2/addstatus.jsp\";\n\n\n\nreturn msg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "x": 710,
        "y": 700,
        "wires": [
            [
                "8103e596.265d78"
            ]
        ]
    },
    {
        "id": "8103e596.265d78",
        "type": "http request",
        "z": "3ecef44f.692d0c",
        "name": "Post",
        "method": "POST",
        "ret": "txt",
        "paytoqs": false,
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 710,
        "y": 760,
        "wires": [
            [
                "6baee9d7.af3e38"
            ]
        ]
    },
    {
        "id": "6baee9d7.af3e38",
        "type": "debug",
        "z": "3ecef44f.692d0c",
        "name": "headercheck",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 710,
        "y": 820,
        "wires": []
    },
    {
        "id": "3ea9a1a8.cb079e",
        "type": "moment",
        "z": "3ecef44f.692d0c",
        "name": "Date",
        "topic": "d",
        "input": "",
        "inputType": "date",
        "inTz": "America/Edmonton",
        "adjAmount": 0,
        "adjType": "days",
        "adjDir": "add",
        "format": "YYYYMMDD",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "America/Edmonton",
        "x": 470,
        "y": 540,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "4e320437.1c9b7c",
        "type": "moment",
        "z": "3ecef44f.692d0c",
        "name": "Time",
        "topic": "t",
        "input": "",
        "inputType": "date",
        "inTz": "America/Edmonton",
        "adjAmount": 0,
        "adjType": "days",
        "adjDir": "add",
        "format": "HH:mm",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "America/Edmonton",
        "x": 470,
        "y": 580,
        "wires": [
            [
                "b0ef636d.fa8a5"
            ]
        ]
    },
    {
        "id": "e60ed32d.448f",
        "type": "delay",
        "z": "3ecef44f.692d0c",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "5",
        "rateUnits": "minute",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "x": 700,
        "y": 580,
        "wires": [
            [
                "4af04a29.1038a4"
            ]
        ]
    },
    {
        "id": "cbbf6ce3.4f5eb",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": false
    }
]

sensor config

- platform: mqtt
  name: "Utility Power 1"
  state_topic: "shellies/Utility/emeter/0/power"
  qos: 1
  unit_of_measurement: "W"
  icon: mdi:gauge
- platform: mqtt
  name: "Utility Power 2"
  state_topic: "shellies/Utility/emeter/1/power"
  qos: 1
  unit_of_measurement: "W"
  icon: mdi:gauge        
- platform: mqtt
  name: "Utility Voltage"
  state_topic: "shellies/Utility/emeter/1/voltage"
  qos: 1
  unit_of_measurement: "V"
  icon: mdi:gauge   
- platform: mqtt
  name: "Utility Energy 1"
  state_topic: "shellies/Utility/emeter/0/energy"
  qos: 1
  unit_of_measurement: "Wm"
- platform: mqtt
  name: "Utility Energy 2"
  state_topic: "shellies/Utility/emeter/1/energy"
  qos: 1
  unit_of_measurement: "Wm"

- platform: mqtt
  name: "Solar Power 1 Raw"
  state_topic: "shellies/Solar/emeter/0/power"
  qos: 1
  unit_of_measurement: "W"
  icon: mdi:gauge
- platform: mqtt
  name: "Solar Power 2 Raw"
  state_topic: "shellies/Solar/emeter/1/power"
  qos: 1
  unit_of_measurement: "W"
  icon: mdi:gauge        
- platform: mqtt
  name: "Solar Voltage"
  state_topic: "shellies/Solar/emeter/1/voltage"
  qos: 1
  unit_of_measurement: "V"
  icon: mdi:gauge   
- platform: mqtt
  name: "Solar Energy 1"
  state_topic: "shellies/Solar/emeter/0/energy"
  qos: 1
  unit_of_measurement: "Wm"
- platform: mqtt
  name: "Solar Energy 2"
  state_topic: "shellies/Solar/emeter/1/energy"
  qos: 1
  unit_of_measurement: "Wm"


- platform: integration
  source: sensor.total_solar_power
  name: total_solar_energy
  unit_prefix: k
  round: 2   
- platform: integration
  source: sensor.total_utility_power
  name: total_utility_energy
  unit_prefix: k
  round: 2  
- platform: integration
  source: sensor.total_consumed_power
  name: total_consumed_energy
  unit_prefix: k
  round: 2
  
- platform: template
  sensors:
    solar_power_1:
      value_template: >
        {{ (states('sensor.solar_power_1_raw')|float - 3) |round(2) }}
      friendly_name: 'Solar Power 1'
      unit_of_measurement: 'W'   
    solar_power_2:
      value_template: >
        {{ (states('sensor.solar_power_2_raw')|float - 3) |round(2) }}
      friendly_name: 'Solar Power 2'
      unit_of_measurement: 'W'       
    consumed_power_1:
      value_template: >
        {{ (states('sensor.solar_power_1')|float 
        + states('sensor.utility_power_1')|float) |round(2) }}
      friendly_name: 'Consumed Power 1'
      unit_of_measurement: 'W'       
    consumed_power_2:
      value_template: >
        {{ (states('sensor.solar_power_2')|float 
        + states('sensor.utility_power_2')|float) |round(2) }}
      friendly_name: 'Consumed Power 2'
      unit_of_measurement: 'W'          
    total_consumed_power:
      value_template: >
        {{ (states('sensor.consumed_power_1')|float 
        + states('sensor.consumed_power_2')|float)| round(2) }}
      friendly_name: 'Total Consumed Power'
      unit_of_measurement: 'W'   
    total_solar_power:
      value_template: >
        {{ (states('sensor.solar_power_1')|float 
        + states('sensor.solar_power_2')|float)| round(2) }}
      friendly_name: 'Total Solar Power'
      unit_of_measurement: 'W'       
    total_utility_power:
      value_template: >
        {{ (states('sensor.utility_power_1')|float 
        + states('sensor.utility_power_2')|float)| round(2) }}
      friendly_name: 'Total Utility Power'
      unit_of_measurement: 'W'
    total_solar_power_kw:
      value_template: >
        {{ (states('sensor.total_solar_power')|float /1000) | round(2) }}
      friendly_name: 'Total Solar Power kW'
      unit_of_measurement: 'kW'       
    total_utility_power_kw:
      value_template: >
        {{ (states('sensor.total_utility_power')|float /1000) | round(2) }}
      friendly_name: 'Total Utility Power kW'
      unit_of_measurement: 'kW'
    daily_solar_energy_wh:
      value_template: >
        {{ (states('sensor.solar_daily_energy_peak')|float *1000) | round(2) }}
      friendly_name: 'Daily Solar Energy Wh'
      unit_of_measurement: 'Wh'         
    daily_consumed_energy_wh:
      value_template: >
        {{ (states('sensor.consumed_daily_energy_peak')|float *1000) | round(2) }}
      friendly_name: 'Daily Solar Energy Wh'
      unit_of_measurement: 'Wh'         

utility meter config

  utility_yearly_energy:
    source: sensor.total_utility_energy
    cycle: yearly
    tariffs: 
      - peak
    net_consumption: true
    
  utility_monthly_energy:
    source: sensor.total_utility_energy
    cycle: monthly
    net_consumption: true
    tariffs: 
      - peak
    
  utility_daily_energy:
    source: sensor.total_utility_energy
    cycle: daily  
    net_consumption: true
    tariffs: 
      - peak
    
  solar_daily_energy:
    source: sensor.total_solar_energy
    cycle: daily  
    net_consumption: true
    tariffs: 
      - peak
    
  solar_monthly_energy:
    source: sensor.total_solar_energy
    cycle: monthly  
    net_consumption: true
    tariffs: 
      - peak    

  solar_yearly_energy:
    source: sensor.total_solar_energy
    cycle: yearly  
    net_consumption: true
    tariffs: 
      - peak
      
  consumed_daily_energy:
    source: sensor.total_consumed_energy
    cycle: daily  
    net_consumption: true
    tariffs: 
      - peak    
      
  consumed_monthly_energy:
    source: sensor.total_consumed_energy
    cycle: monthly  
    net_consumption: true
    tariffs: 
      - peak    
      
  consumed_yearly_energy:
    source: sensor.total_consumed_energy
    cycle: yearly  
    net_consumption: true
    tariffs: 
      - peak
1 Like

wow thanks!

I must admit I’m only a beginner when it comes to HA but hopefully I can get this working :slight_smile:

No problem, let me know if you run into trouble.

Which method do you use to change the name of the shelly?

Getting this, but nothing on pv output, any ideas?

4/14/2020, 8:54:53 PM[node: headercheck](http://192.********)

v6 : msg : Object

object

_msgid: "53c4d337.4b0b3c"

topic: "v6"

payload: "OK 200: Added Output"

action: object

d: "20200414"

t: "20:54"

v1: "0.0"

v2: "-6.0"

v3: "1095"

v4: "1071.72"

v6: "238.38"

headers: object

date: "Tue, 14 Apr 2020 10:54:53 GMT"

set-cookie: array[1]

expires: "Thu, 01 Jan 1970 00:00:00 GMT"

content-type: "text/plain;charset=ISO-8859-1"

connection: "close"

server: "Jetty(7.6.17.v20150415)"

strict-transport-security: "max-age=15768000"

x-node-red-request-node: "d67fed14"

statusCode: 200

responseUrl: "https://pvoutput.org/service/r2/addoutput.jsp"

redirectList: array[0]

responseCookies: object

JSESSIONID: object

Path: "/"

value: "n00rw6d0chf01gtebdvnco4wi"

The shelly device name is somewhere in network settings, maybe under advanced?
Did you change the Setup Data node?
My url address is:
http://pvoutput.org/service/r2/addstatus.jsp

This is my header check output:

4/14/2020, 12:59:12 PM[node: headercheck](https://xxxxxxxxxxxxxx.duckdns.org/api/hassio_ingress/S5wodszvyxxxxxxxxxxPGhfU1u32PU/#)v6 : msg : Object

object

topic: "v6"

payload: "OK 200: Added Status"

_msgid: "8da21982.aa8278"

action: object

d: "20200414"

t: "12:59"

v1: "4750.0"

v2: "1031.86"

v3: "8350.0"

v4: "693.03"

v5: "6.7"

v6: "125.33"

headers: object

date: "Tue, 14 Apr 2020 18:59:17 GMT"

set-cookie: array[1]

expires: "Thu, 01 Jan 1970 00:00:00 GMT"

content-type: "text/plain;charset=ISO-8859-1"

connection: "close"

server: "Jetty(7.6.17.v20150415)"

x-node-red-request-node: "15629492"

url: "http://pvoutput.org/service/r2/addstatus.jsp"

statusCode: 200

responseUrl: "http://pvoutput.org/service/r2/addstatus.jsp"

redirectList: array[0]

responseCookies: object

JSESSIONID: object

Path: "/"

value: "wv816q5nzoo3plisdiip2vgm"

Yeah that’s what it was :slight_smile:

Still have to configure my Solar shelly but the Utility feed is working.

Thanks!

it’s unclear to me if somebody managed to get the data from shelly 3EM straight into PVOutput, without the need for intermediate systems such as Home Assistant and/or Node-red.

Please clarify, the above seems to indicate there’s always an intermediate node.

Any update to the topic to upload the data directly from Shelly to PVOutput?