Enphase Energy and HomeAssistant
If you have Enphase solar PV and battery systems, it is relatively easy to integrate them with HomeAssistant.
Enabling Battery Calculations In Energy Dashboard
By default, the Envoy IQ Battery 5P doesn't come with charging and discharging CTs. However, there is a sensor that shows how many watts are flowing to or from the battery at a given time (if it's negative the battery is discharging, if it's positive the battery is charging).
Identify Your Power Sensor ID
You'll need to track down your encharge sensor id by going to Settings > Devices & Services > Enphase Envoy > Encharge <some id>
Click through to "Power":
If you click "Show more" Home Assistant will open up a longer graph showing the battery power over time and you will see the sensor ID in the URL:
http://homeassistant.local:8123/history?entity_id=sensor.encharge_012345678901_power&start_date=<date>
Make a note of the bolded value for your device.
Add Split Functions
Based on the HomeAssistant Enphase Envoy documentation you can create separate two sensors which are needed for displaying the rate of charge and the rate of discharge separately. Adding something like the following to your config yaml should work.
# Other configuration...
template:
- sensor:
- name: "Battery Charge Power"
unique_id: calculated_envoy_battery_charge_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
state: "{{ [0, states('sensor.encharge_123456789012_power') | int(0)] | max }}"
- name: "Battery Discharge Power"
unique_id: calculated_envoy_battery_discharge_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
state: "{{ [0, -(states('sensor.encharge_123456789012_power') | int(0))] | max }}"