Shelly em pv export

Hi
I have solar system and shelly em for power export consolation.
I am getting reading in watts … What I am missing??

utility_meter:
energy_export_daily:
source: sensor.solar_export_corrected
name: Energy Export Daily
cycle: daily

sensor:

  • platform: template
    sensors:
    instant_power_energy_to_grid:
    friendly_name: “Current Energy to Grid”
    unit_of_measurement: ‘W’
    value_template: >-
    {% set current_power = states(‘sensor.shelly_shem_1_current_consumption’)|float %}
    {% if current_power < 0 %}
    {{ (-current_power) }}
    {% else %}
    0
    {% endif %}

  • platform: template
    sensors:
    solar_export_corrected:
    friendly_name: D Solar Export kWh
    unit_of_measurement: kWh
    value_template: “{{ (states(‘sensor.instant_power_energy_to_grid’)|float / 1000) | round(2)}}”

You question maybe??

Sorry, but I could not resist :wink:
Welcome to this community, but you have to be more clear on your question and/or issue with Home Assistant.
What exactly is your problem?
And also: when you post code, please do it such that it is correctly formatted and thus better readable.
How to do that: Format it properly

1 Like

shelly em clamp on main cable sensor.shelly_shem_1_current_consumption
I am looking to monitor pv export to grid.
But I am getting w not kwh reading
I have traded different codes (Google ) still no luck

my code in configuration.yml

utility_meter:
energy_export_daily:
source: sensor.solar_export_corrected
name: Energy Export Daily
cycle: daily
- peak
- offpeak

sensor:

  • platform: template
    sensors:
    instant_power_energy_to_grid:
    friendly_name: “Current Energy to Grid”
    unit_of_measurement: ‘W’
    value_template: >-
    {% if states(‘sensor.shelly_shem_3494547bba4a_2_current_consumption’) | float(0) - states(‘sensor.shelly_shem_3494547bba4a_1_current_consumption’) | float(0) < 0 %}
    {{(states (‘sensor.shelly_shem_3494547bba4a_1_current_consumption’) | float(0) - states(‘sensor.shelly_shem_3494547bba4a_2_current_consumption’) | float(0)) | round (3) }}
    {% else %}
    {{(states (‘0.0’) | float(0)) |round(3) }}
    {% endif %}
    device_class: energy

  • platform: template
    sensors:
    solar_export_corrected:
    friendly_name: D Solar Export kWh
    unit_of_measurement: kWh
    value_template: “{{ (states(‘sensor.instant_power_energy_to_grid’)|float / 1000)}}”