PV Power/ Money Gain

Hi Guys,

I have two different solar systems and would like to have the profit calculated for me on a permanent basis, minus my electricity consumption. Unfortunately I have the problem that I don’t know exactly how to define the formulas that you use

  1. only the purchased electricity (i.e. the plus electricity) multiplied by my electricity price and this also counts permanently.

  2. With the excess electricity, the profit counts permanently.

Can someone help me? I have already prepared the basic formula, but a lot is still missing here. I search here in the Forum but I think the problem is to complex to me :smiley:

Thank you in advance.

power consumption:
friendly_name: ‘power consumption’
unit_of_measurement: “W”
value_template: "{{(states (‘sensor.shelly_shem_3_d8bfc01a82c7_1_current_consumption’) | float + states (‘sensor.shelly_shem_3_d8bfc01a82c7_2_current_consumption’) () | float + states ('sensor.
electricity costs:
friendly_name: ‘Electricity costs’
unit_of_measurement: ‘€’
value_template: “{{(states (‘sensor.power consumption’) | float * 0.30) | round (2)}}”
Profit:
friendly_name: ‘Profit’
unit_of_measurement: ‘€’
value_template: “{{(states (‘sensor.power consumption’) | float * 0.11) | round (2)}}”

There should be no spaces in your entity ids. Replace spaces with underscores. e.g.

value_template: "{{(states ('sensor.power_consumption') | float * 0.30) | round (2)}}"
                                         ^

Also, please format your pasted code. It is impossible to see if your indentation is correct.

Hi Tom,

sorry! now the right format

platform: template
    sensors:
        stromverbrauch:
          friendly_name: 'Stromverbrauch'
          unit_of_measurement: "W"
          value_template: "{{ (states('sensor.shelly_shem_3_d8bfc01a82c7_1_current_consumption')|float + states('sensor.shelly_shem_3_d8bfc01a82c7_2_current_consumption')|float + states('sensor.shelly_shem_3_d8bfc01a82c7_3_current_consumption')|float)|round(3) }}"
        stromkosten:
          friendly_name: 'Stromkosten'
          unit_of_measurement: '€'
          value_template: "{{ (states('sensor.stromverbrauch')|float * 0.30)|round(2) }}"   
        Gewinn:
          friendly_name: 'Gewinn'
          unit_of_measurement: '€'
          value_template: "{{ (states('sensor.stromverbrauch')|float * 0.11)|round(2) }}"

Look here: Forum text markup for instructions, look at the part called Codeblocks on how to format/show yaml or other code.

ok thx for the Tip. I fixed it!

After searching a while I have now create some Statistic and Sensor. But I don’t understand at which point i must combine Shelly and statistic.



  - platform: statistics
    name: Stromverbrauch_pro_Minute
    entity_id: sensor.stromverbrauch_pro_Minute
    sample_size: 60

  - platform: template
    sensors:
        Gesamtverbrauch:
          friendly_name: 'Gesamtverbrauch'
          value_template: "{{ state_attr('sensor.stromverbrauch_pro_Minute', 'total') / (1000 * 60) }}"
          unit_of_measure: "kwH"
        
        stromverbrauch:
          friendly_name: 'Stromverbrauch_aktuell'
          unit_of_measurement: "W"
          value_template: "{{ (states('sensor.shelly_shem_3_d8bfc01a82c7_1_current_consumption')|float + states('sensor.shelly_shem_3_d8bfc01a82c7_2_current_consumption')|float + states('sensor.shelly_shem_3_d8bfc01a82c7_3_current_consumption')|float)|round(3) }}"
        stromkosten:
          friendly_name: 'Stromkosten'
          unit_of_measurement: '€'
          value_template: "{{ (states('sensor.stromverbrauch')|float * 0.30)|round(2) }}"   
        Gewinn:
          friendly_name: 'Gewinn'
          unit_of_measurement: '€'
          value_template: "{{ (states('sensor.stromverbrauch')|float * 0.11)|round(2) }}"