Energy Management in Home Assistant

Hi @tvds
I have a Saj inversor, and I found a workaround, but I’m facing a little issue.
My inversor goes on standby at night, and the sensor on HA becomes unavailable, so I used a workround:
I use a template sensor to count when the sensor isn’t “unavailable” or “unknow”:

sensor:
  - platform: template
    sensors:
      correct_energy_production:
        friendly_name: Energia Produzida Total
        icon_template: mdi:flash
        unit_of_measurement: kWh
        value_template: "{{ states('sensor.saj_today_yield')|float }}"
        availability_template: >
          {% if is_state("sensor.saj_today_yield", "unavailable") %}
            false
          {% elif is_state("sensor.saj_today_yield", "unknown") %}
            false
          {% else %}
            true
          {%- endif %}

and then I use a utility_meter for daily cicles:

utility_meter:
  total_production_daily:
    source: sensor.correct_energy_production
    cycle: daily

The only issue is at the end of solar production, the sensor get an astronic value, and I can’t figure out how to solve it. Example, today I produced 12.5KWh, and the utility_meter was counting good, until the inverter goes standby, after that, the sensor shows 74.9KWh as production today.

I also use influxdb and grafana, and the values coming from the sensor.saj_today_yield is correct
Screenshot 2021-08-05 at 01.12.24

Yeah. Same here.

Standard Solaredge integration, and although it has access to consumption, self consumption, generation, exported to grid etc it doesn’t show up.

I’ve created template sensors that replicate all those values again with state_class: measurement but still no luck as it appears template sensors aren’t supported.

+1 to emporia…

I’ve added that single solar source, but can’t seem to add the SolarEdge exported and imported power (using the standard SolarEdge cloud integration).

This looks amazing, thanks HA team!

Has anyone got this working with the fronius integration?

It looks like the sensors don’t have the required attributes.

Okay. Looks like the SolarEdge other sensors need last_reset added with the same value as the “date” attribute as they reset their values daily. I’ve managed to get them to show up by hard-coding their values, but not sure what code change would be required to update the integration.

state_class: measurement
last_reset: <set to the "date" atribute somehow>

2 Likes

Cheers mate. I’ve just added the code you supplied. All sensors seem to be working, and I’ve added them to the energy page, but grid consumption and return to grid are not showing anything. I’ve given it a few hours so something should be showing.

EDIT: Hmm, seems to have just updated. LOL. Now to check to make sure all the values are correct.

For what it’s worth I opened an issue to track this as my experience mirrors yours so far.

Thanks @dgaust, I got my sensors hooked up like yours are but I had to change the base sensors from sensor.envoy_current_energy_XXXXX to sensor.envoy_current_power_XXXXX. Would you please confirm that this is correct? I think they renamed those sensors for unit accuracy since they are reporting Watts (power) and not Watt-hours (energy).

      solar_export_value:
        friendly_name: Solar Export Value
        icon_template: mdi:solar-panel
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% set value = (('%0.1f' | format(states('sensor.envoy_current_power_production') | float - states('sensor.envoy_current_power_consumption') | float)) | float) %}
          {% if value  <= 0 -%} 
            0
          {%- else -%}
            {{ value | round(2) }}
          {%- endif %}

      house_consumption_value:
        friendly_name: House Importing Value
        icon_template: mdi:transmission-tower
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {% set value = (('%0.1f' | format(states('sensor.envoy_current_power_consumption') | float - states('sensor.envoy_current_power_production') | float)) | float) %}
          {% if value  <= 0 -%} 
            0
          {%- else -%}
            {{ value | round(2) }}
          {%- endif %}

Unfortunately, I still don’t see the “Exported Energy” option I created to select from the “Return to grid” dropdown box. However, maybe I need that sensor to have some value besides zero on it (since it’s nighttime and I have not exported anything to the grid since creating the sensor)?
Hopefully, tomorrow I’ll see it pop up in there and I’ll be ready to go…

Yes, they may have changed, I’ve had the integration for almost a year now - so those entities have been around a while.

It looks ok to me - but you now need to create the other sensors and point them to these template sensors (yes, it’s a little complex).

- platform: integration
  source: sensor.house_consumption_value
  name: Imported Energy
  unit_prefix: k
  round: 2
  method: left

- platform: integration
  source: sensor.solar_export_value
  name: Exported Energy
  unit_prefix: k
  round: 2
  method: left

Restart, and then check to make sure those sensors exist - and also make sure they both have the following attributes

device_class: energy
state_class: measurement
last_reset: '2021-07-31T11:04:08.091669+00:00' (just any time in the past is fine)

If they’re not there, just use the customise entity option to add/change them.

They should then be available to select.

edit: Sorry, saw you’d created those integration sensors. So just double check the attributes are there.

2 Likes

Thanks @dgaust, I got it working with your help. It was that I needed to force the units as well (via customize). Once I did that I saw the “Exported Energy” option available.

I’m really getting excited about this new Energy Management in HA. I wonder if we’ll eventually be able to represent the array per-panel like the Enphase Enlighten app:
image

I’ve been wanting to do something like this with Home Assistant for so long… :smiley:

Is there a way to add a fixed daily cost to the energy cost calculation? I’m thinking like an extra entry field here:

8 Likes

Yet? Suggests this is possibly coming, is that correct?

How on earth did you get a Fronius to show up in here? I’ve spent the better part of the day trying to get either of the two integrations for them to show useful data

I didn’t do anything special, this is the code:

sensor:
  - platform: fronius
    resource: http://192.168.1.141
    scan_interval: 10
    monitored_conditions:
    - sensor_type: inverter
    - sensor_type: meter
    - sensor_type: power_flow

I’ll be checking tomorrow to see if the ones I’ve selected produce the correct values.

First of all great work !

But I’m missing home battery integration on the dashboard. Is this planned for the future.

What hardware to get for easiest setup to monitor my household energy consumption?
I’ve got a Sonoff Pow but it’s only monitoring the fridge at the moment.
Shelly EM seems like a good option?

How are you seeing AUD/kWh ? i’m seeing EUR when my location is correct in the system as far as I know

image

Just to add to my previous reply, the following sensors give the correct values:

Frenck’s reply from earlier:

There is a new setting for local currency.

3 Likes