API update

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

Dave Foster wrote: Tue Feb 20, 2024 1:49 pm
Dad wrote: Tue Feb 20, 2024 12:49 pm Slightly off topic (or is it?), do you know why the Fox app doesn’t have an accurate daily PV generation value on the Home Screen (like Energy Stats) as it’s probably the single most basic value a user looks for. It seems such an obvious gap in functionality.
I'm not sure of the reason but it has to be the single most asked for feature on the app - the strangest thing is that the inverter does actually report this to the Fox cloud but the cloud never reveals it in any of its data streams as if they forgot to store it in their database when they first started logging.

It was asked recently and i'm pretty sure the FoxESS UK support manager said it will be making it into the V2 app (but wouldn't promise when)
Also just as a quick update, the latest release of the FoxESS V2 app is now (finally) showing total solar (PV Yield) on the ‘plant’ screen (the house picture) at the bottom of the screen.
leonb
Posts: 15
Joined: Thu Dec 21, 2023 3:43 pm

It looks like to be both.

In the app, my battery capacity was showing as 203Wh so I have used the manual input option.

In HA it is showing as 0.1306kWh.

For HA, I had a peek and looks like my raw data value is in kWh and the sensor is then using 're / 100' for it.

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

leonb wrote: Wed Feb 21, 2024 3:18 pm It looks like to be both.

In the app, my battery capacity was showing as 203Wh so I have used the manual input option.

In HA it is showing as 0.1306kWh.

For HA, I had a peek and looks like my raw data value is in kWh and the sensor is then using 're / 100' for it.

Thanks.
Ok, thanks i’ll take a look and see if I can see anything - the residual is a new feature we requested so there may be something still not as we expected (like the unit specifier can be different)
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

Dave Foster wrote: Wed Feb 21, 2024 3:25 pm
leonb wrote: Wed Feb 21, 2024 3:18 pm It looks like to be both.

In the app, my battery capacity was showing as 203Wh so I have used the manual input option.

In HA it is showing as 0.1306kWh.

For HA, I had a peek and looks like my raw data value is in kWh and the sensor is then using 're / 100' for it.

Thanks.
Ok, thanks i’ll take a look and see if I can see anything - the residual is a new feature we requested so there may be something still not as we expected (like the unit specifier can be different)
@leonb Can you add some debugging if you get 5 minutes,

You will need to add these lines to your configuration.yaml

Code: Select all

logger:
  default: warn
  logs: 
    custom_components.foxess: debug
And then restart HA, leave it for 10 minutes have a look in your full logs, i’m looking for a long line of text that has OA Device Variables followed by a long list of variables -

Somewhere in there will be the entry that looks like {'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 1766.0}

We are expecting the unit to be 10Wh but i’m suspecting yours might be different - can you post what you are seeing please.

Afterwards remove the code to turn on logs (or change ‘debug’ to ‘warning’) and restart HA or it will create massive logs ;)

Code: Select all

logger:
  default: warn
  logs: 
    custom_components.foxess: warning
leonb
Posts: 15
Joined: Thu Dec 21, 2023 3:43 pm

Here you go. :)

{'report': {'feedin': 0.1, 'generation': 12.6, 'gridConsumption': 25.7, 'chargeEnergyToTal': 20.0, 'dischargeEnergyToTal': 11.3, 'loads': 17.5}, 'reportDailyGeneration': {'value': 12.5}, 'raw': {'ambientTemp
eration': 37.7, 'batChargePower': 0.0, 'batCurrent': -1.4, 'batDischargePower': 0.376, 'batTemperature': 28.0, 'batVolt': 232.8, 'epsCurrentR': 0.7, 'epsPower': 0.0, 'epsPowerR': 0.0, 'epsVoltR': 226.7, 'feedinPower': 0.0, 'generationPower': 0.488, 'gridConsumptionPower': 0.006, 'inv
BatCurrent': 1.6, 'invBatPower': 0.376, 'invBatVolt': 234.3, 'invTemperation': 34.1, 'loadsPower': 0.496, 'meterPower': 0.006, 'meterPower2': 0.0, 'pv1Current': 0.3, 'pv1Power': 0.069, 'pv1Volt': 185.1, 'pv2Current': 0.3, 'pv2Power': 0.062, 'pv2Volt': 170.0, 'pv3Current': 0.4, 'pv3Po
wer': 0.088, 'pv3Volt': 209.7, 'pv4Current': 0.0, 'pv4Power': 0.0, 'pv4Volt': 1.7, 'pvPower': 0.219, 'RCurrent': 2.4, 'RFreq': 50.13, 'RPower': 0.488, 'RVolt': 227.2, 'SoC': 62.0, 'ResidualEnergy': 12.75}, 'battery': {'minSoc': 14, 'minSocOnGrid': 14}, 'addressbook': {'deviceType': '
KH10.5', 'masterVersion': '1.16', 'afciVersion': '', 'hasPV': True, 'deviceSN': '', 'slaveVersion': '1.01', 'hasBattery': True, 'function': {'scheduler': False}, 'hardwareVersion': '--', 'managerVersion': '1.11', 'stationName': '', 'moduleSN': '', 'productType': 'KH', 'stationID': '', 'status': 1, 'plantName': ''}, 'online': True}

edit to put in what you actually asked!

{'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 12.34}

so looks like my data is coming through wrong....
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

leonb wrote: Wed Feb 21, 2024 4:23 pm Here you go. :)

, 'ResidualEnergy': 12.75}, 'battery': {'minSoc': 14, 'minSocOnGrid': 14}, 'addressbook': {'deviceType': '
KH10.5', 'masterVersion': '1.16', 'afciVersion': '', 'hasPV': True, 'deviceSN': '', 'slaveVersion': '1.01', 'hasBattery': True, 'function': {'scheduler': False}, 'hardwareVersion': '--', 'managerVersion': '1.11', 'stationName': '', 'moduleSN': '', 'productType': 'KH', 'stationID': '', 'status': 1, 'plantName': ''}, 'online': True}
Ahh it’s a KH trust that to be different ;)

It definitely thinks the residual energy is 12.75 so it’s a scaling problem - would you mind doing that one more time but see if you can find the line where it receives it’s ‘scale’ it happens every 5 mins when the integration polls the openapi and will have all the variables with their definitions something like this-

2024-02-21 09:45:32.988 DEBUG (MainThread) [custom_components.foxess.sensor] OA Device Variables Good Response: [{'unit': '℃', 'name': 'AmbientTemperature', 'variable': 'ambientTemperation', 'value': 34.3}, {'unit': 'kW', 'name': 'Charge Power', 'variable': 'batChargePower', 'value': 0.0}, {'unit': 'A', 'name': 'BatCurrent', 'variable': 'batCurrent', 'value': -0.8}, {'unit': 'kW', 'name': 'Discharge Power', 'variable': 'batDischargePower', 'value': 0.322}, {'unit': '℃', 'name': 'batTemperature', 'variable': 'batTemperature', 'value': 24.5}, {'unit': 'V', 'name': 'BatVolt', 'variable': 'batVolt', 'value': 424.9}, {'unit': '℃', 'name': 'ChargeTemperature', 'variable': 'chargeTemperature', 'value': 0.0}, {'unit': 'A', 'name': 'EPS-RCurrent', 'variable': 'epsCurrentR', 'value': 0.0}, {'unit': 'kW', 'name': 'EPSPower', 'variable': 'epsPower', 'value': 0.0}, {'unit': 'kW', 'name': 'EPS-RPower', 'variable': 'epsPowerR', 'value': 0.0}, {'unit': 'V', 'name': 'EPS-RVolt', 'variable': 'epsVoltR', 'value': 0.0}, {'unit': 'kW', 'name': 'Feed-in Power', 'variable': 'feedinPower', 'value': 0.0}, {'unit': 'kW', 'name': 'Output Power', 'variable': 'generationPower', 'value': 0.444}, {'unit': 'kW', 'name': 'GridConsumption Power', 'variable': 'gridConsumptionPower', 'value': 0.002}, {'unit': 'A', 'name': 'InvBatCurrent', 'variable': 'invBatCurrent', 'value': 0.7}, {'unit': 'kW', 'name': 'invBatPower', 'variable': 'invBatPower', 'value': 0.322}, {'unit': 'V', 'name': 'InvBatVolt', 'variable': 'invBatVolt', 'value': 427.1}, {'unit': '℃', 'name': 'InvTemperation', 'variable': 'invTemperation', 'value': 25.5}, {'unit': 'kW', 'name': 'Load Power', 'variable': 'loadsPower', 'value': 0.446}, {'unit': 'kW', 'name': 'MeterPower', 'variable': 'meterPower', 'value': 0.002}, {'unit': 'kW', 'name': 'Meter2Power', 'variable': 'meterPower2', 'value': 0.0}, {'unit': 'A', 'name': 'PV1Current', 'variable': 'pv1Current', 'value': 0.5}, {'unit': 'kW', 'name': 'PV1Power', 'variable': 'pv1Power', 'value': 0.108}, {'unit': 'V', 'name': 'PV1Volt', 'variable': 'pv1Volt', 'value': 216.7}, {'unit': 'A', 'name': 'PV2Current', 'variable': 'pv2Current', 'value': 0.4}, {'unit': 'kW', 'name': 'PV2Power', 'variable': 'pv2Power', 'value': 0.059}, {'unit': 'V', 'name': 'PV2Volt', 'variable': 'pv2Volt', 'value': 146.6}, {'unit': 'kW', 'name': 'PVPower', 'variable': 'pvPower', 'value': 0.16699999999999998}, {'unit': 'A', 'name': 'RCurrent', 'variable': 'RCurrent', 'value': 1.9}, {'unit': 'Hz', 'name': 'RFreq', 'variable': 'RFreq', 'value': 49.89}, {'unit': 'kW', 'name': 'RPower', 'variable': 'RPower', 'value': 0.444}, {'unit': 'V', 'name': 'RVolt', 'variable': 'RVolt', 'value': 250.6}, {'unit': '%', 'name': 'SoC', 'variable': 'SoC', 'value': 86.0}, {'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 1763.0}]

And right there at the end will be ResidualEnergy - in this case being scaled at unit = ‘10Wh’ - I think yours will say ‘1kWh’ but it would be really helpful to see the string.
leonb
Posts: 15
Joined: Thu Dec 21, 2023 3:43 pm

I did realise and edited my post... here is the whole thing... seems like the scaling is right but my data being returned is wrong....

custom_components.foxess.sensor] OA Device Variables Good Response: [
{'unit': '℃', 'name': 'AmbientTemperature', 'variable': 'ambientTemperation', 'value': 36.0},
{'unit': 'kW', 'name': 'Charge Power', 'variable': 'batChargePower', 'value': 0.0},
{'unit': 'A', 'name': 'BatCurrent', 'variable': 'batCurrent', 'value': -9.9},
{'unit': 'kW', 'name': 'Discharge Power', 'variable': 'batDischargePower', 'value': 2.37},
{'unit': '℃', 'name': 'batTemperature', 'variable': 'batTemperature', 'value': 27.9},
{'unit': 'V', 'name': 'BatVolt', 'variable': 'batVolt', 'value': 229.6},
{'unit': 'A', 'name': 'EPS-RCurrent', 'variable': 'epsCurrentR', 'value': 0.7},
{'unit': 'kW', 'name': 'EPSPower', 'variable': 'epsPower', 'value': 0.0},
{'unit': 'kW', 'name': 'EPS-RPower', 'variable': 'epsPowerR', 'value': 0.0},
{'unit': 'V', 'name': 'EPS-RVolt', 'variable': 'epsVoltR', 'value': 228.9},
{'unit': 'kW', 'name': 'Feed-in Power', 'variable': 'feedinPower', 'value': 0.0},
{'unit': 'kW', 'name': 'Output Power', 'variable': 'generationPower', 'value': 2.329},
{'unit': 'kW', 'name': 'GridConsumption Power', 'variable': 'gridConsumptionPower', 'value': 0.012},
{'unit': 'A', 'name': 'InvBatCurrent', 'variable': 'invBatCurrent', 'value': 10.2},
{'unit': 'kW', 'name': 'invBatPower', 'variable': 'invBatPower', 'value': 2.37},
{'unit': 'V', 'name': 'InvBatVolt', 'variable': 'invBatVolt', 'value': 230.7},
{'unit': '℃', 'name': 'InvTemperation', 'variable': 'invTemperation', 'value': 31.5},
{'unit': 'kW', 'name': 'Load Power', 'variable': 'loadsPower', 'value': 2.356},
{'unit': 'kW', 'name': 'MeterPower', 'variable': 'meterPower', 'value': 0.012},
{'unit': 'kW', 'name': 'Meter2Power', 'variable': 'meterPower2', 'value': 0.0},
{'unit': 'A', 'name': 'PV1Current', 'variable': 'pv1Current', 'value': 0.0},
{'unit': 'kW', 'name': 'PV1Power', 'variable': 'pv1Power', 'value': 0.017},
{'unit': 'V', 'name': 'PV1Volt', 'variable': 'pv1Volt', 'value': 176.5},
{'unit': 'A', 'name': 'PV2Current', 'variable': 'pv2Current', 'value': 0.1},
{'unit': 'kW', 'name': 'PV2Power', 'variable': 'pv2Power', 'value': 0.023},
{'unit': 'V', 'name': 'PV2Volt', 'variable': 'pv2Volt', 'value': 168.5},
{'unit': 'A', 'name': 'PV3Current', 'variable': 'pv3Current', 'value': 0.1},
{'unit': 'kW', 'name': 'PV3Power', 'variable': 'pv3Power', 'value': 0.041},
{'unit': 'V', 'name': 'PV3Volt', 'variable': 'pv3Volt', 'value': 223.5},
{'unit': 'A', 'name': 'PV4Current', 'variable': 'pv4Current', 'value': 0.0},
{'unit': 'kW', 'name': 'PV4Power', 'variable': 'pv4Power', 'value': 0.0},
{'unit': 'V', 'name': 'PV4Volt', 'variable': 'pv4Volt', 'value': 1.7},
{'unit': 'kW', 'name': 'PVPower', 'variable': 'pvPower', 'value': 0.081},
{'unit': 'A', 'name': 'RCurrent', 'variable': 'RCurrent', 'value': 10.2},
{'unit': 'Hz', 'name': 'RFreq', 'variable': 'RFreq', 'value': 49.98},
{'unit': 'kW', 'name': 'RPower', 'variable': 'RPower', 'value': 2.329},
{'unit': 'V', 'name': 'RVolt', 'variable': 'RVolt', 'value': 229.4},
{'unit': '%', 'name': 'SoC', 'variable': 'SoC', 'value': 60.0},
{'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 12.3}]
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

Oh boy ;) - leave it with me for a bit to ponder, I might be able to auto-detect the scale is wrong and do some trickery
leonb
Posts: 15
Joined: Thu Dec 21, 2023 3:43 pm

I've put this into the sensor for now and it seems to be displaying correctly.. :)

if 50 > re > 0:
re = re
elif re > 50:
re = re / 100
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

leonb wrote: Wed Feb 21, 2024 5:30 pm I've put this into the sensor for now and it seems to be displaying correctly.. :)

if 50 > re > 0:
re = re
elif re > 50:
re = re / 100
I was going to use 100 rather than 50, but yes exactly that 👍

I’ve got a few minor mods being tested so i’ll roll them, and this into the next release, thanks ☺️
Dad
Posts: 53
Joined: Mon Oct 30, 2023 12:04 pm

Dave Foster wrote: Wed Feb 21, 2024 1:56 pm Also just as a quick update, the latest release of the FoxESS V2 app is now (finally) showing total solar (PV Yield) on the ‘plant’ screen (the house picture) at the bottom of the screen.
Thanks for the update Dave. Do you know if the Fox value is using realtime data for the new daily PV Yield or if they are also using the five minute interval data?

From what I can see the Fox number is very close to the Energy Stats number but slightly higher which may be a rounding up thing.

Looks promising!
Fox BMS v2
Fox ESS Hybrid Inverter 3.7
Mira HV25 x5
Trina solar panels x8
Ohme Pro EV charger
Skoda Enyaq
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

They did say yesterday that they still needed to do a few tweaks on the algorithm, which sounds very much like it is integrating power over time (like Energy Stats does) - I use home assistant with modbus with samples every 5 seconds and it’s very close to what I see there, yep looking good 😊.
reef
Posts: 109
Joined: Sat Sep 09, 2023 10:06 am
Location: East Yorkshire

Dad wrote: Thu Feb 22, 2024 12:50 pm
Dave Foster wrote: Wed Feb 21, 2024 1:56 pm Also just as a quick update, the latest release of the FoxESS V2 app is now (finally) showing total solar (PV Yield) on the ‘plant’ screen (the house picture) at the bottom of the screen.
Thanks for the update Dave. Do you know if the Fox value is using realtime data for the new daily PV Yield or if they are also using the five minute interval data?

From what I can see the Fox number is very close to the Energy Stats number but slightly higher which may be a rounding up thing.

Looks promising!
I'm glad to see this feature finally. Like yourself I'm curious how it's calculated. Today it's showing 1.6kWh on the v2 app but energy stats shows 1.41kWh which is what I get too using the 5 minute data from the cloud. I might pop into the loft later and see if this matches the inverter screen value as that may provide insight into which is correct.

Edit: I've checked and the inverter also says 1.6kWh, so it appears this could be a "live" total, rather than the 5 minute interval data.
Dave Foster
Posts: 1305
Joined: Thu Oct 13, 2022 7:21 pm

Dave Foster wrote: Wed Feb 21, 2024 5:41 pm
leonb wrote: Wed Feb 21, 2024 5:30 pm I've put this into the sensor for now and it seems to be displaying correctly.. :)

if 50 > re > 0:
re = re
elif re > 50:
re = re / 100
I was going to use 100 rather than 50, but yes exactly that 👍

I’ve got a few minor mods being tested so i’ll roll them, and this into the next release, thanks ☺️
@leon_b - just as a quick update, I reported the problem with the KH (openAPI) to the FoxESS dev team -

Here is their response:
----------------------------------
Dear Dave
Thank you for your email, the issue is logged by our API and KH project team, we have already found the cause and will try to amend it as earlier as possible,

I will keep you posted
-------------------------------------

I'm not sure if that will be a KH firmware update, or an internal fix in their data storage servers - but i'll update when I hear more.
leonb
Posts: 15
Joined: Thu Dec 21, 2023 3:43 pm

Dave Foster wrote: Sat Feb 24, 2024 5:48 pm
Dave Foster wrote: Wed Feb 21, 2024 5:41 pm
leonb wrote: Wed Feb 21, 2024 5:30 pm I've put this into the sensor for now and it seems to be displaying correctly.. :)

if 50 > re > 0:
re = re
elif re > 50:
re = re / 100
I was going to use 100 rather than 50, but yes exactly that 👍

I’ve got a few minor mods being tested so i’ll roll them, and this into the next release, thanks ☺️
@leon_b - just as a quick update, I reported the problem with the KH (openAPI) to the FoxESS dev team -

Here is their response:
----------------------------------
Dear Dave
Thank you for your email, the issue is logged by our API and KH project team, we have already found the cause and will try to amend it as earlier as possible,

I will keep you posted
-------------------------------------

I'm not sure if that will be a KH firmware update, or an internal fix in their data storage servers - but i'll update when I hear more.
OK thanks for checking with them. :)

I only noticed the residual energy value after updating the HA integration (due to the API change and first time I had done it in 5 months) so I'm not sure if a previous firmware had introduced this or if Fox just allowed us to get a bit more info from all the data they already collect.
Post Reply