Closed piluxh closed 3 years ago
When I had a little bit of a dig into the files used to generate the entities of the enphase integration (Of which only 2 exist that can be used on the energy dashboard) the only difference between the ones selectable and the ones not selectable is the last_reset() which exists on the ones that can be selected for use on the energy dashboard. By creating a janky utility meter that has the unit of measure "kWh" and a resetting cycle (daily/weekly/monthly etc) that causes a reset you can use those for the energy dashboard. Please see difference between sensors below.
SENSORS = ( SensorEntityDescription( key="production", name="Current Power Production", unit_of_measurement=POWER_WATT, state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key="daily_production", name="Today's Energy Production", unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="seven_days_production", name="Last Seven Days Energy Production", unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="lifetime_production", name="Lifetime Energy Production", unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, last_reset=dt.utc_from_timestamp(0), ), SensorEntityDescription( key="consumption", name="Current Power Consumption", unit_of_measurement=POWER_WATT, state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key="daily_consumption", name="Today's Energy Consumption", unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="seven_days_consumption", name="Last Seven Days Energy Consumption", unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="lifetime_consumption", name="Lifetime Energy Consumption", unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, last_reset=dt.utc_from_timestamp(0),
What I have also discovered through this whole thing is that enphase "Consumption" and "Production" are Gross values. That is to say that the consumption displayed is inclusive of production. Likewise with production, it is gross, displaying total generated not how much was consumed internally and/or exported back to the grid.
It has meant I've had to create some custom sensors via templating and math etc to achieve what should realistically be easily integrated into the system.
If you use the energy dashboard using the gross values you will notice that without a statistical sensor with units of measure 'kWh" and last_reset() defined being used as a "return to grid" sensor, all production is attributed as being consumed.
This leads the energy dashboard to display Your consumption from the grid (Already grossed thanks to the enphase integration entities being made available to include grid and self generation consumption) and your production (Gross generation including what you sent back to the grid...thanks again enphase integration) as being consumed by your dwelling.
I've created custom Gross and Net instantaneous production and consumption sensors as well as custom gross and net utility meters that allow me to feed the net energy consumption to the energy dashboard for consumption however because there is no way to pull the extra detail of how much was exported back to grid from the enphase integration, there is always the assumption by the energy dashboard that 100% of generation was consumed...leading to an error between the enphase unit and app to the energy dashboard by the amount exported back to grid (Instead being applied back to home consumption).
The end result on the energy dashboard is net consumption (Gross Consumed - gross generation) + gross generation = total consumption with no export to grid.
While I suppose it is no big deal, it does mean that when you are exporting to the grid due to excess generation, and when you are importing from the grid (During no generation) that isn't captured accurately.
When you are paying $0.26/kWh you consume from the grid vs being paid $0.08/kWh for generation back into the grid it throws off any kind of $$$ calculations you may be running.
Anyone wanting to use the custom utility meters or sensors below is the extract from my sensors.yaml for you.
xxxxxxxxxxxx should be your envoy serial number and your device probably won't have the "system" bit after the xxxxxxxxxxxx since I edited the device name after the envoy integration had finished.
platform: template sensors: solar_gross_producing: friendly_name: "Solar Gross Producing kW" unit_of_measurement: kW value_template: "{{ ((states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_production') | float) /1000 ) | round(3) }}"
platform: template sensors: solar_gross_consuming: friendly_name: "Solar Gross Consuming kW" unit_of_measurement: kW value_template: "{{ ((states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_consumption') | float) /1000 ) | round(3) }}"
platform: template sensors: solar_net_consuming: friendly_name: "Solar Net Consuming kW" unit_of_measurement: kW value_template: > {% if (((states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_consumption') | float) - (states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_production') | float)) /1000) | round(3) < 0 %} 0 {% else %} {{ (((states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_consumption') | float) - (states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_production') | float)) /1000) | round(3) }} {% endif %}
platform: template sensors: solar_net_producing: friendly_name: "Solar Net Producing kW" unit_of_measurement: kW value_template: > {% if (((states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_production') | float) - (states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_consumption') | float)) /1000) | round(3) < 0 %} 0 {% else %} {{ (((states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_production') | float) - (states('sensor.envoy_s_xxxxxxxxxxxx_system_current_power_consumption') | float)) /1000) | round(3) }} {% endif %}
platform: template sensors: solar_gross_production: friendly_name: "Solar Total Production" unit_of_measurement: kWh value_template: "{{ ((states('sensor.envoy_s_xxxxxxxxxxxx_system_today_s_energy_production') | float) /1000 ) | round(3) }}"
platform: template sensors: solar_gross_consumption: friendly_name: "Solar Total Consumption" unit_of_measurement: kWh value_template: "{{ ((states('sensor.envoy_s_xxxxxxxxxxxx_system_today_s_energy_consumption') | float) /1000 ) | round(3) }}"
platform: template sensors: solar_net_consumption: friendly_name: "Solar Net Imported" unit_of_measurement: kWh value_template: "{{ (((states('sensor.envoy_s_xxxxxxxxxxxx_system_today_s_energy_consumption') | float) - (states('sensor.envoy_s_xxxxxxxxxxxx_system_today_s_energy_production') | float)) /1000) | round(3) }}"
It tells why:
That’s caused by a bug in the integration providing the entity. Integrations need to configure their entities correctly so Home Assistant knows that we need to track statistics for it and how.
Also asks to report a bug and a developer reference you could pass along to the developers.
It tells why:
That’s caused by a bug in the integration providing the entity. Integrations need to configure their entities correctly so Home Assistant knows that we need to track statistics for it and how.
Also asks to report a bug and a developer reference you could pass along to the developers.
There are many people using MQTT for energy already, so we are the developer of the integration if you like. My energy provider has MQTT interface with realtime/watts, daily, weekly, monthly, yearly Kwh, updated every ten seconds. Home Assistant seems to want to know last_reset for MQTT this is the key info missing and why energy will not use your entity this should be clearer on the page that says "report a bug to the developer of your integration". last_reset is already inferred via daily sensor reading being less than the previous reading. There are various workarounds by feeding the utility_meter integration with your entity and making it daily amount, then using utility meter to feed the energy integration/add-on, I guess this will be duplicating data and seems like an extra step that should not be needed.
Feedback
This page is referenced from the energy configuration page when specifying an entity. If the entity is not listed, you are linked to this page. This page only says that it is a bug in the integration, but not WHY.
URL
https://www.home-assistant.io/more-info/statistics/
Version
2021.8.3
Additional information
No response