Page 1 of 1

Usable Battery Sensor

Posted: Wed Oct 19, 2022 8:01 pm
by Dave Foster
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 %}

Re: Usable Battery Sensor

Posted: Wed Oct 19, 2022 8:11 pm
by Will
Nice post, this will help a lot of people.

Re: Usable Battery Sensor

Posted: Fri Mar 10, 2023 7:57 pm
by Kris
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

Re: Usable Battery Sensor

Posted: Sun Mar 12, 2023 11:52 am
by Dave Foster
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.

Re: Usable Battery Sensor

Posted: Mon Mar 13, 2023 8:53 pm
by Kris
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

Re: Usable Battery Sensor

Posted: Tue Mar 14, 2023 9:42 am
by Dave Foster
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.

Re: Usable Battery Sensor

Posted: Fri Mar 17, 2023 6:32 pm
by Kris
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

Re: Usable Battery Sensor

Posted: Sat Mar 18, 2023 9:19 am
by Dave Foster
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.