Exploring Solar Energy Monitoring in Home Assistant

Hi everyone, I’ve been diving into the world of solar energy monitoring with Home Assistant, and I wanted to share my experiences and some questions I’ve come across. :sun_with_face:

I recently set up a solar system and decided to track its performance using Home Assistant. My goal was to monitor the peak energy output to better understand how my system is performing. I stumbled upon a template sensor setup that tracks the maximum value of my solar system’s grid power. Here’s what I came up with:

  • sensor:
    • name: “SolarPeakMax”
      unit_of_measurement: “W”
      state_class: “total_increasing”
      state: >
      {% if states(“sensor.grid_power”) in [‘unknown’, ‘unavailable’, ‘0’, ‘0.0’] %}
      {% set sensorOutput = states(“sensor.SolarPeakMax”) %}
      {% else %}
      {% set sensorGrid = states(“sensor.grid_power”) | int(0)%}
      {% set sensorSolarPeakMax = states(“sensor.SolarPeakMax”) | int(0)%}
      {% if sensorGrid > sensorSolarPeakMax %}
      {% set sensorOutput = sensorGrid %}
      {% else %}
      {% set sensorOutput = sensorSolarPeakMax %}
      {% endif %}
      {% endif %}
      {{ sensorOutput }}

This setup works perfectly during normal operation, updating the maximum value whenever the grid power exceeds the current peak. However, I’ve noticed an issue after restarting Home Assistant. The peak value resets to the current grid power reading instead of retaining the highest value recorded before the restart. It’s a bit frustrating because it means I lose the historical data I’ve been tracking.

I’ve read through some forum posts and tried adding the state_class: "total_increasing" line to persist the state, but it doesn’t seem to solve the problem. Has anyone else encountered this issue? Are there any workarounds or solutions you’ve found? I’d love to hear your thoughts!

On a positive note, I’ve been impressed with how customizable Home Assistant is. Even though I’m still learning, the ability to create custom sensors and automations is truly empowering. It’s amazing how a bit of YAML can turn an idea into a functional part of my smart home setup. :dart:

If anyone has tips on how to make this solar monitoring setup more robust or has suggestions for other energy-tracking projects, I’d be happy to hear them! Let’s keep the solar energy conversation going! :sunny:

Cheers,
[Your Name]