Lovelace Battery Card

I absolutely love this battery card and would love to see it able to be used as a generic battery card with entities.

Right now, only available for the GivEnergy devices.

Is anyone up to the task to make this a generic lovelace card. It is such a good battery card!

2 Likes

I use this card for the Homewizard plug-in battery.
By creating a number of template helpers, this card is easy to use for multiple types of batteries.

1 Like

would you be able to give us a few ideas on how you did this using custom helpers you mention? i am just starting out on my HA journey and would like to see if I can use this for my Sunsynk battery. when i try to create a battery crd of this type it is understandably not finding the giv integration and i can’t get past the inverter selection as the entity hasn’t been created. TIA!

I use the custom entity id’s. The entities that I didn’t have I created the helpers for.
For example for the discharge and charge power.

I have a working card with the following config:

type: custom:givtcp-battery-card
entity: sensor.marstek_battery_device_name
use_custom_sensors: true
custom_battery_power: sensor.marstek_battery_marstek_ac_power
custom_soc: sensor.marstek_battery_marstek_battery_state_of_charge
custom_soc_kwh: sensor.marstek_battery_marstek_battery_remaining_capacity
custom_discharge_power: sensor.marstek_discharging_in_w
custom_charge_power: sensor.marstek_charging_in_w
custom_battery_capacity_kwh: sensor.marstek_battery_marstek_battery_total_energy
custom_battery_charge_energy_today_kwh: sensor.marstek_battery_marstek_daily_charging_energy
custom_battery_discharge_energy_today_kwh: sensor.marstek_battery_marstek_daily_discharging_energy
custom_battery_power_reserve: number.marstek_battery_marstek_discharging_cutoff_capacity
custom_battery_charge_rate: number.marstek_battery_marstek_max_charge_power
custom_battery_discharge_rate: number.marstek_battery_marstek_max_discharge_power

You have to set all the parameters otherwise there will be an error

2 Likes

nice card, I just made some template variables to be able to use it with my Marstek Venus E V3 battery. But i’m wondering which values are expected for custom_battery_charge_rate and custom_battery_discharge_rate ? in what units are those? How can i calculate those with my existing current power & kWh counters ?
I see in Djes example fixed input_number parameters ? So you put max charge power to ex. 2500 Watt ? and discharge rate to max discharge power rate of 795 W ?
edit: yep that seems to be max rates:

I have this working for a Foxess battery with a h3 smart inverter. I’m no expert, but figured I would share encase anyone is looking for this and wants to try get it working with a fox inverter.

I had to create a custom sensor, that used the SOC % and and the Max SOC to give the sensor for the remaining KWH,

template:
  - sensor:
      - name: "Battery SOC kWh"
        unique_id: battery_soc_kwh
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: measurement
        icon: mdi:battery-medium
        state: >
          {% set max_kwh = states('sensor.foxessinvertermb_bms_kwh_remaining_1') | float(0) %}
          {% set soc_percent = states('sensor.foxessinvertermb_battery_soc_1') | float(0) %}
          {% set current_kwh = (max_kwh * soc_percent / 100) %}
          {{ current_kwh | round(2) }}
        availability: >
          {{ has_value('sensor.foxessinvertermb_bms_kwh_remaining_1') and
             has_value('sensor.foxessinvertermb_battery_soc_1') }}
        attributes:
          max_capacity_kwh: "{{ states('sensor.foxessinvertermb_bms_kwh_remaining_1') | float(0) | round(2) }}"
          soc_percentage: "{{ states('sensor.foxessinvertermb_battery_soc_1') | float(0) | round(1) }}"
          remaining_kwh: "{{ states('sensor.battery_soc_kwh') | float(0) | round(2) }}"
          used_kwh: >
            {% set max_kwh = states('sensor.foxessinvertermb_bms_kwh_remaining_1') | float(0) %}
            {% set current_kwh = states('sensor.battery_soc_kwh') | float(0) %}
            {{ (max_kwh - current_kwh) | round(2) }}
          capacity_percentage_remaining: >
            {% set max_kwh = states('sensor.foxessinvertermb_bms_kwh_remaining_1') | float(0) %}
            {% set current_kwh = states('sensor.battery_soc_kwh') | float(0) %}
            {% if max_kwh > 0 %}
              {{ ((current_kwh / max_kwh) * 100) | round(1) }}
            {% else %}
              0
            {% endif %}

This is the actual card (note the name, I just threw anything in there)

type: custom:givtcp-battery-card
entity: sensor.foxessinvertermb_master_version
name: Battery
soc_threshold_very_high: 80
soc_threshold_high: 60
soc_threshold_medium: 40
soc_threshold_low: 20
soc_colour_input: rgb_picker
soc_threshold_very_high_colour:
  - 0
  - 69
  - 23
soc_threshold_high_colour:
  - 67
  - 160
  - 71
soc_threshold_medium_colour:
  - 255
  - 166
  - 0
soc_threshold_low_colour:
  - 219
  - 68
  - 55
soc_threshold_very_low_colour:
  - 94
  - 0
  - 0
display_abs_power: false
display_type: 3
display_dp: 3
icon_status_idle: mdi:sleep
icon_status_charging: mdi:lightning-bolt
icon_status_discharging: mdi:home-battery
display_battery_rates: true
use_custom_dod: true
custom_dod: 90
calculate_reserve_from_dod: true
display_custom_dod_stats: true
display_energy_today: true
trickle_charge_filter: false
trickle_charge_filter_threshold: 25
use_custom_sensors: true
custom_soc: sensor.foxessinvertermb_battery_soc_1
custom_battery_power: sensor.foxessinvertermb_invbatpower_1
custom_soc_kwh: sensor.battery_energy_available
custom_discharge_power: sensor.foxessinvertermb_battery_discharge_1
custom_charge_power: sensor.foxessinvertermb_battery_charge_1
custom_battery_capacity_kwh: sensor.foxessinvertermb_bms_kwh_remaining_1
custom_battery_charge_energy_today_kwh: sensor.foxessinvertermb_battery_charge_today
custom_battery_discharge_energy_today_kwh: sensor.foxessinvertermb_battery_discharge_today
custom_battery_power_reserve: number.foxessinvertermb_min_soc_on_grid
custom_battery_charge_rate: number.foxessinvertermb_force_discharge_power
custom_battery_discharge_rate: number.foxessinvertermb_force_discharge_power

I like the format of this card. I uesd the custom settings to represent my Zendure battery. Almost there, but somehow the card does not show “Carging” state (nor the charging power) when the battery charges.

I think the charging state and value is related to “custom_battery_power”, but what are the expected values here? When dischaging it shows correct state and discharge power.

I am also wondering what the “custom_battery_power_reserve” is meant for with what kind of value. (gues: if I have my minimum soc at 10%, is should represent 10% of the total capacity (custom_soc)? )

Hi,

Which card is that?

Regards,

Frank