Help needed on DYI Solar Power Monitoring System

Hi Guys I’m making a DIY Solar power monitoring system for my small PV setup

I’ve used a NodeMCU and INA219 with ESPHome for this and the ESP Config is as following

esphome:
  name: solar_power_meter
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "!SECRET"
  password: "!SECRET"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

#Active I2C buss
#Sprcify GPIO pins for ESP board used
i2c:
  sda: 4
  scl: 5
  scan: True
#current-voltage sensor

sensor:
  - platform: ina219
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "Solar Current"
      accuracy_decimals: 3
      filters:
       - multiply: 120
    power:
      name: "Solar Power"
      filters:
       - multiply: 120
    bus_voltage:
      name: "Bus Voltage"
      accuracy_decimals: 3
    shunt_voltage:
      name: "Shunt Voltage"
      filters:
      - multiply: 120
      accuracy_decimals: 3
    max_voltage: 32.0V
    max_current: 3.2A
    update_interval: 1s

The INA219 sends the data in every 1 Seconds and I’m able to get the below output in my HA
image

Now I want to get a “so far accumulate power” and “Day wise accumulated power” generated by the PV system in my HA.

I believe that can be done by a custom sensor with some value template, but I’m no expert in this area, could any one please help me with the above request.

Well, With history sensor I’m really confuse how to achieve what I want, would you be able to help me with some more inputs.

I tried the following but I’m not sure what to give in the state

 - platform: history_stats
   name: Power As of now
   entity_id: sensor.solar_power
   type: time
   start: '{{ now().replace(hour=6).replace(minute=0).replace(second=0) }}'
   duration:
     hours: 12

Looking at it again, I may have leapt too soon. I assume Power (being in watts) is the power being delivered at a point in time. What you are wanting is total energy produced in watt hours, in other words an integral of the power over time. I probably should have pointed you here https://www.home-assistant.io/components/integration/

1 Like

Thanks much @nickrout :smiley:

- platform: integration
  source: sensor.solar_power
  name: solar_energy_generated

With the above I’m able to get the following stat.
image

Now how can I get Day wise stat ? Can I use Utility Meter for this ? Will the following give me the proper output which I want ?

utility_meter:
  daily_energy:
    source: sensor.solar_energy_generated
    cycle: daily

I think so.

1 Like

Thanks @nickrout For pointing me in the right direction. :slight_smile:

With the Help of Integration and Utility Meter Sensors I’m able achieve what I wanted.

1 Like