Electricity consumption Share of PV system

Hello everyone,

I have a domestic hot water heat pump Stiebel Warmwasser-Wärmepumpe WWK 300 and a PV system.

Using evcc, I have integrated a Shelly 1 which switches on the heat pump when there is a PV surplus. This also works without any problems.

I have plugged a Plug S in front of the heat pump so that I can measure my electricity consumption.

Unfortunately, I can now only see how much electricity I consume, but not what comes from the PV system and what comes from the “socket”.

Is there a way to count the power consumption when the Shelly 1 is switched on (i.e. PV surplus). I could then calculate total consumption - PV surplus and thus have consumption from the “socket”.

Thanks for your help

Greetings Diver

You need to add another electricity meter

Hello Miwyf
Thank you for your reply.
What kind of electricity meter do I still need?
I have the “electricity meter” from Solaredge, which counts what comes from PV and what comes from the grid.

However, I have the Plug S, which also indicates how much electricity I have consumed. Now I thought it might be possible to create an “automation” that starts a second count when the Shelly1 is switched on by evcc.
Unfortunately, I am not familiar enough with yaml programming to be able to do this on my own. :slight_smile:
Maybe someone has already “tinkered” something like this for their whale box, because I would also like to implement this, but I thought I would start with the smaller Shelly first.
Then the go-E charger Gen3 wallbox would be next.

Thanks for your help.
Unfortunately, everything is full of snow at the moment, so I’m not even getting 1 watt from the PV system. :slight_smile:

Snowy greetings Diver

If you have an “electricity meter” from Solaredge, you don’t need another meter. Here is a yaml example you can refer to:

  - platform: template
        friendly_name: "Energy3"
        value_template: "{{ states('sensor.energy1') | float - states('sensor.energy2') | float }}"
        unit_of_measurement: "kWh"
        device_class: energy

Hello Miwyf,
i tried it with this Sensor



  • platform: template
    value_template: “{{ state_attr(‘switch.shelly_shsw_1_e8db84d27ec8’, ‘consumption’) }}”


and tried a automation like this:



  • alias: “PV-Überschuss-Verbrauch messen”
    - platform: state
    entity_id: switch.shelly_shsw_1_e8db84d27ec8
    to: “on”
    - service: sensor.update_state
    entity_id: sensor.pv_ueberschuss_verbrauch
    value: “{{ state_attr(‘switch.shelly_shsw_1_e8db84d27ec8’, ‘consumption’) }}”


but i always get this message:

Message malformed: extra keys not allowed @ data[‘automation’]

what do i wrong?

This switch.shelly_shsw_1_e8db84d27ec8 contains sensor data?

ok, sorry and what does this means? :frowning:

switch.shelly_shsw_1_e8db84d27ec8 Isn’t this a switch? Does it also contain some photovoltaic data?

Hello an a happy new year.
Sorry that i anwere just now, but Christmas and so on. you know. :slight_smile:
Oh man i got crazy with this automation.
I just wanted Homeassistant to count the power consumption of the Shelly plug-s when the Shelly 1 has the status “on”, but somehow I can’t get it to work.
Maybe someone can help me, I have tried the following.
alias: Stromzähler Warmwasser bei PV überschuss

  • platform: template
    entity_id: switch.shelly_shsw_1_e8db84d27ec8
    state: “on”
  • service: homeassistant.update_state
    state: {{ state_attr(“sensor.stromzahler_warmepumpe_warmwasser”, “last_reading”) }}

than i get this error message:
Message malformed: extra keys not allowed @ data[‘entity_id’]

Thanks for your help