I have a home assistant display that matches the power display of the enPhase app. This required dealing with the following issues:
Battery Power -
The envoy_2024xxxxx_current_battery_discharge appears to have a random drift so that the total battery discharge must be calculated from the separate battery power values:
calcBatteryPwr.py ...
mport math
import sys
batteryPwr4540 = float(sys.argv[1])/1000.0
batteryPwr1062 = float(sys.argv[2])/1000.0
batteryPwr = batteryPwr4540 + batteryPwr1062
print("{0:0.3f}".format(batteryPwr))
"""
batteryPwr4540 : sensor.encharge_492350004540_power
power output from battery4540
batteryPwr4540 : sensor.encharge_492350001062_power
power output from battery1062
batteryPwr : total combined battery output power
"""
Net Consumption -
For a system with batteries, the term consumption was confusing. The sensor envoy_202406020944_current_net_power_consumption is net power from/to the grid where consumption on the enPhase app is net consumption within the house.
calcNetConsumption.py ...
import math
import sys
solarProduction = float(sys.argv[1])
netPowerImport = float(sys.argv[2])
batteryPwr4540 = float(sys.argv[3])/1000.0
batteryPwr1062 = float(sys.argv[4])/1000.0
netConsumption = solarProduction + netPowerImport + batteryPwr4540 + batteryPwr1062
print("{0:0.3f}".format(netConsumption))
"""
netPowerImport : envoy_202406020944_current_net_power_consumption
net power comming off the grid
battertDischarge: envoy_202406020944_current_battery_discharge
if positive power out from battery
if negative power into battery
solarPower : envoy_202406020944_current_power_consumption
only positive or 0
netConsumption : netPowerImport + solarPower + batteryPwr4540 + batteryPwr1062
"""
Configuration -
These python scripts are add as Command_line sensors in the configuration file. Note your paths to the scripts may differ.
command_line:
- sensor:
name: Net Consumed Power
command: "python3 /var/snap/home-assistant-snap/current/scripts/calcNetConsumption.py {{ states('sensor.envoy_202406020944_current_power_production') }} {{ states('sensor.envoy_202406020944_current_net_power_consumption') }} {{ states('sensor.encharge_492350004540_power') }} {{ states('sensor.encharge_492401001062_power') }}"
unit_of_measurement: "kW"
unique_id: "sensor.net_consumed_power"
- sensor:
name: Total Battery Power
command: "python3 /var/snap/home-assistant-snap/current/scripts/calcBatteryPwr.py {{ states('sensor.encharge_492350004540_power') }} {{ states('sensor.encharge_492401001062_power') }}"
unit_of_measurement: "kW"
unique_id: "sensor.total_battery_power"
I plot these values as single panel History- graph
title: Daily Power Balance
type: panel
cards:
- type: history-graph
entities:
- entity: sensor.total_battery_power
- entity: sensor.envoy_202406020944_current_power_production
- entity: sensor.envoy_202406020944_current_net_power_consumption
- entity: sensor.net_consumed_power
hours_to_show: 12

