Energy Management in Home Assistant

Yes, I use Envoy and participated in the beta. You need to create some additional sensors for ‘real time’ consumption and export.

    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_energy_production') | float - states('sensor.envoy_current_energy_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_energy_consumption') | float - states('sensor.envoy_current_energy_production') | float)) | float) %}
        {% if value  <= 0 -%} 
          0
        {%- else -%}
          {{ value | round(2) }}
        {%- endif %}

You then create two additional sensors using the Reimann Sum integration and point them to the sensors created above

- 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

During the beta, one of these sensors had all the required values, but one didn’t. So I had to customise to add the device_class: energy, state_class: measurement and last_reset value.

Then set the imported energy sensor to be the ‘Grid Consumption’, exported exergy sensor as ‘Return to Grid’

edit: Added method: left to the integration sensors, since generation/consumption is considered spiky.

6 Likes