Usable Battery Sensor

Post Reply
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

The standard Fox battery SoC sensor returns a 0-99% value (it never gets to 100%), coupled with the fact that a portion of the battery is unavailable for use (normally set to 10%) it can be a bit confusing when trying to explain the display.

This sensor code provides a 'usable battery' sensor by deducting the unusable minimum SoC and provides a full range 0-100% sensor that represents only the portion of the battery that is usable.

For example if the minimum SoC is set to 10%, only 89% of the battery is actually usable - this 89% is then scaled up to provide a full 0 - 100% sensor.

The sensor below needs to be added to your configuration.yaml file, if you run a different minSoc than the default value of 10, enter the value you use and it will then provide a new sensor.usable_battery

Code: Select all

  - sensor:
      - name: "Usable Battery"
        unit_of_measurement: "%"
        state: >
          {% set minSoC = 10 | float %}
          {% if  states("sensor.battery_soc") in ['unknown', 'unavailable', 'none'] %}
            {{ states("sensor.battery_soc") }}
          {% elif  states("sensor.battery_soc")|float >= minSoC%}
            {{ ( (states("sensor.battery_soc")|float - minSoC ) * (100/(99-minSoC)) )|round(0, default=0) }}
          {% else %}
            {{ 0|float }}
          {% endif %}
Edit: - this second version is for the latest firmware and Cube batteries where the battery SoC is reported full range to 100%

Code: Select all

  - sensor:
      - name: "Usable Battery"
        unit_of_measurement: "%"
        device_class: battery
        state: >
          {% set minSoC = 10 | float %}
          {% if  states("sensor.battery_soc") in ['unknown', 'unavailable', 'none'] %}
            {{ states("sensor.battery_soc") }}
          {% elif  states("sensor.battery_soc")|float > minSoC%}
            {{ ( ((states("sensor.battery_soc")|float - minSoC) * (100/(100-minSoC)) ))|round(0, default=0) }}
          {% else %}
            {{ 0|int }}
          {% endif %}
Last edited by Dave Foster on Sun Mar 12, 2023 11:56 am, edited 1 time in total.
User avatar
Will
Site Admin
Posts: 262
Joined: Thu Oct 13, 2022 5:56 pm

Nice post, this will help a lot of people.
Community Admin / FoxESS Elite Professional

Buy me a coffee or Book a zoom meeting for remote consultancy

FoxESS Tri Inverter Installation
2 x KH Series Inverters
24 x HV2600 (62.4kWh)
32 x 490w across 4 arrays
Dual Tesla Household
Heatpump & Low Carbon Housebuild
Kris
Posts: 7
Joined: Tue Feb 14, 2023 6:19 pm

Nice one, I'll try that.

I am also trying to find a way to see the individual cell voltages and temperatures.

Is this possible?

TA

Kris
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

Kris wrote: Fri Mar 10, 2023 7:57 pm
I am also trying to find a way to see the individual cell voltages and temperatures.

Is this possible?

TA

Kris
The only way you can do this is if you have the latest firmware versions and installer access on your app.

If you have Home Assistant and download the latest modbus version, as long as you have updated firmware you will be able to see the battery cell highest/lowest temperatures, battery cell highest/lowest voltage levels, kWh_remaining and number of battery cycles recorded.
Kris
Posts: 7
Joined: Tue Feb 14, 2023 6:19 pm

Many thanks, I am running home assistant, but where do I get the latest firmware?
I think I'm on 1.48
H1-ac Firmware.jpeg
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

Kris wrote: Mon Mar 13, 2023 8:53 pm Many thanks, I am running home assistant, but where do I get the latest firmware?
I think I'm on 1.48H1-ac Firmware.jpeg
Firmware can only be loaded if you have an agent account, but normally you would speak to your installer and ask them to update you to the latest versions. I believe Fox support will update if asked but it won't be a priority unless you are reporting an error.
Kris
Posts: 7
Joined: Tue Feb 14, 2023 6:19 pm

Sorry for being dense, I can see the individual cell Temps/voltage on the foxcloud app, but I can't find those sensors in home assistant, how do I know if I have the latest Modbus version, and how do I install it?
I'm very new to HA and not a programmer, but I am very interested in getting as much info out of my inverter as possible.
Any help, would be greatly appreciated.

Many thanks
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

Kris wrote: Fri Mar 17, 2023 6:32 pm Sorry for being dense, I can see the individual cell Temps/voltage on the foxcloud app, but I can't find those sensors in home assistant, how do I know if I have the latest Modbus version, and how do I install it?
Many thanks
I think by the individual cell Temps/voltages you mean down to individual cell level (so 16 per pack, times number of packs)- these aren't available on any of the modbus versions. What is available in the latest modbus RS485 version is the BMS reported cell temperature High & Low values and also the BMS reported cell High and Low voltages, which are very useful in understanding why the BMS is charging when the 'Battery Temp' is showing everything is fine.
Post Reply